mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2025-10-03 09:49:21 +02:00
Migrate from pre-Android 13 app language pref
This commit is contained in:
parent
87693a2ad1
commit
3532ac96b4
1 changed files with 19 additions and 0 deletions
|
@ -3,11 +3,14 @@ package org.schabi.newpipe;
|
|||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.app.NotificationChannelCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.jakewharton.processphoenix.ProcessPhoenix;
|
||||
|
@ -122,6 +125,22 @@ public class App extends Application {
|
|||
configureRxJavaErrorHandler();
|
||||
|
||||
YoutubeStreamExtractor.setPoTokenProvider(PoTokenProviderImpl.INSTANCE);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
final String appLanguageKey = getString(R.string.app_language_key);
|
||||
if (prefs.contains(appLanguageKey)) {
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue