Skip to content

Commit 4dd6e3c

Browse files
committed
Minor changes for app
1 parent 0d39b10 commit 4dd6e3c

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler {
104104
override fun onItemAction(view: View, item: BaseSettingsItem) {
105105
when (item) {
106106
Theme -> SettingsFragmentDirections.actionSettingsFragmentToThemeFragment().navigate()
107-
LanguageSystem -> launchAppLocaleSettings(view.activity)
107+
LanguageSystem -> view.activity.startActivity(LocaleSetting.localeSettingsIntent)
108108
AddShortcut -> AddHomeIconEvent().publish()
109109
SystemlessHosts -> createHosts()
110110
DenyListConfig -> SettingsFragmentDirections.actionSettingsFragmentToDenyFragment().navigate()
@@ -116,12 +116,6 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler {
116116
}
117117
}
118118

119-
private fun launchAppLocaleSettings(activity: Activity) {
120-
val intent = Intent(Settings.ACTION_APP_LOCALE_SETTINGS)
121-
intent.data = Uri.fromParts("package", activity.packageName, null)
122-
activity.startActivity(intent)
123-
}
124-
125119
private fun openUrlIfNecessary(view: View) {
126120
UpdateChannelUrl.refresh()
127121
if (UpdateChannelUrl.isEnabled && UpdateChannelUrl.value.isBlank()) {

app/core/src/main/java/com/topjohnwu/magisk/core/utils/LocaleSetting.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ interface LocaleSetting {
3333

3434
private val systemLocale: Locale = Locale.getDefault()
3535

36-
override var currentLocale: Locale = systemLocale
3736
override var appLocale: Locale? = null
37+
override var currentLocale: Locale = systemLocale
3838

3939
init {
4040
setLocale(Config.locale)
@@ -167,10 +167,18 @@ interface LocaleSetting {
167167
LocaleConfig.fromContextIgnoringOverride(context)
168168
}
169169

170-
val useLocaleManager get() =
171-
(if (isRunningAsStub) Build.VERSION.SDK_INT >= 34 else Build.VERSION.SDK_INT >= 33) &&
172-
Intent(Settings.ACTION_APP_LOCALE_SETTINGS, Uri.fromParts("package", AppContext.packageName, null))
173-
.resolveActivity(AppContext.packageManager) != null
170+
private val localeManagerUsable get() =
171+
if (isRunningAsStub) Build.VERSION.SDK_INT >= 34 else Build.VERSION.SDK_INT >= 33
172+
173+
val useLocaleManager by lazy {
174+
localeManagerUsable &&
175+
localeSettingsIntent.resolveActivity(AppContext.packageManager) != null
176+
}
177+
178+
val localeSettingsIntent get() = Intent(
179+
Settings.ACTION_APP_LOCALE_SETTINGS,
180+
Uri.fromParts("package", AppContext.packageName, null),
181+
)
174182

175183
val instance: LocaleSetting by lazy {
176184
// Initialize available locale list

app/gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kotlin = "2.3.0"
33
android = "9.0.0"
44
ksp = "2.3.4"
55
rikka = "1.3.0"
6-
navigation = "2.9.6"
6+
navigation = "2.9.7"
77
libsu = "6.0.0"
88
okhttp = "5.3.2"
99
retrofit = "3.0.0"
@@ -23,7 +23,7 @@ timber = { module = "com.jakewharton.timber:timber", version = "5.0.1" }
2323
jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version = "7.1.0.202411261347-r" }
2424

2525
# AndroidX
26-
activity = { module = "androidx.activity:activity", version = "1.12.2" }
26+
activity = { module = "androidx.activity:activity", version = "1.12.3" }
2727
appcompat = { module = "androidx.appcompat:appcompat", version = "1.7.1" }
2828
core-ktx = { module = "androidx.core:core-ktx", version = "1.17.0" }
2929
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
6363
ksp-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" }
6464
navigation-safe-args-plugin = { module = "androidx.navigation:navigation-safe-args-gradle-plugin", version.ref = "navigation" }
6565
lsparanoid-plugin = { module = "org.lsposed.lsparanoid:gradle-plugin", version = "0.6.0" }
66-
moshi-plugin = { module = "dev.zacsweers.moshix:dev.zacsweers.moshix.gradle.plugin", version = "0.34.2" }
66+
moshi-plugin = { module = "dev.zacsweers.moshix:dev.zacsweers.moshix.gradle.plugin", version = "0.34.4" }
6767

6868
[plugins]

0 commit comments

Comments
 (0)