From 98007c98e4fe7504c1c918c7632034fde6282e17 Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Mon, 11 May 2020 00:44:12 +0800 Subject: [PATCH] move PCL project to shared --- Pixiview.iOS/GlobalSuppressions.cs | 2 + Pixiview.iOS/Pixiview.iOS.csproj | 7 +- Pixiview.sln | 42 ++++------- Pixiview/GlobalSuppressions.cs | 9 --- Pixiview/Pixiview.csproj | 32 --------- Pixiview/Pixiview.projitems | 102 +++++++++++++++++++++++++++ Pixiview/Pixiview.shproj | 11 +++ Pixiview/Resources/ResourceHelper.cs | 30 +++++--- Pixiview/UI/SegmentedControl.cs | 3 +- Pixiview/UI/StyleDefinition.cs | 73 +++++++++---------- Pixiview/Utils/Stores.cs | 2 +- 11 files changed, 191 insertions(+), 122 deletions(-) delete mode 100644 Pixiview/GlobalSuppressions.cs delete mode 100644 Pixiview/Pixiview.csproj create mode 100644 Pixiview/Pixiview.projitems create mode 100644 Pixiview/Pixiview.shproj diff --git a/Pixiview.iOS/GlobalSuppressions.cs b/Pixiview.iOS/GlobalSuppressions.cs index 4285a53..692d919 100644 --- a/Pixiview.iOS/GlobalSuppressions.cs +++ b/Pixiview.iOS/GlobalSuppressions.cs @@ -6,3 +6,5 @@ using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage("Style", "IDE0066:Convert switch statement to expression", Justification = "")] +[assembly: SuppressMessage("Style", "IDE0057:Use range operator", Justification = "")] +[assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "")] diff --git a/Pixiview.iOS/Pixiview.iOS.csproj b/Pixiview.iOS/Pixiview.iOS.csproj index f93cef6..fc85f28 100644 --- a/Pixiview.iOS/Pixiview.iOS.csproj +++ b/Pixiview.iOS/Pixiview.iOS.csproj @@ -139,17 +139,16 @@ + + + - - {7F310047-BCBB-45F5-BD16-F246BA72AF73} - Pixiview - true {618D8350-495C-42D0-9DAC-87ADD36AC727} diff --git a/Pixiview.sln b/Pixiview.sln index 4ff29a3..255fd45 100644 --- a/Pixiview.sln +++ b/Pixiview.sln @@ -3,12 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pixiview.iOS", "Pixiview.iOS\Pixiview.iOS.csproj", "{0CDD279E-3CAB-4CCA-A7C4-BC499724D051}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pixiview", "Pixiview\Pixiview.csproj", "{7F310047-BCBB-45F5-BD16-F246BA72AF73}" -EndProject -Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "Pixiview.Android", "Pixiview.Android\Pixiview.Android.csproj", "{EEE719E5-36B4-4024-84F5-F71DF07B3308}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pixiview", "Pixiview\Pixiview.shproj", "{57C27E64-049B-4EE8-9308-BCAFE329E8E8}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pixiview.iOS.OpenExtension", "Pixiview.iOS.OpenExtension\Pixiview.iOS.OpenExtension.csproj", "{618D8350-495C-42D0-9DAC-87ADD36AC727}" EndProject +Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "Pixiview.Android", "Pixiview.Android\Pixiview.Android.csproj", "{FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -31,30 +31,6 @@ Global {0CDD279E-3CAB-4CCA-A7C4-BC499724D051}.Debug|iPhone.Build.0 = Debug|iPhone {0CDD279E-3CAB-4CCA-A7C4-BC499724D051}.Release|iPhone.ActiveCfg = Release|iPhone {0CDD279E-3CAB-4CCA-A7C4-BC499724D051}.Release|iPhone.Build.0 = Release|iPhone - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Release|Any CPU.Build.0 = Release|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Debug|iPhone.Build.0 = Debug|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Release|iPhone.ActiveCfg = Release|Any CPU - {7F310047-BCBB-45F5-BD16-F246BA72AF73}.Release|iPhone.Build.0 = Release|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Release|Any CPU.Build.0 = Release|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Debug|iPhone.Build.0 = Debug|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Release|iPhone.ActiveCfg = Release|Any CPU - {EEE719E5-36B4-4024-84F5-F71DF07B3308}.Release|iPhone.Build.0 = Release|Any CPU {618D8350-495C-42D0-9DAC-87ADD36AC727}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator {618D8350-495C-42D0-9DAC-87ADD36AC727}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator {618D8350-495C-42D0-9DAC-87ADD36AC727}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator @@ -67,5 +43,17 @@ Global {618D8350-495C-42D0-9DAC-87ADD36AC727}.Debug|iPhone.Build.0 = Debug|iPhone {618D8350-495C-42D0-9DAC-87ADD36AC727}.Release|iPhone.ActiveCfg = Release|iPhone {618D8350-495C-42D0-9DAC-87ADD36AC727}.Release|iPhone.Build.0 = Release|iPhone + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Release|Any CPU.Build.0 = Release|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Debug|iPhone.Build.0 = Debug|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Release|iPhone.ActiveCfg = Release|Any CPU + {FBB80F2B-0C2B-4BE5-A578-853AA0AF9F4A}.Release|iPhone.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Pixiview/GlobalSuppressions.cs b/Pixiview/GlobalSuppressions.cs deleted file mode 100644 index f5c46f7..0000000 --- a/Pixiview/GlobalSuppressions.cs +++ /dev/null @@ -1,9 +0,0 @@ -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. - -using System.Diagnostics.CodeAnalysis; - -[assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "")] -[assembly: SuppressMessage("Style", "IDE0066:Convert switch statement to expression", Justification = "")] diff --git a/Pixiview/Pixiview.csproj b/Pixiview/Pixiview.csproj deleted file mode 100644 index bc395f3..0000000 --- a/Pixiview/Pixiview.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - netstandard2.0 - true - - - - portable - true - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Pixiview/Pixiview.projitems b/Pixiview/Pixiview.projitems new file mode 100644 index 0000000..4e66d52 --- /dev/null +++ b/Pixiview/Pixiview.projitems @@ -0,0 +1,102 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {57C27E64-049B-4EE8-9308-BCAFE329E8E8} + + + Pixiview + + + + Designer + MSBuild:UpdateDesignTimeXaml + + + Designer + MSBuild:UpdateDesignTimeXaml + + + Designer + MSBuild:UpdateDesignTimeXaml + + + Designer + MSBuild:UpdateDesignTimeXaml + + + Designer + MSBuild:UpdateDesignTimeXaml + + + Designer + MSBuild:UpdateDesignTimeXaml + + + Designer + MSBuild:UpdateDesignTimeXaml + + + Designer + MSBuild:UpdateDesignTimeXaml + + + + + + + AppShell.xaml + + + + OptionPage.xaml + + + FavoritesPage.xaml + + + + MainPage.xaml + + + RankingPage.xaml + + + RecommendsPage.xaml + + + UserIllustPage.xaml + + + ViewIllustPage.xaml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Pixiview/Pixiview.shproj b/Pixiview/Pixiview.shproj new file mode 100644 index 0000000..d09214b --- /dev/null +++ b/Pixiview/Pixiview.shproj @@ -0,0 +1,11 @@ + + + + {57C27E64-049B-4EE8-9308-BCAFE329E8E8} + + + + + + + \ No newline at end of file diff --git a/Pixiview/Resources/ResourceHelper.cs b/Pixiview/Resources/ResourceHelper.cs index c7f4f19..a9dc36f 100644 --- a/Pixiview/Resources/ResourceHelper.cs +++ b/Pixiview/Resources/ResourceHelper.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Xml.Linq; +using System.Xml; using Xamarin.Forms; using Xamarin.Forms.Xaml; @@ -65,29 +65,41 @@ namespace Pixiview.Resources { try { +#if __IOS__ + var langId = $"Pixiview.iOS.Resources.Languages.{lang.Language}.xml"; + var langCodeId = $"Pixiview.iOS.Resources.Languages.{lang.LanguageCode}.xml"; +#else + var langId = $"Pixiview.Android.Resources.Languages.{lang.Language}.xml"; + var langCodeId = $"Pixiview.Android.Resources.Languages.{lang.LanguageCode}.xml"; +#endif var assembly = IntrospectionExtensions.GetTypeInfo(typeof(LanguageResource)).Assembly; var names = assembly.GetManifestResourceNames(); var name = names.FirstOrDefault(n - => string.Equals(n, $"Pixiview.Resources.Languages.{lang.Language}.xml", StringComparison.OrdinalIgnoreCase) - || string.Equals(n, $"Pixiview.Resources.Languages.{lang.LanguageCode}.xml", StringComparison.OrdinalIgnoreCase)); + => string.Equals(n, langId, StringComparison.OrdinalIgnoreCase) + || string.Equals(n, langCodeId, StringComparison.OrdinalIgnoreCase)); if (name == null) { - name = "Pixiview.Resources.Languages.zh-CN.xml"; +#if __IOS__ + name = "Pixiview.iOS.Resources.Languages.zh-CN.xml"; +#else + name = "Pixiview.Android.Resources.Languages.zh-CN.xml"; +#endif } - XDocument xml; + var xml = new XmlDocument(); using (var stream = assembly.GetManifestResourceStream(name)) { - xml = XDocument.Load(stream); + xml.Load(stream); } strings = new Dictionary(); - foreach (var ele in xml.Root.Elements()) + foreach (XmlElement ele in xml.DocumentElement) // .Root.Elements() { - strings[ele.Name.LocalName] = ele.Value; + strings[ele.Name] = ele.InnerText; // .LocalName Value } } - catch + catch (Exception ex) { // load failed + App.DebugError("language.ctor", $"failed to load xml resource: {ex.Message}"); } } } diff --git a/Pixiview/UI/SegmentedControl.cs b/Pixiview/UI/SegmentedControl.cs index c472618..bedab81 100644 --- a/Pixiview/UI/SegmentedControl.cs +++ b/Pixiview/UI/SegmentedControl.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using Xamarin.Forms; namespace Pixiview.UI @@ -48,7 +47,7 @@ namespace Pixiview.UI public event EventHandler ValueChanged; - [EditorBrowsable(EditorBrowsableState.Never)] + //[EditorBrowsable(EditorBrowsableState.Never)] public void SendValueChanged() { ValueChanged?.Invoke(this, new ValueChangedEventArgs { NewValue = SelectedSegmentIndex }); diff --git a/Pixiview/UI/StyleDefinition.cs b/Pixiview/UI/StyleDefinition.cs index 07c9644..53d8632 100644 --- a/Pixiview/UI/StyleDefinition.cs +++ b/Pixiview/UI/StyleDefinition.cs @@ -57,57 +57,54 @@ namespace Pixiview.UI { return _isFullscreenDevice.Value; } - if (Device.RuntimePlatform == Device.iOS) +#if __IOS__ + try { - try + var model = DeviceInfo.Model; + if (model == "iPhone10,3") { - var model = DeviceInfo.Model; - if (model == "iPhone10,3") + // iPhone X + _isFullscreenDevice = true; + } + else if (model.StartsWith("iPhone")) + { + var vs = model.Substring(6).Split(','); + if (vs.Length == 2 && int.TryParse(vs[0], out int main) && int.TryParse(vs[1], out int sub)) { - // iPhone X - _isFullscreenDevice = true; + // iPhone X/XS/XR or iPhone 11 + _isFullscreenDevice = (main == 10 && sub >= 6) || (main > 10); } - else if (model.StartsWith("iPhone")) - { - var vs = model.Substring(6).Split(','); - if (vs.Length == 2 && int.TryParse(vs[0], out int main) && int.TryParse(vs[1], out int sub)) - { - // iPhone X/XS/XR or iPhone 11 - _isFullscreenDevice = (main == 10 && sub >= 6) || (main > 10); - } - else - { - _isFullscreenDevice = false; - } - } - else if (model.StartsWith("iPad8,")) - { - // iPad 11-inch or 12.9-inch (3rd+) - _isFullscreenDevice = true; - } -#if DEBUG else { - // iPad or Simulator - var name = DeviceInfo.Name; - _isFullscreenDevice = name.StartsWith("iPhone X") - || name.StartsWith("iPhone 11") - || name.StartsWith("iPad Pro (11-inch)") - || name.StartsWith("iPad Pro (12.9-inch) (3rd generation)") - || name.StartsWith("iPad Pro (12.9-inch) (4th generation)"); + _isFullscreenDevice = false; } -#endif } - catch (Exception ex) + else if (model.StartsWith("iPad8,")) { - App.DebugError("device.get", $"failed to get the device model. {ex.Message}"); + // iPad 11-inch or 12.9-inch (3rd+) + _isFullscreenDevice = true; } +#if DEBUG + else + { + // iPad or Simulator + var name = DeviceInfo.Name; + _isFullscreenDevice = name.StartsWith("iPhone X") + || name.StartsWith("iPhone 11") + || name.StartsWith("iPad Pro (11-inch)") + || name.StartsWith("iPad Pro (12.9-inch) (3rd generation)") + || name.StartsWith("iPad Pro (12.9-inch) (4th generation)"); + } +#endif } - else + catch (Exception ex) { - // TODO: - _isFullscreenDevice = false; + App.DebugError("device.get", $"failed to get the device model. {ex.Message}"); } +#else + // TODO: + _isFullscreenDevice = false; +#endif if (_isFullscreenDevice == null) { _isFullscreenDevice = false; diff --git a/Pixiview/Utils/Stores.cs b/Pixiview/Utils/Stores.cs index f6de5b2..c22b8e0 100644 --- a/Pixiview/Utils/Stores.cs +++ b/Pixiview/Utils/Stores.cs @@ -36,7 +36,7 @@ namespace Pixiview.Utils { try { - return Connectivity.NetworkAccess == NetworkAccess.Internet; + return Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.Internet; } catch {