From da106e2361b9660b25e1a9a81fa5d74d37d826e2 Mon Sep 17 00:00:00 2001 From: Miles Krell Date: Sat, 15 Mar 2025 22:54:17 -0400 Subject: [PATCH] Don't try to migrate "system" app language --- app/src/main/java/org/schabi/newpipe/App.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 495ef43a5..992651141 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -127,17 +127,20 @@ public class App extends Application { YoutubeStreamExtractor.setPoTokenProvider(PoTokenProviderImpl.INSTANCE); if (Build.VERSION.SDK_INT >= 33) { + final String appLanguageDefaultValue = getString(R.string.default_localization_key); final String appLanguageKey = getString(R.string.app_language_key); - if (prefs.contains(appLanguageKey)) { + final String appLanguageCurrentValue = prefs.getString(appLanguageKey, null); + if (appLanguageCurrentValue != null) { // Migrate to Android per-app language settings - final String languageCode = prefs.getString(appLanguageKey, null); prefs.edit().remove(appLanguageKey).apply(); - try { - AppCompatDelegate.setApplicationLocales( - LocaleListCompat.forLanguageTags(languageCode) - ); - } catch (final RuntimeException e) { - Log.e(TAG, "Error migrating to Android 13+ per-app language settings"); + if (!appLanguageCurrentValue.equals(appLanguageDefaultValue)) { + try { + AppCompatDelegate.setApplicationLocales( + LocaleListCompat.forLanguageTags(appLanguageCurrentValue) + ); + } catch (final RuntimeException e) { + Log.e(TAG, "Error migrating to Android 13+ per-app language settings"); + } } } }