Skip to content

Commit

Permalink
fix Android project
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Jul 2, 2022
1 parent 5d848c9 commit f057d41
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 56 deletions.
7 changes: 4 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<ItemGroup Condition=" $(TargetFramework.StartsWith('net6.0')) ">
<!-- Microsoft.Extensions.* & AspNetCore & EntityFrameworkCore(NET60) -->
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<!--<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />-->
<PackageVersion Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
Expand All @@ -20,7 +20,7 @@
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) Or $(TargetFramework.StartsWith('netcoreapp3.1'))">
<!-- Microsoft.Extensions.* & AspNetCore & EntityFrameworkCore(NETCOREAPP31) -->
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="3.1.26" />
<!--<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="3.1.26" />-->
<PackageVersion Include="Microsoft.Extensions.Http" Version="3.1.26" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="3.1.26" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.26" />
Expand Down Expand Up @@ -80,6 +80,7 @@
<!--<PackageVersion Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />-->
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.1" />
<PackageVersion Include="Microsoft.Extensions.Primitives" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<!--<PackageVersion Include="CommunityToolkit.Mvvm" Version="7.1.2" />-->
<PackageVersion Include="System.Text.Encoding.CodePages" Version="6.0.0" />

Expand Down Expand Up @@ -260,7 +261,7 @@
<PackageVersion Include="Xamarin.Google.MLKit.BarcodeScanning" Version="116.1.2.5" />
<PackageVersion Include="Plugin.CurrentActivity" Version="2.1.0.4" />
<PackageVersion Include="de.hdodenhof.circleimageview" Version="3.1.0.4" />
<PackageVersion Include="Square.OkHttp3" Version="4.9.3.1" />
<PackageVersion Include="Square.OkHttp3" Version="4.9.3" />
<PackageVersion Include="Square.Picasso" Version="2.71828.0" />
<!--<PackageVersion Include="LeakCanaryBinding" Version="1.5.1.1" />-->
<!--<PackageVersion Include="TencentOpenApiSDK.Android" Version="3.5.4.11" />-->
Expand Down
2 changes: 1 addition & 1 deletion references/ArchiSteamFarm
8 changes: 6 additions & 2 deletions release-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
2. 修复 库存游戏 编辑 Steam 游戏封面时选择自定义图片失败的问题
3. 修复 程序内在显示某些图片时会出现错乱马赛克的问题
4. 修复 Linux 上点击关于页面可能因字体引发闪退
5. 修复 MIUI Android 11 ~ 12 中绑定或换绑手机号页面闪退
6. 修复 Android 本地加速中已知问题弹窗显示时不应同时跳转引导证书页

<!--
~~仅发布桌面版~~
. 修复 MIUI Android 11 ~ 12 中绑定或换绑手机号页面闪退
TODO:
Android 第三方快速登录回调改为 URL Scheme
修复 Android 检查更新检测不到最新版本的问题
### 已知问题
- 除 Windows 之外的平台此软件自动更新尚不可用
Expand Down
23 changes: 20 additions & 3 deletions src/ST.Client.Android/Extensions/AuthExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using Android.App;
using System;
using System.Collections.Generic;
using System.Text;
using System.Application.Services;

// ReSharper disable once CheckNamespace
namespace System
{
public static class AuthExtensions
{
/// <summary>
/// 当未登录账号时,将关闭当前活动
/// </summary>
/// <param name="activity"></param>
/// <returns></returns>
public static bool IsAuthenticated(this Activity activity)
{
var value = UserService.Current.IsAuthenticated;
Expand All @@ -18,5 +20,20 @@ public static bool IsAuthenticated(this Activity activity)
}
return value;
}

/// <summary>
/// 当已登录账号时,将关闭当前活动
/// </summary>
/// <param name="activity"></param>
/// <returns></returns>
public static bool IsNotAuthenticated(this Activity activity)
{
var value = UserService.Current.IsAuthenticated;
if (value)
{
activity.Finish();
}
return value;
}
}
}
32 changes: 30 additions & 2 deletions src/ST.Client.Android/UI/Activities/LoginOrRegisterActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,29 @@
using System.Collections.Generic;
using System.Application.UI.Fragments;
using System.Text;
using CC = System.Application.Services.CloudService.Constants;

namespace System.Application.UI.Activities
{
[Register(JavaPackageConstants.Activities + nameof(LoginOrRegisterActivity))]
[Activity(Theme = ManifestConstants.MainTheme2_NoActionBar,
LaunchMode = LaunchMode.SingleTask,
ConfigurationChanges = ManifestConstants.ConfigurationChanges)]
LaunchMode = LaunchMode.SingleTask,
ConfigurationChanges = ManifestConstants.ConfigurationChanges,
Exported = true)]
[IntentFilter(actions: new[] { Intent.ActionView },
Categories = new[] {
Intent.CategoryBrowsable, // 通过浏览器的连接启动
Intent.CategoryDefault, // 该页面可以被隐式调用
},
DataScheme = CC.SchemeValue,
DataHost = "auth")]
internal sealed class LoginOrRegisterActivity : BaseActivity<activity_login_or_register, LoginOrRegisterWindowViewModel>
{
/* URL Route
* spp://auth/fast/{value?} 打开快速登录页面/回调授权值
* spp://auth/phonenum 打开手机号登录页面
*/

protected override int? LayoutResource => Resource.Layout.activity_login_or_register;

static readonly Dictionary<int, Func<string>> title_strings = new()
Expand All @@ -40,6 +54,8 @@ protected override void OnCreate2(Bundle? savedInstanceState)
{
base.OnCreate2(savedInstanceState);

this.IsNotAuthenticated();

this.SetSupportActionBarWithNavigationClick(binding!.toolbar, true);

var appBarConfiguration = new AppBarConfiguration.Builder(Resource.Id.navigation_login_or_register_fast).Build();
Expand All @@ -59,6 +75,18 @@ protected override void OnCreate2(Bundle? savedInstanceState)
}
}
}).AddTo(this);

OnNewIntent(Intent);
}

protected override void OnNewIntent(Intent? intent)
{
base.OnNewIntent(intent);
var intentData = intent?.DataString;
if (!string.IsNullOrWhiteSpace(intentData))
{

}
}

public static SpannableString CreateAgreementAndPrivacy(LoginOrRegisterWindowViewModel viewModel) => RichTextHelper.CreateSpannableString(list =>
Expand Down
21 changes: 13 additions & 8 deletions src/ST.Client.Android/UI/Fragments/CommunityFixFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ void SetProxyModeText()
var proxyMode = ProxySettings.ProxyModeValue;
binding!.tvProxyMode.Text = proxyMode switch
{
ProxyMode.ProxyOnly => $"{AppResources.CommunityFix_ProxyModeTip}{ProxySettings.ToStringByProxyMode(proxyMode)}{Environment.NewLine}IPEndPoint: {proxyS.ProxyIp}:{proxyS.ProxyPort}",
_ => $"{AppResources.CommunityFix_ProxyModeTip}{ProxySettings.ToStringByProxyMode(proxyMode)}",
ProxyMode.ProxyOnly => $"{AppResources.CommunityFix_ProxyMode}{ProxySettings.ToStringByProxyMode(proxyMode)}{Environment.NewLine}IPEndPoint: {proxyS.ProxyIp}:{proxyS.ProxyPort}",
_ => $"{AppResources.CommunityFix_ProxyMode}{ProxySettings.ToStringByProxyMode(proxyMode)}",
};
}

Expand Down Expand Up @@ -179,8 +179,11 @@ async void StartProxyButton_Click(bool start/*, bool ignoreVPNCheck = false*/)
"因 Android 7(Nougat API 24) 之后的版本不再信任用户证书,所以此功能已放弃继续开发," +
"如仍想使用需要自行使用 adb 工具或 Magisk 之类的软件导入证书到系统目录," +
"未来会使用不需要证书的加速功能替换此功能";
await MessageBox.ShowAsync(textCertificateTrustTip, "已知问题",
rememberChooseKey: MessageBox.DontPromptType.AndroidCertificateTrustTip);
if ((await MessageBox.ShowAsync(textCertificateTrustTip, "已知问题", MessageBox.Button.OKCancel,
rememberChooseKey: MessageBox.DontPromptType.AndroidCertificateTrustTip)) != MessageBox.Result.OK)
{
return;
}
}

Intent? intent = null;
Expand Down Expand Up @@ -357,10 +360,12 @@ internal static void InstallCertificate(Context context, CommunityProxyPageViewM
async void Test()
{
if (!ProxyService.Current.ProxyStatus) return;
var s = IHttpProxyService.Instance;
Xamarin.Android.Net.AndroidClientHandler handler = new();
handler.Proxy = new WebProxy(s.ProxyIp.ToString(), s.ProxyPort);
var certFilePath = s.GetCerFilePathGeneratedWhenNoFileExists();
var s = IReverseProxyService.Instance;
Xamarin.Android.Net.AndroidClientHandler handler = new()
{
Proxy = new WebProxy(s.ProxyIp.ToString(), s.ProxyPort),
};
var certFilePath = s.CertificateManager.GetCerFilePathGeneratedWhenNoFileExists();
if (certFilePath != null)
handler.AddTrustedCert(File.OpenRead(certFilePath));
using var client = new HttpClient(handler);
Expand Down
4 changes: 2 additions & 2 deletions src/ST.Client.Android/UI/ImageLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public static void SetImageSource(this ImageView imageView,
$"Bitmap.Width: {bitmap.Width}, " +
$"Bitmap.Height: {bitmap.Height}, " +
$"Bitmap.Config: {bitmap.GetConfig()}, " +
$"Bitmap.Size1: {IOPath.GetSizeString(bitmap.ByteCount)}, " +
$"Bitmap.Size2: {IOPath.GetSizeString(bitmap.AllocationByteCount)}.");
$"Bitmap.Size1: {IOPath.GetDisplayFileSizeString(bitmap.ByteCount)}, " +
$"Bitmap.Size2: {IOPath.GetDisplayFileSizeString(bitmap.AllocationByteCount)}.");
#endif
imageView.SetImageBitmap(bitmap);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ST.Client.Android/UI/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ bool GetIsMainProcess()
XEPlatform.ActivityStateChanged += OnActivityStateChanged;
if (isTrace) StartWatchTrace.Record("Essentials");

OnCreateAppExecuted(this, isTrace: isTrace);

var level = DILevel.Min;
if (IsMainProcess) level = DILevel.MainProcess;
IApplication.IProgramHost host = this;
Expand All @@ -120,6 +118,8 @@ bool GetIsMainProcess()
}
}

OnCreateAppExecuted(this, isTrace: isTrace);

host.OnStartup();
if (isTrace) StartWatchTrace.Record("OnStartup");

Expand Down
1 change: 1 addition & 0 deletions src/ST.Client.AppCenter/ST.Client.AppCenter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<RootNamespace>System.Application</RootNamespace>
<AssemblyName>System.Application.SteamTools.Client.AppCenter</AssemblyName>
<ImplicitUsings>enable</ImplicitUsings>
<AndroidUseIntermediateDesignerFile>false</AndroidUseIntermediateDesignerFile>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/ST.Client/ST.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
<PackageReference Include="Fleck" />
<!--<PackageReference Include="CommunityToolkit.Mvvm"/>-->
<PackageReference Include="ReactiveUI.Fody" />
<PackageReference Include="ArchiSteamFarm.Library" />
<!--<PackageReference Include="ArchiSteamFarm.Library" />-->
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) ">
<PackageReference Include="JustArchiNET.Madness" />
</ItemGroup>

<ItemGroup>
<!--<ProjectReference Include="..\..\references\ArchiSteamFarm\ArchiSteamFarm.Library\ArchiSteamFarm.Library.csproj" />-->
<ProjectReference Include="..\..\references\ArchiSteamFarm\ArchiSteamFarm.Library\ArchiSteamFarm.Library.csproj" />
<ProjectReference Include="..\Common.PinyinLib\Common.PinyinLib.csproj" />
<ProjectReference Include="..\Repositories.sqlite-net-pcl\Repositories.sqlite-net-pcl.csproj" />
<ProjectReference Include="..\ST.Client.ReverseProxy\ST.Client.ReverseProxy.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public partial class ArchiSteamFarmServiceImpl : ReactiveObject, IArchiSteamFarm

public ArchiSteamFarmServiceImpl()
{
ArchiSteamFarmLibrary.Init(this, IOPath.AppDataDirectory, IApplication.LogDirPathASF);
ArchiSteamFarmLibrary.Init(this, IOPath.AppDataDirectory, IApplication.LogDirPath);
}

public event Action<string>? OnConsoleWirteLine;
Expand Down
4 changes: 0 additions & 4 deletions src/ST.Client/UI/Resx/AppResources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,6 @@
<value>Routing mode</value>
<comment>Comment=;Author=沙中金</comment>
</data>
<data name="CommunityFix_ProxyModeTip" xml:space="preserve">
<value>Routing mode</value>
<comment>Comment=;Author=沙中金</comment>
</data>
<data name="ProxyMode_Hosts" xml:space="preserve">
<value>Hosts routing mode</value>
<comment>Comment=;Author=沙中金</comment>
Expand Down
4 changes: 0 additions & 4 deletions src/ST.Client/UI/Resx/AppResources.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,6 @@
<value>Modo de aceleración</value>
<comment>Comment=;Author=EspRoy</comment>
</data>
<data name="CommunityFix_ProxyModeTip" xml:space="preserve">
<value>Modo de aceleración:</value>
<comment>Comment=;Author=EspRoy</comment>
</data>
<data name="ProxyMode_Hosts" xml:space="preserve">
<value>Modo proxy de hosts</value>
<comment>Comment=;Author=EspRoy</comment>
Expand Down
4 changes: 0 additions & 4 deletions src/ST.Client/UI/Resx/AppResources.it.resx
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,6 @@
<value>Modalità di accelerazione</value>
<comment>Comment=;Author=Zhengye</comment>
</data>
<data name="CommunityFix_ProxyModeTip" xml:space="preserve">
<value>Modalità accelerata :</value>
<comment>Comment=;Author=Zhengye</comment>
</data>
<data name="ProxyMode_Hosts" xml:space="preserve">
<value>Modalità proxy Hosts</value>
<comment>Comment=;Author=Zhengye</comment>
Expand Down
4 changes: 0 additions & 4 deletions src/ST.Client/UI/Resx/AppResources.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,6 @@
<value>加速モード</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="CommunityFix_ProxyModeTip" xml:space="preserve">
<value>加速モード:</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="ProxyMode_Hosts" xml:space="preserve">
<value>Hosts プロキシ モード</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
Expand Down
4 changes: 0 additions & 4 deletions src/ST.Client/UI/Resx/AppResources.ko.resx
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,6 @@
<value>가속 모드</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="CommunityFix_ProxyModeTip" xml:space="preserve">
<value>가속 모드:</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="ProxyMode_Hosts" xml:space="preserve">
<value>호스트 프록시 모드</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
Expand Down
4 changes: 0 additions & 4 deletions src/ST.Client/UI/Resx/AppResources.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,6 @@ AAAAA-BBBBB-CCCC3</value>
<value>Режим ускорения</value>
<comment>Comment=;Author=vanja-san</comment>
</data>
<data name="CommunityFix_ProxyModeTip" xml:space="preserve">
<value>Режим ускорения:</value>
<comment>Comment=;Author=vanja-san</comment>
</data>
<data name="ProxyMode_Hosts" xml:space="preserve">
<value>Режим хоста прокси</value>
<comment>Comment=;Author=vanja-san</comment>
Expand Down
4 changes: 0 additions & 4 deletions src/ST.Client/UI/Resx/AppResources.zh-Hant.resx
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,6 @@
<value>加速模式</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="CommunityFix_ProxyModeTip" xml:space="preserve">
<value>加速模式:</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="ProxyMode_Hosts" xml:space="preserve">
<value>Hosts 代理模式</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public static class Constants

public static string NetworkConnectionInterruption => SR.NetworkConnectionInterruption;

public const string Scheme = "spp://";
public const string SchemeValue = "spp";

public const string Scheme = $"{SchemeValue}://";

public const string Referrer_ = $"{Scheme}{{0}}/{_ThisAssembly.Version}";

Expand Down
2 changes: 1 addition & 1 deletion src/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public MockServiceProvider(Action<IServiceCollection> configureServices)

#endregion

// OnCreateAppExecuting -> OnCreateAppExecuted -> DI.ConfigureServices(Init) -> OnStartup
// OnCreateAppExecuting -> DI.ConfigureServices(Init) -> OnCreateAppExecuted -> OnStartup

#region OnCreateApplication

Expand Down

0 comments on commit f057d41

Please sign in to comment.