Skip to content

Commit 9d029c1

Browse files
committed
Go directly to language settings
1 parent 46fdf18 commit 9d029c1

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ private boolean handleAppLocalePickerClick() {
652652
// if per-app language preferences are enabled and the device is on API 33+, take the user to the
653653
// system app settings to change the language
654654
if (mIsPerAppLanguagePrefsEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
655-
mLocaleHelper.openAppSettings(getContext());
655+
mLocaleHelper.openAppLanguageSettings(getContext());
656656
return true;
657657
} else if (getActivity() instanceof AppCompatActivity) {
658658
LocalePickerBottomSheet bottomSheet = LocalePickerBottomSheet.newInstance();

WordPress/src/main/java/org/wordpress/android/ui/prefs/language/LocaleHelper.kt

+19-11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.wordpress.android.ui.prefs.language
33
import android.content.Context
44
import android.content.Intent
55
import android.net.Uri
6+
import android.os.Build
67
import android.provider.Settings
78
import androidx.appcompat.app.AppCompatDelegate
89
import androidx.core.os.LocaleListCompat
@@ -85,18 +86,25 @@ class LocaleHelper @Inject constructor(
8586
}
8687

8788
/**
88-
* Open the app settings screen so the user can change the app locale - note that
89-
* the locale is only available in API 33+
89+
* Open the app settings screen so the user can change the app language.
90+
* Note that the per-app language setting is only available in API 33+
91+
* and it's up to the caller to check the version
9092
*/
91-
fun openAppSettings(context: Context) {
92-
Intent().also { intent ->
93-
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
94-
intent.addCategory(Intent.CATEGORY_DEFAULT)
95-
intent.setData(Uri.parse("package:" + context.packageName))
96-
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
97-
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
98-
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
99-
context.startActivity(intent)
93+
fun openAppLanguageSettings(context: Context) {
94+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
95+
Intent().also { intent ->
96+
intent.setAction(Settings.ACTION_APP_LOCALE_SETTINGS)
97+
intent.addCategory(Intent.CATEGORY_DEFAULT)
98+
intent.setData(Uri.parse("package:" + context.packageName))
99+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
100+
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
101+
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
102+
context.startActivity(intent)
103+
}
104+
} else {
105+
throw UnsupportedOperationException(
106+
"Per-app language settings are not available in this version of Android"
107+
)
100108
}
101109
}
102110

0 commit comments

Comments
 (0)