Skip to content

Commit

Permalink
Update Nuget Packages & Remove ZXing.Net.Mobile Add MLKit + Camera2
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Aug 17, 2021
1 parent da11f59 commit 865e317
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 96 deletions.
2 changes: 1 addition & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-->
<!--👇图标如果发生更改,还需更改 Tools.OpenSourceLibraryList(Program.OpenSourceLibraryListEmoji) -->
## 📄 感谢以下开源项目
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions release-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
25. 改进 hosts 文件编码在 Windows 上使用系统的活动代码页(ANSICodePage),例如 GB2312/936,其他操作系统则使用 UTF-8,还原 V1 版本行为
26. 改进 开始菜单磁贴背景由黑色更改为透明
27. 修复 账号切换修改账号备注重启后被还原

### 已知问题
- macOS
- 尚未公证,这会影响 macOS Catalina(版本 10.15)以上
- 自动更新不可用
- Linux
- 托盘不生效,这将影响程序不能正常退出
- 窗口弹出位置不正确
- 自动更新不可用

***

<!-- 1. 新增 ASF Plus 本地挂卡
Expand All @@ -62,11 +72,9 @@
| ---- | ---- |
| Steam++_win_x64_v2.4.9.7z | SHA256 |
| Steam++_win_x64_v2.4.9.exe | SHA256 |
| Steam++_win_x64_v2.4.9.msix | SHA256 |
| | |
| Steam++_win_arm64_v2.4.9.7z | SHA256 |
| Steam++_win_arm64_v2.4.9.exe | SHA256 |
| Steam++_win_arm64_v2.4.9.msix | SHA256 |
| | |
| Steam++_linux_x64_v2.4.9.7z | SHA256 |
| Steam++_linux_x64_v2.4.9.deb | SHA256 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override void PlatformShow(string text, int duration)
}
catch (JException e)
{
Log.Error(TAG, e, "ShowDroidToast Error, text: {0}", text);
Log.Error(TAG, e, "ShowDroidToast Error, text: {0}, IsMainThread: {1}", text, IsMainThread);
// 解决在子线程中调用Toast的异常情况处理
Looper.Prepare();
var _toast = AndroidToast.MakeText(context, text, duration2)
Expand Down
2 changes: 1 addition & 1 deletion src/Common.ClientLib/Common.ClientLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ReactiveUI" Version="14.1.1" />
<PackageReference Include="ReactiveUI" Version="14.3.10" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ST.Client.Desktop/ST.Client.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.3" />
<PackageReference Include="SharpZipLib" Version="1.3.2" />
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.4.0.345" />
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.5.0.366" />
<PackageReference Include="StatefulModel.Standard" Version="0.1.0" />
<!--<PackageReference Include="Titanium.Web.Proxy" Version="3.1.1344" />-->
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
<AndroidSupportedAbis>x86_64</AndroidSupportedAbis>
<AndroidSupportedAbis>x86_64;arm64-v8a</AndroidSupportedAbis>
<AndroidUseAapt2>true</AndroidUseAapt2>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
Expand Down
113 changes: 56 additions & 57 deletions src/ST.Client.Mobile.Droid/Extensions/ZXingExtensions.cs
Original file line number Diff line number Diff line change
@@ -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<ZXingResult> 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>() { BarcodeFormat.QR_CODE },
CameraResolutionSelector = new((List<CameraResolution> 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);
}
}
}
//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<ZXingResult?> 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>() { BarcodeFormat.QR_CODE },
// CameraResolutionSelector = new((List<CameraResolution> 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;
// }
// }
//}
32 changes: 17 additions & 15 deletions src/ST.Client.Mobile.Droid/ST.Client.Mobile.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,32 +132,34 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="de.hdodenhof.circleimageview" Version="3.1.0" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.SwipeRefreshLayout" Version="1.1.0.3" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.4.0.2" />
<PackageReference Include="Xamarin.AndroidX.ConstraintLayout" Version="2.1.0" />
<PackageReference Include="Xamarin.AndroidX.Navigation.Fragment" Version="2.3.5.1" />
<PackageReference Include="Xamarin.AndroidX.Navigation.UI" Version="2.3.5.1" />
<PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.2.1.1" />
<PackageReference Include="Xamarin.AndroidX.ViewPager2" Version="1.0.0.10" />
<!--dependencies implementation-->
<PackageReference Include="Microsoft.AppCenter" Version="4.3.0" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.3.0" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.3.0" />
<PackageReference Include="ReactiveUI.AndroidX" Version="14.1.1" />
<PackageReference Include="ReactiveUI.AndroidX" Version="14.3.10" />
<PackageReference Include="Square.OkHttp3" Version="4.9.1" />
<PackageReference Include="Square.Picasso" Version="2.71828.0" />
<PackageReference Include="TencentOpenApiSDK.Android" Version="3.5.4.11" />
<!--<PackageReference Include="XAB.FloatingActionButtonSpeedDial" Version="3.2.0" />-->
<PackageReference Include="Xamarin.AndroidX.Activity" Version="1.2.4.1" />
<PackageReference Include="Xamarin.AndroidX.Activity" Version="1.3.1" />
<PackageReference Include="Xamarin.AndroidX.Biometric" Version="1.1.0.4" />
<PackageReference Include="Xamarin.AndroidX.ExifInterface" Version="1.3.2.3" />
<PackageReference Include="Xamarin.AndroidX.ExifInterface" Version="1.3.3" />
<PackageReference Include="Xamarin.AndroidX.Fragment" Version="1.3.6.1" />
<PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.8" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.Core.UI" Version="1.0.0.9" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.3.1.1" />
<!--dependencies implementation-->
<PackageReference Include="de.hdodenhof.circleimageview" Version="3.1.0" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.1.1" />
<PackageReference Include="Xamarin.AndroidX.SwipeRefreshLayout" Version="1.1.0.3" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.4.0.1" />
<PackageReference Include="Xamarin.AndroidX.ConstraintLayout" Version="2.0.4.3" />
<PackageReference Include="Xamarin.AndroidX.Navigation.Fragment" Version="2.3.5.1" />
<PackageReference Include="Xamarin.AndroidX.Navigation.UI" Version="2.3.5.1" />
<PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.2.1.1" />
<PackageReference Include="Xamarin.AndroidX.ViewPager2" Version="1.0.0.10" />
<PackageReference Include="ZXing.Net.Mobile" Version="3.1.0-beta2" />
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.0.1.1" />
<PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.0.0.5-alpha20" />
<PackageReference Include="Xamarin.AndroidX.Camera.Lifecycle" Version="1.0.1.1" />
<PackageReference Include="Xamarin.Google.MLKit.BarcodeScanning" Version="116.1.2" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Debug'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace System.Application.UI.Fragments
{
partial class LocalAuthSteamToolsImportFragment
{
internal sealed class MLKitCameraX : LocalAuthSteamToolsImportFragment
{
protected override void OnBtnImportV2ByQRCodeClick()
{
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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!);
// }
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -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<fragment_local_auth_import_steam_plus_plus, AddAuthWindowViewModel>
internal abstract partial class LocalAuthSteamToolsImportFragment : BaseFragment<fragment_local_auth_import_steam_plus_plus, AddAuthWindowViewModel>
{
protected override int? LayoutResource => Resource.Layout.fragment_local_auth_import_steam_plus_plus;

MobileBarcodeScanner? scanner;

public override void OnCreateView(View view)
{
base.OnCreateView(view);
Expand All @@ -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)
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/ST.Client.Mobile/ST.Client.Mobile.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ReactiveUI" Version="14.1.1" />
<PackageReference Include="ReactiveUI" Version="14.3.10" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.35.1" />
<!--<PackageReference Include="StatefulModel.Standard" Version="0.1.0" />-->
</ItemGroup>
Expand Down
Loading

0 comments on commit 865e317

Please sign in to comment.