Skip to content

Commit da106e2

Browse files
committed
Don't try to migrate "system" app language
1 parent 3532ac9 commit da106e2

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

  • app/src/main/java/org/schabi/newpipe

app/src/main/java/org/schabi/newpipe/App.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,20 @@ public void onCreate() {
127127
YoutubeStreamExtractor.setPoTokenProvider(PoTokenProviderImpl.INSTANCE);
128128

129129
if (Build.VERSION.SDK_INT >= 33) {
130+
final String appLanguageDefaultValue = getString(R.string.default_localization_key);
130131
final String appLanguageKey = getString(R.string.app_language_key);
131-
if (prefs.contains(appLanguageKey)) {
132+
final String appLanguageCurrentValue = prefs.getString(appLanguageKey, null);
133+
if (appLanguageCurrentValue != null) {
132134
// Migrate to Android per-app language settings
133-
final String languageCode = prefs.getString(appLanguageKey, null);
134135
prefs.edit().remove(appLanguageKey).apply();
135-
try {
136-
AppCompatDelegate.setApplicationLocales(
137-
LocaleListCompat.forLanguageTags(languageCode)
138-
);
139-
} catch (final RuntimeException e) {
140-
Log.e(TAG, "Error migrating to Android 13+ per-app language settings");
136+
if (!appLanguageCurrentValue.equals(appLanguageDefaultValue)) {
137+
try {
138+
AppCompatDelegate.setApplicationLocales(
139+
LocaleListCompat.forLanguageTags(appLanguageCurrentValue)
140+
);
141+
} catch (final RuntimeException e) {
142+
Log.e(TAG, "Error migrating to Android 13+ per-app language settings");
143+
}
141144
}
142145
}
143146
}

0 commit comments

Comments
 (0)