mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Move migration to separate method
This commit is contained in:
		| @@ -127,20 +127,24 @@ public class App extends Application { | |||||||
|         YoutubeStreamExtractor.setPoTokenProvider(PoTokenProviderImpl.INSTANCE); |         YoutubeStreamExtractor.setPoTokenProvider(PoTokenProviderImpl.INSTANCE); | ||||||
|  |  | ||||||
|         if (Build.VERSION.SDK_INT >= 33) { |         if (Build.VERSION.SDK_INT >= 33) { | ||||||
|             final String appLanguageDefaultValue = getString(R.string.default_localization_key); |             ensureAppLanguagePreferenceIsMigrated(prefs); | ||||||
|             final String appLanguageKey = getString(R.string.app_language_key); |         } | ||||||
|             final String appLanguageCurrentValue = prefs.getString(appLanguageKey, null); |     } | ||||||
|             if (appLanguageCurrentValue != null) { |  | ||||||
|                 // Migrate to Android per-app language settings |     private void ensureAppLanguagePreferenceIsMigrated(final SharedPreferences prefs) { | ||||||
|                 prefs.edit().remove(appLanguageKey).apply(); |         final String appLanguageDefaultValue = getString(R.string.default_localization_key); | ||||||
|                 if (!appLanguageCurrentValue.equals(appLanguageDefaultValue)) { |         final String appLanguageKey = getString(R.string.app_language_key); | ||||||
|                     try { |         final String appLanguageCurrentValue = prefs.getString(appLanguageKey, null); | ||||||
|                         AppCompatDelegate.setApplicationLocales( |         if (appLanguageCurrentValue != null) { | ||||||
|                                 LocaleListCompat.forLanguageTags(appLanguageCurrentValue) |             // Migrate to Android per-app language settings | ||||||
|                         ); |             prefs.edit().remove(appLanguageKey).apply(); | ||||||
|                     } catch (final RuntimeException e) { |             if (!appLanguageCurrentValue.equals(appLanguageDefaultValue)) { | ||||||
|                         Log.e(TAG, "Error migrating to Android 13+ per-app language settings"); |                 try { | ||||||
|                     } |                     AppCompatDelegate.setApplicationLocales( | ||||||
|  |                             LocaleListCompat.forLanguageTags(appLanguageCurrentValue) | ||||||
|  |                     ); | ||||||
|  |                 } catch (final RuntimeException e) { | ||||||
|  |                     Log.e(TAG, "Error migrating to Android 13+ per-app language settings"); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Miles Krell
					Miles Krell