diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt index 1a6db30cc..e8dd010f9 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt @@ -104,7 +104,7 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler { override fun onItemAction(view: View, item: BaseSettingsItem) { when (item) { Theme -> SettingsFragmentDirections.actionSettingsFragmentToThemeFragment().navigate() - LanguageSystem -> launchAppLocaleSettings(view.activity) + LanguageSystem -> view.activity.startActivity(LocaleSetting.localeSettingsIntent) AddShortcut -> AddHomeIconEvent().publish() SystemlessHosts -> createHosts() DenyListConfig -> SettingsFragmentDirections.actionSettingsFragmentToDenyFragment().navigate() @@ -116,12 +116,6 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler { } } - private fun launchAppLocaleSettings(activity: Activity) { - val intent = Intent(Settings.ACTION_APP_LOCALE_SETTINGS) - intent.data = Uri.fromParts("package", activity.packageName, null) - activity.startActivity(intent) - } - private fun openUrlIfNecessary(view: View) { UpdateChannelUrl.refresh() if (UpdateChannelUrl.isEnabled && UpdateChannelUrl.value.isBlank()) { diff --git a/app/core/src/main/java/com/topjohnwu/magisk/core/utils/LocaleSetting.kt b/app/core/src/main/java/com/topjohnwu/magisk/core/utils/LocaleSetting.kt index 4f936ed57..c9cc31e84 100644 --- a/app/core/src/main/java/com/topjohnwu/magisk/core/utils/LocaleSetting.kt +++ b/app/core/src/main/java/com/topjohnwu/magisk/core/utils/LocaleSetting.kt @@ -33,8 +33,8 @@ interface LocaleSetting { private val systemLocale: Locale = Locale.getDefault() - override var currentLocale: Locale = systemLocale override var appLocale: Locale? = null + override var currentLocale: Locale = systemLocale init { setLocale(Config.locale) @@ -167,10 +167,18 @@ interface LocaleSetting { LocaleConfig.fromContextIgnoringOverride(context) } - val useLocaleManager get() = - (if (isRunningAsStub) Build.VERSION.SDK_INT >= 34 else Build.VERSION.SDK_INT >= 33) && - Intent(Settings.ACTION_APP_LOCALE_SETTINGS, Uri.fromParts("package", AppContext.packageName, null)) - .resolveActivity(AppContext.packageManager) != null + private val localeManagerUsable get() = + if (isRunningAsStub) Build.VERSION.SDK_INT >= 34 else Build.VERSION.SDK_INT >= 33 + + val useLocaleManager by lazy { + localeManagerUsable && + localeSettingsIntent.resolveActivity(AppContext.packageManager) != null + } + + val localeSettingsIntent get() = Intent( + Settings.ACTION_APP_LOCALE_SETTINGS, + Uri.fromParts("package", AppContext.packageName, null), + ) val instance: LocaleSetting by lazy { // Initialize available locale list diff --git a/app/gradle/libs.versions.toml b/app/gradle/libs.versions.toml index 1947d50f4..e69305501 100644 --- a/app/gradle/libs.versions.toml +++ b/app/gradle/libs.versions.toml @@ -3,7 +3,7 @@ kotlin = "2.3.0" android = "9.0.0" ksp = "2.3.4" rikka = "1.3.0" -navigation = "2.9.6" +navigation = "2.9.7" libsu = "6.0.0" okhttp = "5.3.2" retrofit = "3.0.0" @@ -23,7 +23,7 @@ timber = { module = "com.jakewharton.timber:timber", version = "5.0.1" } jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version = "7.1.0.202411261347-r" } # AndroidX -activity = { module = "androidx.activity:activity", version = "1.12.2" } +activity = { module = "androidx.activity:activity", version = "1.12.3" } appcompat = { module = "androidx.appcompat:appcompat", version = "1.7.1" } core-ktx = { module = "androidx.core:core-ktx", version = "1.17.0" } core-splashscreen = { module = "androidx.core:core-splashscreen", version = "1.2.0" } @@ -63,6 +63,6 @@ android-kapt-plugin = { module = "com.android.legacy-kapt:com.android.legacy-kap ksp-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" } navigation-safe-args-plugin = { module = "androidx.navigation:navigation-safe-args-gradle-plugin", version.ref = "navigation" } lsparanoid-plugin = { module = "org.lsposed.lsparanoid:gradle-plugin", version = "0.6.0" } -moshi-plugin = { module = "dev.zacsweers.moshix:dev.zacsweers.moshix.gradle.plugin", version = "0.34.2" } +moshi-plugin = { module = "dev.zacsweers.moshix:dev.zacsweers.moshix.gradle.plugin", version = "0.34.4" } [plugins]