pair = LocaleManager
+ .createSortedLanguageDisplayStrings(mLanguagePref.getEntryValues(), LocaleManager.languageLocale(null));
if (pair != null) {
String[] sortedEntries = pair.first;
String[] sortedValues = pair.second;
mLanguagePref.setEntries(sortedEntries);
mLanguagePref.setEntryValues(sortedValues);
- mLanguagePref.setDetails(WPPrefUtils.createLanguageDetailDisplayStrings(sortedValues));
+ mLanguagePref.setDetails(LocaleManager.createLanguageDetailDisplayStrings(sortedValues));
}
}
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsInterface.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsInterface.java
index 6887e51b6f16..8a22062469b5 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsInterface.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsInterface.java
@@ -24,9 +24,9 @@
import org.wordpress.android.models.JetpackSettingsModel;
import org.wordpress.android.models.SiteSettingsModel;
import org.wordpress.android.util.LanguageUtils;
+import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.SiteUtils;
import org.wordpress.android.util.StringUtils;
-import org.wordpress.android.util.WPPrefUtils;
import java.util.ArrayList;
import java.util.HashMap;
@@ -218,7 +218,7 @@ protected SiteSettingsInterface(Context host, SiteModel site, SiteSettingsListen
mRemoteSettings = new SiteSettingsModel();
mJpSettings = new JetpackSettingsModel();
mRemoteJpSettings = new JetpackSettingsModel();
- mLanguageCodes = WPPrefUtils.generateLanguageMap(host);
+ mLanguageCodes = LocaleManager.generateLanguageMap(host);
}
@Override
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/views/ReaderSiteHeaderView.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/views/ReaderSiteHeaderView.java
index 74c7268e5019..98d1bf0678df 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/reader/views/ReaderSiteHeaderView.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/views/ReaderSiteHeaderView.java
@@ -129,17 +129,10 @@ private void showBlogInfo(ReaderBlog blogInfo) {
txtDescription.setVisibility(View.GONE);
}
- try {
- txtFollowCount.setText(String.format(
- LocaleManager.getSafeLocale(getContext()),
- getContext().getString(R.string.reader_label_follow_count),
- blogInfo.numSubscribers));
- } catch (ArithmeticException exception) {
- txtFollowCount.setText(String.format(
- LocaleManager.getSafeLocale(getContext()),
- getContext().getString(R.string.reader_label_follow_count),
- blogInfo.numSubscribers));
- }
+ txtFollowCount.setText(String.format(
+ LocaleManager.getSafeLocale(getContext()),
+ getContext().getString(R.string.reader_label_follow_count),
+ blogInfo.numSubscribers));
if (!mAccountStore.hasAccessToken()) {
mFollowButton.setVisibility(View.GONE);
diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
index 025dfabc8ceb..a5efa6a48576 100644
--- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
+++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
@@ -7,8 +7,16 @@
import android.content.res.Resources;
import android.os.Build;
import android.preference.PreferenceManager;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
+import android.util.Pair;
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Locale;
+import java.util.Map;
import javax.annotation.Nullable;
@@ -18,6 +26,24 @@
* android version.
*/
public abstract class LocaleManager {
+ /**
+ * Length of a {@link String} (representing a language code) when there is no region included.
+ * For example: "en" contains no region, "en_US" contains a region (US)
+ *
+ * Used to parse a language code {@link String} when creating a {@link Locale}.
+ */
+ private static final int NO_REGION_LANG_CODE_LEN = 2;
+
+ /**
+ * Index of a language code {@link String} where the region code begins. The language code
+ * format is cc_rr, where cc is the country code (e.g. en, es, az) and rr is the region code
+ * (e.g. us, au, gb).
+ */
+ private static final int REGION_SUBSTRING_INDEX = 3;
+
+ /**
+ * Key used for saving the language selection to shared preferences.
+ */
private static final String LANGUAGE_KEY = "language-pref";
/**
@@ -35,7 +61,7 @@ public static Context setLocale(Context context) {
* @param language The 2-letter language code (example "en") to switch to
*/
public static Context setNewLocale(Context context, String language) {
- Locale newLocale = WPPrefUtils.languageLocale(language);
+ Locale newLocale = languageLocale(language);
if (Locale.getDefault().toString().equals(newLocale.toString())) {
removePersistedLanguage(context);
@@ -50,9 +76,9 @@ public static Context setNewLocale(Context context, String language) {
* @param language The language to compare
* @return True if the languages are the same, else false
*/
- public static boolean isDifferentLanguage(String language) {
- Locale newLocale = WPPrefUtils.languageLocale(language);
- return !Locale.getDefault().getLanguage().equals(newLocale.getLanguage());
+ public static boolean isSameLanguage(@NonNull String language) {
+ Locale newLocale = languageLocale(language);
+ return Locale.getDefault().getLanguage().equals(newLocale.getLanguage());
}
/**
@@ -143,9 +169,111 @@ public static Locale getSafeLocale(@Nullable Context context) {
}
if (Build.VERSION.SDK_INT >= 24) {
- return WPPrefUtils.languageLocale(baseLocale.getLanguage());
+ return languageLocale(baseLocale.getLanguage());
} else {
return baseLocale;
}
}
+
+ /**
+ * Gets a locale for the given language code.
+ * @param languageCode The 2-letter language code (example "en"). If null or empty will return
+ * the current default locale.
+ */
+ public static Locale languageLocale(@Nullable String languageCode) {
+ if (TextUtils.isEmpty(languageCode)) {
+ return Locale.getDefault();
+ }
+
+ if (languageCode.length() > NO_REGION_LANG_CODE_LEN) {
+ return new Locale(languageCode.substring(0, NO_REGION_LANG_CODE_LEN),
+ languageCode.substring(REGION_SUBSTRING_INDEX));
+ }
+
+ return new Locale(languageCode);
+ }
+
+ /**
+ * Creates a map from language codes to WordPress language IDs.
+ */
+ public static Map generateLanguageMap(Context context) {
+ String[] languageIds = context.getResources().getStringArray(org.wordpress.android.R.array.lang_ids);
+ String[] languageCodes = context.getResources().getStringArray(org.wordpress.android.R.array.language_codes);
+
+ Map languageMap = new HashMap<>();
+ for (int i = 0; i < languageIds.length && i < languageCodes.length; ++i) {
+ languageMap.put(languageCodes[i], languageIds[i]);
+ }
+
+ return languageMap;
+ }
+
+ /**
+ * Generates display strings for given language codes. Used as entries in language preference.
+ */
+ @android.support.annotation.Nullable
+ public static Pair createSortedLanguageDisplayStrings(CharSequence[] languageCodes,
+ Locale locale) {
+ if (languageCodes == null || languageCodes.length < 1) {
+ return null;
+ }
+
+ ArrayList entryStrings = new ArrayList<>(languageCodes.length);
+ for (int i = 0; i < languageCodes.length; ++i) {
+ // "__" is used to sort the language code with the display string so both arrays are sorted at the same time
+ entryStrings.add(i, StringUtils.capitalize(
+ getLanguageString(languageCodes[i].toString(), locale)) + "__" + languageCodes[i]);
+ }
+
+ Collections.sort(entryStrings, Collator.getInstance(locale));
+
+ String[] sortedEntries = new String[languageCodes.length];
+ String[] sortedValues = new String[languageCodes.length];
+
+ for (int i = 0; i < entryStrings.size(); ++i) {
+ // now, we can split the sorted array to extract the display string and the language code
+ String[] split = entryStrings.get(i).split("__");
+ sortedEntries[i] = split[0];
+ sortedValues[i] = split[1];
+ }
+
+ return new Pair<>(sortedEntries, sortedValues);
+ }
+
+ /**
+ * Generates detail display strings in the currently selected locale. Used as detail text
+ * in language preference dialog.
+ */
+ @android.support.annotation.Nullable
+ public static String[] createLanguageDetailDisplayStrings(CharSequence[] languageCodes) {
+ if (languageCodes == null || languageCodes.length < 1) {
+ return null;
+ }
+
+ String[] detailStrings = new String[languageCodes.length];
+ for (int i = 0; i < languageCodes.length; ++i) {
+ detailStrings[i] = StringUtils.capitalize(getLanguageString(
+ languageCodes[i].toString(), languageLocale(languageCodes[i].toString())));
+ }
+
+ return detailStrings;
+ }
+
+ /**
+ * Return a non-null display string for a given language code.
+ */
+ public static String getLanguageString(String languageCode, Locale displayLocale) {
+ if (languageCode == null || languageCode.length() < 2 || languageCode.length() > 6) {
+ return "";
+ }
+
+ Locale languageLocale = languageLocale(languageCode);
+ String displayLanguage = StringUtils.capitalize(languageLocale.getDisplayLanguage(displayLocale));
+ String displayCountry = languageLocale.getDisplayCountry(displayLocale);
+
+ if (!TextUtils.isEmpty(displayCountry)) {
+ return displayLanguage + " (" + displayCountry + ")";
+ }
+ return displayLanguage;
+ }
}
diff --git a/WordPress/src/main/java/org/wordpress/android/util/WPPrefUtils.java b/WordPress/src/main/java/org/wordpress/android/util/WPPrefUtils.java
index ab26e0244764..29c8496785f4 100644
--- a/WordPress/src/main/java/org/wordpress/android/util/WPPrefUtils.java
+++ b/WordPress/src/main/java/org/wordpress/android/util/WPPrefUtils.java
@@ -1,46 +1,20 @@
package org.wordpress.android.util;
-import android.content.Context;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
-import android.support.annotation.Nullable;
-import android.text.TextUtils;
-import android.util.Pair;
import android.util.TypedValue;
import android.widget.EditText;
import android.widget.TextView;
import org.wordpress.android.R;
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
/**
* Design guidelines for Calypso-styled Site Settings (and likely other screens)
*/
public class WPPrefUtils {
- /**
- * Length of a {@link String} (representing a language code) when there is no region included.
- * For example: "en" contains no region, "en_US" contains a region (US)
- *
- * Used to parse a language code {@link String} when creating a {@link Locale}.
- */
- private static final int NO_REGION_LANG_CODE_LEN = 2;
-
- /**
- * Index of a language code {@link String} where the region code begins. The language code
- * format is cc_rr, where cc is the country code (e.g. en, es, az) and rr is the region code
- * (e.g. us, au, gb).
- */
- private static final int REGION_SUBSTRING_INDEX = 3;
-
/**
* Gets a preference and sets the {@link android.preference.Preference.OnPreferenceChangeListener}.
*/
@@ -186,104 +160,4 @@ public static void setTextViewAttributes(TextView textView, int size, int colorR
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
textView.setTextColor(textView.getResources().getColor(colorRes));
}
-
- /**
- * Gets a locale for the given language code.
- */
- public static Locale languageLocale(String languageCode) {
- if (TextUtils.isEmpty(languageCode)) {
- return Locale.getDefault();
- }
-
- if (languageCode.length() > NO_REGION_LANG_CODE_LEN) {
- return new Locale(languageCode.substring(0, NO_REGION_LANG_CODE_LEN),
- languageCode.substring(REGION_SUBSTRING_INDEX));
- }
-
- return new Locale(languageCode);
- }
-
- /**
- * Creates a map from language codes to WordPress language IDs.
- */
- public static Map generateLanguageMap(Context context) {
- String[] languageIds = context.getResources().getStringArray(R.array.lang_ids);
- String[] languageCodes = context.getResources().getStringArray(R.array.language_codes);
-
- Map languageMap = new HashMap<>();
- for (int i = 0; i < languageIds.length && i < languageCodes.length; ++i) {
- languageMap.put(languageCodes[i], languageIds[i]);
- }
-
- return languageMap;
- }
-
- /**
- * Generates display strings for given language codes. Used as entries in language preference.
- */
- @Nullable
- public static Pair createSortedLanguageDisplayStrings(CharSequence[] languageCodes,
- Locale locale) {
- if (languageCodes == null || languageCodes.length < 1) {
- return null;
- }
-
- ArrayList entryStrings = new ArrayList<>(languageCodes.length);
- for (int i = 0; i < languageCodes.length; ++i) {
- // "__" is used to sort the language code with the display string so both arrays are sorted at the same time
- entryStrings.add(i, StringUtils.capitalize(
- getLanguageString(languageCodes[i].toString(), locale)) + "__" + languageCodes[i]);
- }
-
- Collections.sort(entryStrings, Collator.getInstance(locale));
-
- String[] sortedEntries = new String[languageCodes.length];
- String[] sortedValues = new String[languageCodes.length];
-
- for (int i = 0; i < entryStrings.size(); ++i) {
- // now, we can split the sorted array to extract the display string and the language code
- String[] split = entryStrings.get(i).split("__");
- sortedEntries[i] = split[0];
- sortedValues[i] = split[1];
- }
-
- return new Pair<>(sortedEntries, sortedValues);
- }
-
- /**
- * Generates detail display strings in the currently selected locale. Used as detail text
- * in language preference dialog.
- */
- @Nullable
- public static String[] createLanguageDetailDisplayStrings(CharSequence[] languageCodes) {
- if (languageCodes == null || languageCodes.length < 1) {
- return null;
- }
-
- String[] detailStrings = new String[languageCodes.length];
- for (int i = 0; i < languageCodes.length; ++i) {
- detailStrings[i] = StringUtils.capitalize(getLanguageString(
- languageCodes[i].toString(), WPPrefUtils.languageLocale(languageCodes[i].toString())));
- }
-
- return detailStrings;
- }
-
- /**
- * Return a non-null display string for a given language code.
- */
- public static String getLanguageString(String languageCode, Locale displayLocale) {
- if (languageCode == null || languageCode.length() < 2 || languageCode.length() > 6) {
- return "";
- }
-
- Locale languageLocale = WPPrefUtils.languageLocale(languageCode);
- String displayLanguage = StringUtils.capitalize(languageLocale.getDisplayLanguage(displayLocale));
- String displayCountry = languageLocale.getDisplayCountry(displayLocale);
-
- if (!TextUtils.isEmpty(displayCountry)) {
- return displayLanguage + " (" + displayCountry + ")";
- }
- return displayLanguage;
- }
}
From abd0dcc297fc036f0d298e3d04383cd5821d4b0f Mon Sep 17 00:00:00 2001
From: Amanda Riu
Date: Fri, 9 Mar 2018 14:39:07 -0700
Subject: [PATCH 09/12] Fix broken methods getCurrentDeviceLanguage(context),
getCurrentDeviceLanguageCode(context) and deprecate method signatures
Methods stopped working as expected as of API 25. Context argument is no longer needed, but may still be used by other libraries so deprecated those method signatures and added new updated method signatures.
---
.../wordpress/android/util/LanguageUtils.java | 38 ++++++++++++++-----
1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/LanguageUtils.java b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/LanguageUtils.java
index c043b2f0d97c..586c1e18b553 100644
--- a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/LanguageUtils.java
+++ b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/LanguageUtils.java
@@ -1,6 +1,7 @@
package org.wordpress.android.util;
import android.content.Context;
+import android.support.annotation.Nullable;
import java.util.Locale;
@@ -8,17 +9,35 @@
* Methods for dealing with i18n messages
*/
public class LanguageUtils {
- public static Locale getCurrentDeviceLanguage(Context context) {
- // better use getConfiguration as it has the latest locale configuration change.
- // Otherwise Locale.getDefault().getLanguage() gets
- // the config upon application launch.
- Locale deviceLocale = context != null ? context.getResources().getConfiguration().locale : Locale.getDefault();
- return deviceLocale;
+ /**
+ * @deprecated Use {@link #getCurrentDeviceLanguage()}. As of API 25, setting the locale by updating the
+ * configuration on the resources object was deprecated, so this method stopped working for newer versions
+ * of Android. The current active locale should always be set in {@link Locale#getDefault()}. When manually
+ * setting the active locale, the developer should set it in {@link Locale#setDefault(Locale)}.
+ */
+ @SuppressWarnings("DeprecatedIsStillUsed")
+ @Deprecated
+ public static Locale getCurrentDeviceLanguage(@Nullable Context context) {
+ return getCurrentDeviceLanguage();
+ }
+
+ @SuppressWarnings("WeakerAccess")
+ public static Locale getCurrentDeviceLanguage() {
+ return Locale.getDefault();
+ }
+
+ /**
+ * @deprecated Use {@link #getCurrentDeviceLanguageCode()}.
+ */
+ @SuppressWarnings("WeakerAccess,DeprecatedIsStillUsed")
+ @Deprecated
+ public static String getCurrentDeviceLanguageCode(@Nullable Context context) {
+ return getCurrentDeviceLanguageCode();
}
- public static String getCurrentDeviceLanguageCode(Context context) {
- String deviceLanguageCode = getCurrentDeviceLanguage(context).toString();
- return deviceLanguageCode;
+ @SuppressWarnings("WeakerAccess")
+ public static String getCurrentDeviceLanguageCode() {
+ return getCurrentDeviceLanguage().toString();
}
public static String getPatchedCurrentDeviceLanguage(Context context) {
@@ -28,6 +47,7 @@ public static String getPatchedCurrentDeviceLanguage(Context context) {
/**
* Patches a deviceLanguageCode if any of deprecated values iw, id, or yi
*/
+ @SuppressWarnings("WeakerAccess")
public static String patchDeviceLanguageCode(String deviceLanguageCode) {
String patchedCode = deviceLanguageCode;
/*
From 123e50e89f36ed40e6ddea8282999fe6567f6bc3 Mon Sep 17 00:00:00 2001
From: Amanda Riu
Date: Fri, 9 Mar 2018 14:59:59 -0700
Subject: [PATCH 10/12] Remove abstract keyword
---
.../src/main/java/org/wordpress/android/util/LocaleManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
index a5efa6a48576..07d4e0adb8c7 100644
--- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
+++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
@@ -25,7 +25,7 @@
* selected language is properly saved and resources appropriately updated for the
* android version.
*/
-public abstract class LocaleManager {
+public class LocaleManager {
/**
* Length of a {@link String} (representing a language code) when there is no region included.
* For example: "en" contains no region, "en_US" contains a region (US)
From 5217f882943e70b5c56144935ec1fcda9d76d116 Mon Sep 17 00:00:00 2001
From: Amanda Riu
Date: Fri, 9 Mar 2018 15:26:19 -0700
Subject: [PATCH 11/12] No need to return the context from
LocaleManager.setNewLocale(...). Updated login in method to just exit it the
new language is the same as the current language.
---
.../android/ui/prefs/AppSettingsFragment.java | 5 ++---
.../org/wordpress/android/util/LocaleManager.java | 13 +++++--------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java
index 91f343d8795a..3f9f2462bbf2 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java
@@ -1,7 +1,6 @@
package org.wordpress.android.ui.prefs;
import android.content.ActivityNotFoundException;
-import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@@ -276,13 +275,13 @@ private void changeLanguage(String languageCode) {
return;
}
- Context newContext = LocaleManager.setNewLocale(WordPress.getContext(), languageCode);
+ LocaleManager.setNewLocale(WordPress.getContext(), languageCode);
updateLanguagePreference(languageCode);
// Track language change on Analytics because we have both the device language and app selected language
// data in Tracks metadata.
Map properties = new HashMap<>();
- properties.put("app_locale", newContext.getResources().getConfiguration().locale.toString());
+ properties.put("app_locale", Locale.getDefault());
AnalyticsTracker.track(Stat.ACCOUNT_SETTINGS_LANGUAGE_CHANGED, properties);
// Language is now part of metadata, so we need to refresh them
diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
index 07d4e0adb8c7..dac6b52df335 100644
--- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
+++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
@@ -60,15 +60,12 @@ public static Context setLocale(Context context) {
* @param context The current context
* @param language The 2-letter language code (example "en") to switch to
*/
- public static Context setNewLocale(Context context, String language) {
- Locale newLocale = languageLocale(language);
-
- if (Locale.getDefault().toString().equals(newLocale.toString())) {
- removePersistedLanguage(context);
- } else {
- saveLanguageToPref(context, language);
+ public static void setNewLocale(Context context, String language) {
+ if (isSameLanguage(language)) {
+ return;
}
- return updateResources(context, language);
+ saveLanguageToPref(context, language);
+ updateResources(context, language);
}
/**
From cf64885d56271abed6d1fd19845083630193006c Mon Sep 17 00:00:00 2001
From: Amanda Riu
Date: Fri, 9 Mar 2018 15:43:31 -0700
Subject: [PATCH 12/12] Remove unused method and add proper @Nullable import.
---
.../wordpress/android/util/LocaleManager.java | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
index dac6b52df335..20dac9b93581 100644
--- a/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
+++ b/WordPress/src/main/java/org/wordpress/android/util/LocaleManager.java
@@ -8,6 +8,7 @@
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Pair;
@@ -18,8 +19,6 @@
import java.util.Locale;
import java.util.Map;
-import javax.annotation.Nullable;
-
/**
* Helper class for working with localized strings. Ensures updates to the users
* selected language is properly saved and resources appropriately updated for the
@@ -104,18 +103,6 @@ private static void saveLanguageToPref(Context context, String language) {
prefs.edit().putString(LANGUAGE_KEY, language).commit();
}
- /**
- * Remove any saved custom language selection from SharedPreferences.
- * Use commit() instead of apply() to ensure the language preference is saved instantly
- * as the app may be restarted immediately.
- * @param context The current context
- */
- @SuppressLint("ApplySharedPref")
- private static void removePersistedLanguage(Context context) {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- prefs.edit().remove(LANGUAGE_KEY).commit();
- }
-
/**
* Update resources for the current session.
*
@@ -208,7 +195,7 @@ public static Map generateLanguageMap(Context context) {
/**
* Generates display strings for given language codes. Used as entries in language preference.
*/
- @android.support.annotation.Nullable
+ @Nullable
public static Pair createSortedLanguageDisplayStrings(CharSequence[] languageCodes,
Locale locale) {
if (languageCodes == null || languageCodes.length < 1) {
@@ -241,7 +228,7 @@ public static Pair createSortedLanguageDisplayStrings(CharSe
* Generates detail display strings in the currently selected locale. Used as detail text
* in language preference dialog.
*/
- @android.support.annotation.Nullable
+ @Nullable
public static String[] createLanguageDetailDisplayStrings(CharSequence[] languageCodes) {
if (languageCodes == null || languageCodes.length < 1) {
return null;