From 865e317d4e6ff74ebfd76274d5ecb17c2c7334c2 Mon Sep 17 00:00:00 2001 From: Aigio Liu Date: Tue, 17 Aug 2021 16:04:56 +0800 Subject: [PATCH] Update Nuget Packages & Remove ZXing.Net.Mobile Add MLKit + Camera2 --- README.en.md | 2 +- README.md | 3 +- release-template.md | 12 +- .../Implementation/PlatformToastImpl.cs | 2 +- src/Common.ClientLib/Common.ClientLib.csproj | 2 +- .../ST.Client.Desktop.csproj | 2 +- .../AddAuthWindowViewModel.shared.cs | 3 +- .../ST.Client.Mobile.Droid.App.csproj | 2 +- .../Extensions/ZXingExtensions.cs | 113 +++++++++--------- .../ST.Client.Mobile.Droid.csproj | 32 ++--- .../LocalAuthPage/AddAuthActivity.cs | 2 +- ...thSteamToolsImportFragment.MLKitCameraX.cs | 12 ++ ...uthSteamToolsImportFragment.ZXingMobile.cs | 29 +++++ .../LocalAuthSteamToolsImportFragment.cs | 16 +-- src/ST.Client.Mobile/ST.Client.Mobile.csproj | 2 +- src/ST.Server.Resources/UI/Resx/R.cs | 11 ++ ...ST.Services.CloudService.ViewModels.csproj | 2 +- 17 files changed, 151 insertions(+), 96 deletions(-) create mode 100644 src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.MLKitCameraX.cs create mode 100644 src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.ZXingMobile.cs create mode 100644 src/ST.Server.Resources/UI/Resx/R.cs diff --git a/README.en.md b/README.en.md index efecf9d7317..4bb13f3b3a7 100644 --- a/README.en.md +++ b/README.en.md @@ -161,7 +161,6 @@ Read what we [milestones](https://github.com/SteamTools-Team/SteamTools/mileston * [AspNet.Security.OpenId.Providers](https://github.com/aspnet-contrib/AspNet.Security.OpenId.Providers) * [AspNet.Security.OAuth.Providers](https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers) * [ZXing.Net](https://github.com/micjahn/ZXing.Net) -* [ZXing.Net.Mobile](https://github.com/Redth/ZXing.Net.Mobile) * [QRCoder](https://github.com/codebude/QRCoder) * [React](https://github.com/facebook/react) * [Ant Design](https://github.com/ant-design/ant-design) @@ -173,6 +172,7 @@ Read what we [milestones](https://github.com/SteamTools-Team/SteamTools/mileston * [MSBuild.Sdk.Extras](https://github.com/novotnyllc/MSBuildSdkExtras) * [Xamarin.Essentials](https://github.com/xamarin/essentials) * [Open Source Components for Xamarin](https://github.com/xamarin/XamarinComponents) +* [Google Play Services / Firebase / ML Kit for Xamarin.Android](https://github.com/xamarin/GooglePlayServicesComponents) * [Picasso](https://github.com/square/picasso) * [OkHttp](https://github.com/square/okhttp) * [Material Components for Android](https://github.com/material-components/material-components-android) diff --git a/README.md b/README.md index bde408d3fa2..e71fd8be2e8 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ * [Chromium Embedded Framework (CEF)](https://github.com/chromiumembedded/cef) * [CefNet](https://github.com/CefNet/CefNet) * [CefSharp](https://github.com/cefsharp/CefSharp) +* [ZXing.Net.Mobile](https://github.com/Redth/ZXing.Net.Mobile) --> ## 📄 感谢以下开源项目 @@ -179,7 +180,6 @@ * [AspNet.Security.OpenId.Providers](https://github.com/aspnet-contrib/AspNet.Security.OpenId.Providers) * [AspNet.Security.OAuth.Providers](https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers) * [ZXing.Net](https://github.com/micjahn/ZXing.Net) -* [ZXing.Net.Mobile](https://github.com/Redth/ZXing.Net.Mobile) * [QRCoder](https://github.com/codebude/QRCoder) * [React](https://github.com/facebook/react) * [Ant Design](https://github.com/ant-design/ant-design) @@ -191,6 +191,7 @@ * [MSBuild.Sdk.Extras](https://github.com/novotnyllc/MSBuildSdkExtras) * [Xamarin.Essentials](https://github.com/xamarin/essentials) * [Open Source Components for Xamarin](https://github.com/xamarin/XamarinComponents) +* [Google Play Services / Firebase / ML Kit for Xamarin.Android](https://github.com/xamarin/GooglePlayServicesComponents) * [Picasso](https://github.com/square/picasso) * [OkHttp](https://github.com/square/okhttp) * [Material Components for Android](https://github.com/material-components/material-components-android) diff --git a/release-template.md b/release-template.md index 1a46e76f564..4ec028ca948 100644 --- a/release-template.md +++ b/release-template.md @@ -40,6 +40,16 @@ 25. 改进 hosts 文件编码在 Windows 上使用系统的活动代码页(ANSICodePage),例如 GB2312/936,其他操作系统则使用 UTF-8,还原 V1 版本行为 26. 改进 开始菜单磁贴背景由黑色更改为透明 27. 修复 账号切换修改账号备注重启后被还原 + +### 已知问题 +- macOS + - 尚未公证,这会影响 macOS Catalina(版本 10.15)以上 + - 自动更新不可用 +- Linux + - 托盘不生效,这将影响程序不能正常退出 + - 窗口弹出位置不正确 + - 自动更新不可用 + *** diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/LocalAuthPage/AddAuthWindowViewModel.shared.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/LocalAuthPage/AddAuthWindowViewModel.shared.cs index 64ff094fd64..532108c6f3d 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Windows/LocalAuthPage/AddAuthWindowViewModel.shared.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/LocalAuthPage/AddAuthWindowViewModel.shared.cs @@ -406,8 +406,9 @@ public void ImportSteamPlusPlusV2(byte[] bytes) AuthService.Current.ImportWinAuthenticators(urls, AuthIsLocal, AuthPassword); } } - catch + catch (Exception e) { + Log.Error(nameof(ImportSteamPlusPlusV2), e, string.Empty); Toast.Show(string.Format(AppResources.LocalAuth_ExportAuth_Error, ImportResultCode.IncorrectFormat)); } } diff --git a/src/ST.Client.Mobile.Droid.App/ST.Client.Mobile.Droid.App.csproj b/src/ST.Client.Mobile.Droid.App/ST.Client.Mobile.Droid.App.csproj index 9ebaebc95f4..a58185b5681 100644 --- a/src/ST.Client.Mobile.Droid.App/ST.Client.Mobile.Droid.App.csproj +++ b/src/ST.Client.Mobile.Droid.App/ST.Client.Mobile.Droid.App.csproj @@ -36,7 +36,7 @@ prompt 4 None - x86_64 + x86_64;arm64-v8a true false false diff --git a/src/ST.Client.Mobile.Droid/Extensions/ZXingExtensions.cs b/src/ST.Client.Mobile.Droid/Extensions/ZXingExtensions.cs index 176f599d4c2..9025927474e 100644 --- a/src/ST.Client.Mobile.Droid/Extensions/ZXingExtensions.cs +++ b/src/ST.Client.Mobile.Droid/Extensions/ZXingExtensions.cs @@ -1,57 +1,56 @@ -using System.Collections.Generic; -using System.Linq; -using Xamarin.Essentials; -using ZXing; -using ZXing.Mobile; -using ZXingResult = ZXing.Result; - -// ReSharper disable once CheckNamespace -namespace System -{ - public static class ZXingExtensions - { - // https://github.com/Redth/ZXing.Net.Mobile/blob/master/Samples/Sample.Android/MainActivity.cs - - public static async void StartScan(this MobileBarcodeScanner? scanner, Action handleScanResult) - { - if (scanner == null) return; - - // Tell our scanner to use the default overlay - scanner.UseCustomOverlay = false; - - // We can customize the top and bottom text of the default overlay - scanner.TopText = "Hold the camera up to the barcode\nAbout 6 inches away"; - scanner.BottomText = "Wait for the barcode to automatically scan!"; - - //Start scanning - var result = await scanner.Scan(new() - { - // https://github.com/Redth/ZXing.Net.Mobile/issues/808#issuecomment-835089415 - PossibleFormats = new List() { BarcodeFormat.QR_CODE }, - CameraResolutionSelector = new((List availableResolutions) => - { - CameraResolution? result = null; - - double aspectTolerance = 0.1; - var displayOrientationHeight = DeviceDisplay.MainDisplayInfo.Orientation == DisplayOrientation.Portrait ? DeviceDisplay.MainDisplayInfo.Height : DeviceDisplay.MainDisplayInfo.Width; - var displayOrientationWidth = DeviceDisplay.MainDisplayInfo.Orientation == DisplayOrientation.Portrait ? DeviceDisplay.MainDisplayInfo.Width : DeviceDisplay.MainDisplayInfo.Height; - - var targetRatio = displayOrientationHeight / displayOrientationWidth; - var targetHeight = displayOrientationHeight; - var minDiff = double.MaxValue; - - foreach (var r in availableResolutions.Where(r => Math.Abs(((double)r.Width / r.Height) - targetRatio) < aspectTolerance)) - { - if (Math.Abs(r.Height - targetHeight) < minDiff) - minDiff = Math.Abs(r.Height - targetHeight); - result = r; - } - return result; - }) - }); - if (result == null) return; - - handleScanResult(result); - } - } -} \ No newline at end of file +//using System.Collections.Generic; +//using System.Linq; +//using System.Threading.Tasks; +//using Xamarin.Essentials; +//using ZXing; +//using ZXing.Mobile; +//using ZXingResult = ZXing.Result; + +//// ReSharper disable once CheckNamespace +//namespace System +//{ +// public static class ZXingExtensions +// { +// // https://github.com/Redth/ZXing.Net.Mobile/blob/master/Samples/Sample.Android/MainActivity.cs + +// public static async Task StartScanAsync(this MobileBarcodeScanner? scanner, string? topText = null, string? bottomText = null) +// { +// if (scanner == null) return null; + +// // Tell our scanner to use the default overlay +// scanner.UseCustomOverlay = false; + +// // We can customize the top and bottom text of the default overlay +// scanner.TopText = topText ?? "Hold the camera up to the barcode\nAbout 6 inches away"; +// scanner.BottomText = bottomText ?? "Wait for the barcode to automatically scan!"; + +// //Start scanning +// var result = await scanner.Scan(new() +// { +// // https://github.com/Redth/ZXing.Net.Mobile/issues/808#issuecomment-835089415 +// PossibleFormats = new List() { BarcodeFormat.QR_CODE }, +// CameraResolutionSelector = new((List availableResolutions) => +// { +// CameraResolution? result = null; + +// double aspectTolerance = 0.1; +// var displayOrientationHeight = DeviceDisplay.MainDisplayInfo.Orientation == DisplayOrientation.Portrait ? DeviceDisplay.MainDisplayInfo.Height : DeviceDisplay.MainDisplayInfo.Width; +// var displayOrientationWidth = DeviceDisplay.MainDisplayInfo.Orientation == DisplayOrientation.Portrait ? DeviceDisplay.MainDisplayInfo.Width : DeviceDisplay.MainDisplayInfo.Height; + +// var targetRatio = displayOrientationHeight / displayOrientationWidth; +// var targetHeight = displayOrientationHeight; +// var minDiff = double.MaxValue; + +// foreach (var r in availableResolutions.Where(r => Math.Abs(((double)r.Width / r.Height) - targetRatio) < aspectTolerance)) +// { +// if (Math.Abs(r.Height - targetHeight) < minDiff) +// minDiff = Math.Abs(r.Height - targetHeight); +// result = r; +// } +// return result; +// }) +// }); +// return result; +// } +// } +//} \ No newline at end of file diff --git a/src/ST.Client.Mobile.Droid/ST.Client.Mobile.Droid.csproj b/src/ST.Client.Mobile.Droid/ST.Client.Mobile.Droid.csproj index 885e212c9a8..6f5c896f10c 100644 --- a/src/ST.Client.Mobile.Droid/ST.Client.Mobile.Droid.csproj +++ b/src/ST.Client.Mobile.Droid/ST.Client.Mobile.Droid.csproj @@ -132,32 +132,34 @@ + + + + + + + + + + - + - - + - + - - - - - - - - - - - + + + + diff --git a/src/ST.Client.Mobile.Droid/UI/Activities/LocalAuthPage/AddAuthActivity.cs b/src/ST.Client.Mobile.Droid/UI/Activities/LocalAuthPage/AddAuthActivity.cs index e39b560cdf9..16d88c78a2f 100644 --- a/src/ST.Client.Mobile.Droid/UI/Activities/LocalAuthPage/AddAuthActivity.cs +++ b/src/ST.Client.Mobile.Droid/UI/Activities/LocalAuthPage/AddAuthActivity.cs @@ -44,7 +44,7 @@ protected override void OnCreate(Bundle? savedInstanceState) { 2 => new LocalAuthSteamUserImportFragment(), 1 => new LocalAuthSteamAppImportFragment(), - 0 => new LocalAuthSteamToolsImportFragment(), + 0 => new LocalAuthSteamToolsImportFragment.MLKitCameraX(), 3 => new LocalAuthOtherImportFragment(), _ => throw new ArgumentOutOfRangeException(nameof(position), position.ToString()), }; diff --git a/src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.MLKitCameraX.cs b/src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.MLKitCameraX.cs new file mode 100644 index 00000000000..b7613705a58 --- /dev/null +++ b/src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.MLKitCameraX.cs @@ -0,0 +1,12 @@ +namespace System.Application.UI.Fragments +{ + partial class LocalAuthSteamToolsImportFragment + { + internal sealed class MLKitCameraX : LocalAuthSteamToolsImportFragment + { + protected override void OnBtnImportV2ByQRCodeClick() + { + } + } + } +} \ No newline at end of file diff --git a/src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.ZXingMobile.cs b/src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.ZXingMobile.cs new file mode 100644 index 00000000000..f05e610579c --- /dev/null +++ b/src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.ZXingMobile.cs @@ -0,0 +1,29 @@ +//using Android.Views; +//using ZXing.Mobile; + +//namespace System.Application.UI.Fragments +//{ +// partial class LocalAuthSteamToolsImportFragment +// { +// internal sealed class ZXing : LocalAuthSteamToolsImportFragment +// { +// MobileBarcodeScanner? scanner; + +// public override void OnCreateView(View view) +// { +// base.OnCreateView(view); + +// //Create a new instance of our Scanner +// scanner = new(); +// } + +// protected override async void OnBtnImportV2ByQRCodeClick() +// { +// var result = await scanner.StartScanAsync(); +// if (result == null) return; +// if (!result.RawBytes.Any_Nullable()) return; +// ViewModel!.ImportSteamPlusPlusV2(result.RawBytes!); +// } +// } +// } +//} \ No newline at end of file diff --git a/src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.cs b/src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.cs index 4ea7e6b9817..f79cd18b5e8 100644 --- a/src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.cs +++ b/src/ST.Client.Mobile.Droid/UI/Fragments/LocalAuthPage/LocalAuthSteamToolsImportFragment.cs @@ -3,17 +3,14 @@ using ReactiveUI; using System.Application.UI.Resx; using System.Application.UI.ViewModels; -using ZXing.Mobile; using static System.Application.UI.Resx.AppResources; namespace System.Application.UI.Fragments { - internal sealed class LocalAuthSteamToolsImportFragment : BaseFragment + internal abstract partial class LocalAuthSteamToolsImportFragment : BaseFragment { protected override int? LayoutResource => Resource.Layout.fragment_local_auth_import_steam_plus_plus; - MobileBarcodeScanner? scanner; - public override void OnCreateView(View view) { base.OnCreateView(view); @@ -29,11 +26,10 @@ public override void OnCreateView(View view) }).AddTo(this); SetOnClickListener(binding!.btnImportV1, binding.btnImportV2, binding.btnImportV2ByQRCode); - - //Create a new instance of our Scanner - scanner = new(); } + protected abstract void OnBtnImportV2ByQRCodeClick(); + protected override bool OnClick(View view) { if (view.Id == Resource.Id.btnImportV1) @@ -48,11 +44,7 @@ protected override bool OnClick(View view) } else if (view.Id == Resource.Id.btnImportV2ByQRCode) { - scanner.StartScan(x => - { - if (!x.RawBytes.Any_Nullable()) return; - ViewModel!.ImportSteamPlusPlusV2(x.RawBytes!); - }); + OnBtnImportV2ByQRCodeClick(); return true; } return base.OnClick(view); diff --git a/src/ST.Client.Mobile/ST.Client.Mobile.csproj b/src/ST.Client.Mobile/ST.Client.Mobile.csproj index d3ce24f9a63..45e04b2e697 100644 --- a/src/ST.Client.Mobile/ST.Client.Mobile.csproj +++ b/src/ST.Client.Mobile/ST.Client.Mobile.csproj @@ -135,7 +135,7 @@ - + diff --git a/src/ST.Server.Resources/UI/Resx/R.cs b/src/ST.Server.Resources/UI/Resx/R.cs new file mode 100644 index 00000000000..5a4beab23e4 --- /dev/null +++ b/src/ST.Server.Resources/UI/Resx/R.cs @@ -0,0 +1,11 @@ +namespace System.Application.UI.Resx +{ + public static partial class R + { + public const string Url_MicrosoftEdge = "https://www.microsoft.com/edge"; + + public const string Url_Chrome = "https://www.google.cn/chrome/browser/desktop"; + + public const string Url_Firefox = "https://www.mozilla.org/firefox/browsers"; + } +} \ No newline at end of file diff --git a/src/ST.Services.CloudService.ViewModels/ST.Services.CloudService.ViewModels.csproj b/src/ST.Services.CloudService.ViewModels/ST.Services.CloudService.ViewModels.csproj index 735aed9f518..ffdec67b4aa 100644 --- a/src/ST.Services.CloudService.ViewModels/ST.Services.CloudService.ViewModels.csproj +++ b/src/ST.Services.CloudService.ViewModels/ST.Services.CloudService.ViewModels.csproj @@ -39,7 +39,7 @@ - +