mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-25 11:39:56 +08:00
Android localization following system
This commit is contained in:
+6
-3
@@ -25,16 +25,19 @@
|
||||
| Steam++_win_x64_v2.5.0.7z | SHA256 |
|
||||
| Steam++_win_x64_v2.5.0.exe | SHA256 |
|
||||
| Steam++_win_x64_v2.5.0.msix | SHA256 |
|
||||
|
|
||||
| Steam++_win_arm64_v2.5.0.7z | SHA256 |
|
||||
| Steam++_win_arm64_v2.5.0.exe | SHA256 |
|
||||
| Steam++_win_arm64_v2.5.0.msix | SHA256 |
|
||||
|
|
||||
| Steam++_linux_x64_v2.5.0.7z | SHA256 |
|
||||
| Steam++_linux_x64_v2.5.0.deb | SHA256 |
|
||||
|
|
||||
| Steam++_macos_x64_v2.5.0.dmg | SHA256 |
|
||||
| Steam++_macos_arm64_v2.5.0.dmg | SHA256 |
|
||||
| net.steampp.app-arm64-v8a-Signed.apk | SHA256 |
|
||||
| net.steampp.app-armeabi-v7a-Signed.apk | SHA256 |
|
||||
| net.steampp.app-x86_64-Signed.apk | SHA256 |
|
||||
|
|
||||
| Steam++_android_arm64_v8a_v2.5.0.apk | SHA256 |
|
||||
| Steam++_android_armeabi_v7a_v2.5.0.apk | SHA256 |
|
||||
|
||||
***
|
||||
|
||||
|
||||
@@ -124,10 +124,11 @@ namespace System
|
||||
|
||||
#endif
|
||||
|
||||
public static void SetSupportActionBarWithNavigationClick(this AppCompatActivity activity, Toolbar toolbar)
|
||||
public static void SetSupportActionBarWithNavigationClick(this AppCompatActivity activity, Toolbar toolbar, bool displayHomeAsUpEnabled = false)
|
||||
{
|
||||
activity.SetSupportActionBar(toolbar);
|
||||
toolbar.NavigationClick += (_, _) => activity.OnBackPressed();
|
||||
if (displayHomeAsUpEnabled) activity.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
using ReactiveUI;
|
||||
using System.Application.Services;
|
||||
using System.Application.UI.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using AppRes = System.Application.UI.Resx.AppResources;
|
||||
#if __MOBILE__
|
||||
using R_Res_TYPE = System.Byte;
|
||||
using Res = System.Byte;
|
||||
#else
|
||||
using R_Res_TYPE = System.Application.UI.Resx.AppResources;
|
||||
using Res = System.Application.UI.Resx.AppResources;
|
||||
#endif
|
||||
|
||||
namespace System.Application.UI.Resx
|
||||
@@ -21,9 +23,9 @@ namespace System.Application.UI.Resx
|
||||
static readonly Lazy<IReadOnlyCollection<KeyValuePair<string, string>>> mFonts = new(() => IFontManager.Instance.GetFonts());
|
||||
public static IReadOnlyCollection<KeyValuePair<string, string>> Fonts => mFonts.Value;
|
||||
|
||||
public R_Res_TYPE Res { get; set; } = new();
|
||||
public Res Res { get; set; } = new();
|
||||
|
||||
public static CultureInfo DefaultCurrentUICulture { get; }
|
||||
public static CultureInfo DefaultCurrentUICulture { get; private set; }
|
||||
|
||||
static R()
|
||||
{
|
||||
@@ -52,7 +54,7 @@ namespace System.Application.UI.Resx
|
||||
{ "es", "spanish" },
|
||||
{ "it", "italian" },
|
||||
};
|
||||
AppResources.Culture = DefaultCurrentUICulture;
|
||||
AppRes.Culture = DefaultCurrentUICulture;
|
||||
}
|
||||
|
||||
static bool IsMatch(CultureInfo cultureInfo, string cultureName)
|
||||
@@ -71,27 +73,37 @@ namespace System.Application.UI.Resx
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChangeAutoLanguage(CultureInfo? cultureInfo = null)
|
||||
{
|
||||
#if !__MOBILE__
|
||||
if (!string.IsNullOrWhiteSpace(SettingsPageViewModel.Instance.SelectLanguage.Key)) return;
|
||||
#endif
|
||||
cultureInfo ??= CultureInfo.CurrentUICulture;
|
||||
DefaultCurrentUICulture = cultureInfo;
|
||||
ChangeLanguage(cultureInfo.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改语言
|
||||
/// </summary>
|
||||
/// <param name="cultureName"></param>
|
||||
public static void ChangeLanguage(string? cultureName)
|
||||
{
|
||||
if (cultureName == null || IsMatch(AppResources.Culture, cultureName)) return;
|
||||
AppResources.Culture = string.IsNullOrWhiteSpace(cultureName) ?
|
||||
if (cultureName == null || IsMatch(AppRes.Culture, cultureName)) return;
|
||||
AppRes.Culture = string.IsNullOrWhiteSpace(cultureName) ?
|
||||
DefaultCurrentUICulture :
|
||||
CultureInfo.GetCultureInfo(Languages.SingleOrDefault(x => x.Key == cultureName).Key);
|
||||
CultureInfo.CurrentUICulture = AppResources.Culture;
|
||||
CultureInfo.DefaultThreadCurrentUICulture = AppResources.Culture;
|
||||
CultureInfo.CurrentCulture = AppResources.Culture;
|
||||
CultureInfo.DefaultThreadCurrentCulture = AppResources.Culture;
|
||||
CultureInfo.CurrentUICulture = AppRes.Culture;
|
||||
CultureInfo.DefaultThreadCurrentUICulture = AppRes.Culture;
|
||||
CultureInfo.CurrentCulture = AppRes.Culture;
|
||||
CultureInfo.DefaultThreadCurrentCulture = AppRes.Culture;
|
||||
mAcceptLanguage = GetAcceptLanguageCore();
|
||||
mLanguage = GetLanguageCore();
|
||||
Current.Res =
|
||||
#if __MOBILE__
|
||||
++Current.Res;
|
||||
#else
|
||||
new AppResources();
|
||||
new();
|
||||
#endif
|
||||
Current.RaisePropertyChanged(nameof(Res));
|
||||
}
|
||||
@@ -182,6 +194,6 @@ namespace System.Application.UI.Resx
|
||||
}
|
||||
}
|
||||
|
||||
public static CultureInfo Culture => AppResources.Culture ?? DefaultCurrentUICulture;
|
||||
public static CultureInfo Culture => AppRes.Culture ?? DefaultCurrentUICulture;
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,8 @@
|
||||
<AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
<MandroidI18n />
|
||||
<AndroidSupportedAbis>armeabi-v7a;x86_64;arm64-v8a</AndroidSupportedAbis>
|
||||
<AndroidSupportedAbis>
|
||||
</AndroidSupportedAbis>
|
||||
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using Com.Leinardi.Android.Speeddial;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace System
|
||||
{
|
||||
public static class FloatingActionButtonExtensions
|
||||
{
|
||||
public static void ReplaceLabels<TEnum>(this IReadOnlyDictionary<TEnum, FabWithLabelView>? speedDialDict, Func<TEnum, string> getLabel)
|
||||
{
|
||||
if (!speedDialDict.Any_Nullable()) return;
|
||||
foreach (var x in speedDialDict!)
|
||||
{
|
||||
var label = getLabel(x.Key);
|
||||
x.Value.SpeedDialActionItem = x.Value.SpeedDialActionItemBuilder.SetLabel(label).Create();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ namespace System.Application
|
||||
ConfigChanges.Keyboard |
|
||||
ConfigChanges.KeyboardHidden |
|
||||
ConfigChanges.ScreenLayout |
|
||||
ConfigChanges.Locale |
|
||||
ConfigChanges.LayoutDirection |
|
||||
ConfigChanges.SmallestScreenSize;
|
||||
|
||||
public const string MainTheme = "@style/MainTheme";
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using System.Application.UI.Resx;
|
||||
|
||||
namespace System.Application.Receivers
|
||||
{
|
||||
[BroadcastReceiver(Enabled = true, Exported = true)]
|
||||
[IntentFilter(new[] { Intent.ActionLocaleChanged }, Priority = int.MaxValue)]
|
||||
internal sealed class LocaleChangedReceiver : BroadcastReceiver
|
||||
{
|
||||
public override void OnReceive(Context? context, Intent? intent)
|
||||
{
|
||||
if (intent == null) return;
|
||||
if (intent.Action != Intent.ActionLocaleChanged) return;
|
||||
var locale = Java.Util.Locale.Default;
|
||||
string name;
|
||||
if (!string.IsNullOrWhiteSpace(locale.Script))
|
||||
{
|
||||
name = $"{locale.Language}-{locale.Script}";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = locale.Language;
|
||||
}
|
||||
R.ChangeAutoLanguage(new(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,8 +43,7 @@ namespace System.Application.UI.Activities
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar, true);
|
||||
|
||||
binding!.tvDevelopers.SetLinkMovementMethod();
|
||||
binding!.tvBusinessCooperationContact.SetLinkMovementMethod();
|
||||
|
||||
@@ -26,8 +26,7 @@ namespace System.Application.UI.Activities
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar, true);
|
||||
|
||||
binding.tab_layout.TabMode = TabLayout.ModeScrollable;
|
||||
var adapter = new ViewPagerWithTabLayoutAdapter(this, this);
|
||||
|
||||
@@ -43,8 +43,7 @@ namespace System.Application.UI.Activities
|
||||
return;
|
||||
}
|
||||
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar, true);
|
||||
|
||||
ViewModel!.Authenticator.WhenAnyValue(x => x.Name).Subscribe(value =>
|
||||
{
|
||||
|
||||
@@ -23,8 +23,7 @@ namespace System.Application.UI.Activities
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar, true);
|
||||
|
||||
R.Current.WhenAnyValue(x => x.Res).Subscribe(_ =>
|
||||
{
|
||||
|
||||
@@ -33,8 +33,7 @@ namespace System.Application.UI.Activities
|
||||
return;
|
||||
}
|
||||
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar, true);
|
||||
|
||||
R.Current.WhenAnyValue(x => x.Res).Subscribe(_ =>
|
||||
{
|
||||
|
||||
@@ -37,8 +37,7 @@ namespace System.Application.UI.Activities
|
||||
|
||||
this.SetWindowSecure(true);
|
||||
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar, true);
|
||||
|
||||
binding!.tvSteamGuardLabel.Text = "SteamGuard:";
|
||||
R.Current.WhenAnyValue(x => x.Res).Subscribe(_ =>
|
||||
|
||||
@@ -43,8 +43,7 @@ namespace System.Application.UI.Activities
|
||||
return;
|
||||
}
|
||||
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar, true);
|
||||
|
||||
R.Current.WhenAnyValue(x => x.Res).Subscribe(_ =>
|
||||
{
|
||||
@@ -56,6 +55,7 @@ namespace System.Application.UI.Activities
|
||||
binding.btnLogin.Text = Login;
|
||||
binding.tvSteamTradeLoginTip.Text = LocalAuth_SteamTradeLoginTip;
|
||||
binding.tvLoading.Text = LocalAuth_AuthTrade_GetTip;
|
||||
speedDialDict.ReplaceLabels(ToString2);
|
||||
}).AddTo(this);
|
||||
|
||||
ViewModel!.WhenAnyValue(x => x.IsLoggedIn).Subscribe(value =>
|
||||
@@ -65,6 +65,7 @@ namespace System.Application.UI.Activities
|
||||
var state_reverse = !value ? ViewStates.Gone : ViewStates.Visible;
|
||||
binding.layoutContentSteamLogin.Visibility = state;
|
||||
binding.layoutContentConfirmations.Visibility = state_reverse;
|
||||
binding.speedDial.Visibility = state_reverse;
|
||||
}).AddTo(this);
|
||||
ViewModel!.WhenAnyValue(x => x.IsRequiresCaptcha).Subscribe(value =>
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace System.Application.UI.Activities
|
||||
|
||||
tencent = TencentOpenApiSDK.GetTencent(this);
|
||||
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar);
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar, true);
|
||||
|
||||
var appBarConfiguration = new AppBarConfiguration.Builder(Resource.Id.navigation_login_or_register_fast).Build();
|
||||
navController = ((NavHostFragment)SupportFragmentManager.FindFragmentById(Resource.Id.nav_host_fragment)).NavController;
|
||||
|
||||
@@ -5,10 +5,10 @@ using Android.Runtime;
|
||||
using AndroidX.Navigation;
|
||||
using AndroidX.Navigation.UI;
|
||||
using Binding;
|
||||
using Java.Lang;
|
||||
using ReactiveUI;
|
||||
using System.Application.UI.Resx;
|
||||
using System.Application.UI.ViewModels;
|
||||
using CharSequence = Java.Lang.ICharSequence;
|
||||
|
||||
namespace System.Application.UI.Activities
|
||||
{
|
||||
@@ -22,7 +22,7 @@ namespace System.Application.UI.Activities
|
||||
|
||||
protected override bool BackToHome => true;
|
||||
|
||||
void SetBottomNavigationMenuTitle(int resId, ICharSequence value)
|
||||
void SetBottomNavigationMenuTitle(int resId, CharSequence value)
|
||||
{
|
||||
if (binding == null) return;
|
||||
var menu = binding.nav_view.Menu;
|
||||
@@ -51,14 +51,15 @@ namespace System.Application.UI.Activities
|
||||
Resource.Id.navigation_my)
|
||||
.Build();
|
||||
navController = Navigation.FindNavController(this, Resource.Id.nav_host_fragment_activity_main);
|
||||
NavigationUI.SetupActionBarWithNavController(this, navController, appBarConfiguration);
|
||||
NavigationUI.SetupWithNavController(binding!.nav_view, navController);
|
||||
|
||||
R.Current.WhenAnyValue(x => x.Res).Subscribe(_ =>
|
||||
{
|
||||
SetSubPageTitle(Resource.Id.navigation_local_auth, LocalAuthPageViewModel.DisplayName);
|
||||
SetSubPageTitle(Resource.Id.navigation_my, MyPageViewModel.DisplayName);
|
||||
}).AddTo(this);
|
||||
|
||||
NavigationUI.SetupActionBarWithNavController(this, navController, appBarConfiguration);
|
||||
NavigationUI.SetupWithNavController(binding!.nav_view, navController);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace System.Application.UI.Activities
|
||||
base.OnCreate(savedInstanceState);
|
||||
//if (!DeviceSecurityCheckUtil.IsAllowStart(this)) return;
|
||||
this.StartActivity<MainActivity>();
|
||||
OverridePendingTransition(Resource.Animation.abc_fade_in, Resource.Animation.abc_fade_out);
|
||||
}
|
||||
|
||||
public override void OnBackPressed()
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace System.Application.UI.Activities
|
||||
return;
|
||||
}
|
||||
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
this.SetSupportActionBarWithNavigationClick(binding!.toolbar, true);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(vm.Title)) Title = vm.Title;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(vm.Content)) binding!.tvContent.Text = vm.Content;
|
||||
|
||||
@@ -29,14 +29,12 @@ namespace System.Application.UI.Fragments
|
||||
{
|
||||
base.OnCreateView(view);
|
||||
|
||||
// This WhenActivated block calls ViewModel's WhenActivated
|
||||
// block if the ViewModel implements IActivatableViewModel.
|
||||
|
||||
R.Current.WhenAnyValue(x => x.Res).Subscribe(_ =>
|
||||
{
|
||||
if (binding == null) return;
|
||||
binding.tvEmptyTip.Text = LocalAuth_NoAuthTip_.Format(BottomRightCorner);
|
||||
binding.tvLoading.Text = LocalAuth_Loading;
|
||||
speedDialDict.ReplaceLabels(ToString2);
|
||||
}).AddTo(this);
|
||||
|
||||
ViewModel!.WhenAnyValue(x => x.IsAuthenticatorsEmpty).Subscribe(value =>
|
||||
|
||||
Reference in New Issue
Block a user