From 82527789c867965a68da0c2452b67a24fdd1434c Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Sun, 24 May 2020 17:08:15 +0800 Subject: [PATCH] fix: dev region to China feature: add version display in option page --- .../Properties/AndroidManifest.xml | 2 +- Pixiview.iOS.OpenExtension/Info.plist | 4 +-- Pixiview.iOS/Info.plist | 4 ++- Pixiview/OptionPage.xaml | 3 +++ Pixiview/OptionPage.xaml.cs | 26 +++++++++++++++++++ Pixiview/Resources/Languages/zh-CN.xml | 2 ++ Pixiview/UI/OptionCell.cs | 23 +++++++++++++++- 7 files changed, 59 insertions(+), 5 deletions(-) diff --git a/Pixiview.Android/Properties/AndroidManifest.xml b/Pixiview.Android/Properties/AndroidManifest.xml index 6e743fa..2390d4e 100644 --- a/Pixiview.Android/Properties/AndroidManifest.xml +++ b/Pixiview.Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/Pixiview.iOS.OpenExtension/Info.plist b/Pixiview.iOS.OpenExtension/Info.plist index 75cf818..ffb57f4 100644 --- a/Pixiview.iOS.OpenExtension/Info.plist +++ b/Pixiview.iOS.OpenExtension/Info.plist @@ -9,7 +9,7 @@ CFBundleIdentifier org.tsanie.Pixiview.OpenExtension CFBundleDevelopmentRegion - en + China CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType @@ -31,6 +31,6 @@ CFBundleShortVersionString 1.0.524 CFBundleVersion - 13 + 15 diff --git a/Pixiview.iOS/Info.plist b/Pixiview.iOS/Info.plist index 424ad73..d9a0ab7 100644 --- a/Pixiview.iOS/Info.plist +++ b/Pixiview.iOS/Info.plist @@ -81,6 +81,8 @@ CFBundleShortVersionString 1.0.524 CFBundleVersion - 13 + 15 + CFBundleDevelopmentRegion + China diff --git a/Pixiview/OptionPage.xaml b/Pixiview/OptionPage.xaml index 26ddf88..36c3c8b 100644 --- a/Pixiview/OptionPage.xaml +++ b/Pixiview/OptionPage.xaml @@ -12,6 +12,9 @@ + + + diff --git a/Pixiview/OptionPage.xaml.cs b/Pixiview/OptionPage.xaml.cs index cdac905..7722b0c 100644 --- a/Pixiview/OptionPage.xaml.cs +++ b/Pixiview/OptionPage.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Pixiview.Resources; using Pixiview.UI; using Pixiview.Utils; @@ -9,6 +10,15 @@ namespace Pixiview { public partial class OptionPage : AdaptedPage { + public static readonly BindableProperty VersionProperty = BindableProperty.Create( + nameof(Version), typeof(string), typeof(OptionPage)); + + public string Version + { + get => (string)GetValue(VersionProperty); + set => SetValue(VersionProperty, value); + } + public static readonly BindableProperty IsOnR18Property = BindableProperty.Create( nameof(IsOnR18), typeof(bool), typeof(OptionPage)); public static readonly BindableProperty SyncFavTypeProperty = BindableProperty.Create( @@ -65,12 +75,27 @@ namespace Pixiview ResourceHelper.SyncAuto, }; SyncFavType = 0; +#if OBSOLETE +#if __IOS__ + string version = Foundation.NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleShortVersionString").ToString(); + int build = int.Parse(Foundation.NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString()); +#elif __ANDROID__ + var context = Android.App.Application.Context; + var manager = context.PackageManager; + var info = manager.GetPackageInfo(context.PackageName, 0); + + string version = info.VersionName; + long build = info.LongVersionCode; +#endif + Version = $"{version} ({build})"; +#endif } protected override void OnAppearing() { base.OnAppearing(); + Version = $"{AppInfo.VersionString} ({AppInfo.BuildString})"; IsOnR18 = Configs.IsOnR18; SyncFavType = (int)Configs.SyncFavType; var proxy = Configs.Proxy; @@ -173,6 +198,7 @@ namespace Pixiview #if LOG App.DebugPrint($"cookie changed, user id: {session}"); #endif + Task.Run(() => AppShell.Current.DoLoginInformation(true)); } } } diff --git a/Pixiview/Resources/Languages/zh-CN.xml b/Pixiview/Resources/Languages/zh-CN.xml index ca3863a..5b78952 100644 --- a/Pixiview/Resources/Languages/zh-CN.xml +++ b/Pixiview/Resources/Languages/zh-CN.xml @@ -7,6 +7,8 @@ 登录 + 关于 + 版本 插画 代理 详细 diff --git a/Pixiview/UI/OptionCell.cs b/Pixiview/UI/OptionCell.cs index 6691d54..93be88e 100644 --- a/Pixiview/UI/OptionCell.cs +++ b/Pixiview/UI/OptionCell.cs @@ -49,6 +49,26 @@ namespace Pixiview.UI } } + public class OptionTextCell : OptionCell + { + public static readonly BindableProperty DetailProperty = BindableProperty.Create( + nameof(Detail), typeof(string), typeof(OptionCell)); + + public string Detail + { + get => (string)GetValue(DetailProperty); + set => SetValue(DetailProperty, value); + } + + protected override View Content => new Label + { + HorizontalOptions = LayoutOptions.End, + VerticalOptions = LayoutOptions.Center + } + .Binding(Label.TextProperty, nameof(Detail)) + .DynamicResource(Label.TextColorProperty, ThemeBase.SubTextColor); + } + public class OptionSwitchCell : OptionCell { public static readonly BindableProperty IsToggledProperty = BindableProperty.Create( @@ -64,7 +84,8 @@ namespace Pixiview.UI { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center - }.Binding(Switch.IsToggledProperty, nameof(IsToggled), BindingMode.TwoWay); + } + .Binding(Switch.IsToggledProperty, nameof(IsToggled), BindingMode.TwoWay); } public class OptionDropCell : OptionCell