address review

This commit is contained in:
Julian Dehm
2019-03-27 19:15:22 +01:00
committed by akwizgran
parent 5b77f28ce0
commit 2374f8b4c9
3 changed files with 17 additions and 8 deletions

View File

@@ -106,7 +106,7 @@ public class BriarApplicationImpl extends Application
public void onConfigurationChanged(@NonNull Configuration newConfig) { public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
Localizer.getInstance() Localizer.getInstance()
.applicationConfigurationChanged(this); .applicationConfigurationChanged(this, newConfig);
} }
private void setTheme(Context ctx, SharedPreferences prefs) { private void setTheme(Context ctx, SharedPreferences prefs) {

View File

@@ -119,20 +119,29 @@ public class Localizer {
Resources.getSystem().getConfiguration(); Resources.getSystem().getConfiguration();
updateConfiguration(systemConfiguration, locale); updateConfiguration(systemConfiguration, locale);
// DateUtils uses the system resources, so we need to update them too. // DateUtils uses the system resources, so we need to update them too.
//noinspection deprecation
Resources.getSystem().updateConfiguration(systemConfiguration, Resources.getSystem().updateConfiguration(systemConfiguration,
Resources.getSystem().getDisplayMetrics()); 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); setLocaleAndSystemConfiguration(locale);
if (SDK_INT < 17) setLocaleLegacy(appContext); if (SDK_INT < 17) setLocaleLegacy(appContext);
} }
// Indicates whether the language represented by locale /**
// should be offered to the user on this device. * Indicates whether the language represented by locale
// * Android doesn't pick up Asturian on API < 21 * should be offered to the user on this device.
// * Android can't render Devanagari characters on API 15. * * Android doesn't pick up Asturian on API < 21
// * RTL languages are supported since API >= 17 * * Android can't render Devanagari characters on API 15.
* * RTL languages are supported since API >= 17
*/
public static boolean isLocaleSupported(Locale locale) { public static boolean isLocaleSupported(Locale locale) {
if (SDK_INT >= 21) return true; if (SDK_INT >= 21) return true;
if (locale.getLanguage().equals("ast")) return false; if (locale.getLanguage().equals("ast")) return false;

View File

@@ -301,7 +301,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
continue; continue;
} }
String nativeName; 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")) { if (locale.getLanguage().equals("ast")) {
nativeName = "Asturianu"; nativeName = "Asturianu";
} else if (locale.getLanguage().equals("oc")) { } else if (locale.getLanguage().equals("oc")) {