From 2374f8b4c9801abd2a8184ced0ab5e1d2e3e5455 Mon Sep 17 00:00:00 2001 From: Julian Dehm Date: Wed, 27 Mar 2019 19:15:22 +0100 Subject: [PATCH] address review --- .../briar/android/BriarApplicationImpl.java | 2 +- .../briarproject/briar/android/Localizer.java | 21 +++++++++++++------ .../android/settings/SettingsFragment.java | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/briar-android/src/main/java/org/briarproject/briar/android/BriarApplicationImpl.java b/briar-android/src/main/java/org/briarproject/briar/android/BriarApplicationImpl.java index 40edc6079..f5ea3c8ba 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/BriarApplicationImpl.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/BriarApplicationImpl.java @@ -106,7 +106,7 @@ public class BriarApplicationImpl extends Application public void onConfigurationChanged(@NonNull Configuration newConfig) { super.onConfigurationChanged(newConfig); Localizer.getInstance() - .applicationConfigurationChanged(this); + .applicationConfigurationChanged(this, newConfig); } private void setTheme(Context ctx, SharedPreferences prefs) { diff --git a/briar-android/src/main/java/org/briarproject/briar/android/Localizer.java b/briar-android/src/main/java/org/briarproject/briar/android/Localizer.java index f36e1ff24..44729bad7 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/Localizer.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/Localizer.java @@ -119,20 +119,29 @@ public class Localizer { Resources.getSystem().getConfiguration(); updateConfiguration(systemConfiguration, locale); // DateUtils uses the system resources, so we need to update them too. + //noinspection deprecation Resources.getSystem().updateConfiguration(systemConfiguration, Resources.getSystem().getDisplayMetrics()); } - public void applicationConfigurationChanged(Context appContext) { + public void applicationConfigurationChanged(Context appContext, + Configuration newConfig) { + if (SDK_INT >= 24) { + if (newConfig.getLocales().get(0) == locale) return; + } else { + if (newConfig.locale == locale) return; + } setLocaleAndSystemConfiguration(locale); if (SDK_INT < 17) setLocaleLegacy(appContext); } - // Indicates whether the language represented by locale - // should be offered to the user on this device. - // * Android doesn't pick up Asturian on API < 21 - // * Android can't render Devanagari characters on API 15. - // * RTL languages are supported since API >= 17 + /** + * Indicates whether the language represented by locale + * should be offered to the user on this device. + * * Android doesn't pick up Asturian on API < 21 + * * Android can't render Devanagari characters on API 15. + * * RTL languages are supported since API >= 17 + */ public static boolean isLocaleSupported(Locale locale) { if (SDK_INT >= 21) return true; if (locale.getLanguage().equals("ast")) return false; diff --git a/briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsFragment.java index b89f56a7b..e3ce3e511 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsFragment.java @@ -301,7 +301,7 @@ public class SettingsFragment extends PreferenceFragmentCompat continue; } String nativeName; - // Unsupported languages won't be translated to their native name. + // Unknown languages won't be translated to their native name. if (locale.getLanguage().equals("ast")) { nativeName = "Asturianu"; } else if (locale.getLanguage().equals("oc")) {