From dee5cde1ec3cca5235c397acdb217ddadaa7994f Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 22 Aug 2014 11:45:33 -0700 Subject: [PATCH] Don't show the pseudolocales unless we're in developer mode. The old zz_ZY and zz_ZZ pseudolocales are gone, replaced by ar_XB and en_XA. The existing check for "developer mode" wasn't working, and now the pseudolocales are there by default, we want to _remove_ them if we're not in developer mode rather than add them if we are in developer mode. Bug: 17190407 Change-Id: I6ee6eba53f5b816ef8e0d1768c94cd3484a196b5 --- .../android/internal/app/LocalePicker.java | 62 ++++++------------- 1 file changed, 19 insertions(+), 43 deletions(-) diff --git a/core/java/com/android/internal/app/LocalePicker.java b/core/java/com/android/internal/app/LocalePicker.java index 229df8f23293d..1f0bb7676ce24 100644 --- a/core/java/com/android/internal/app/LocalePicker.java +++ b/core/java/com/android/internal/app/LocalePicker.java @@ -27,6 +27,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; import android.os.RemoteException; +import android.provider.Settings; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -50,10 +51,6 @@ public class LocalePicker extends ListFragment { public void onLocaleSelected(Locale locale); } - protected boolean isInDeveloperMode() { - return false; - } - LocaleSelectionListener mListener; // default to null public static class LocaleInfo implements Comparable { @@ -86,40 +83,17 @@ public class LocalePicker extends ListFragment { } } - /** - * Constructs an Adapter object containing Locale information. Content is sorted by - * {@link LocaleInfo#label}. - */ - public static ArrayAdapter constructAdapter(Context context) { - return constructAdapter(context, false /* disable pesudolocales */); - } - - public static ArrayAdapter constructAdapter(Context context, - final boolean isInDeveloperMode) { - return constructAdapter(context, R.layout.locale_picker_item, R.id.locale, - isInDeveloperMode); - } - - public static ArrayAdapter constructAdapter(Context context, - final int layoutId, final int fieldId) { - return constructAdapter(context, layoutId, fieldId, false /* disable pseudolocales */); - } - public static List getAllAssetLocales(Context context, boolean isInDeveloperMode) { final Resources resources = context.getResources(); final String[] locales = Resources.getSystem().getAssets().getLocales(); List localeList = new ArrayList(locales.length); Collections.addAll(localeList, locales); - if (isInDeveloperMode) { - if (!localeList.contains("zz_ZZ")) { - localeList.add("zz_ZZ"); - } - /** - TODO: Enable when zz_ZY Pseudolocale is complete - * if (!localeList.contains("zz_ZY")) { - * localeList.add("zz_ZY"); - * } - */ + + // Don't show the pseudolocales unless we're in developer mode. http://b/17190407. + if (!isInDeveloperMode) { + localeList.remove("ar-XB"); + localeList.remove("en-XA"); } Collections.sort(localeList); @@ -160,14 +134,7 @@ public class LocalePicker extends ListFragment { localeInfos.add(new LocaleInfo(toTitleCase( getDisplayName(l, specialLocaleCodes, specialLocaleNames)), l)); } else { - String displayName; - if (locale.equals("zz_ZZ")) { - displayName = "[Developer] Accented English"; - } else if (locale.equals("zz_ZY")) { - displayName = "[Developer] Fake Bi-Directional"; - } else { - displayName = toTitleCase(l.getDisplayLanguage(l)); - } + String displayName = toTitleCase(l.getDisplayLanguage(l)); if (DEBUG) { Log.v(TAG, "adding "+displayName); } @@ -180,8 +147,18 @@ public class LocalePicker extends ListFragment { return localeInfos; } + /** + * Constructs an Adapter object containing Locale information. Content is sorted by + * {@link LocaleInfo#label}. + */ + public static ArrayAdapter constructAdapter(Context context) { + return constructAdapter(context, R.layout.locale_picker_item, R.id.locale); + } + public static ArrayAdapter constructAdapter(Context context, - final int layoutId, final int fieldId, final boolean isInDeveloperMode) { + final int layoutId, final int fieldId) { + boolean isInDeveloperMode = Settings.Global.getInt(context.getContentResolver(), + Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0; final List localeInfos = getAllAssetLocales(context, isInDeveloperMode); final LayoutInflater inflater = @@ -232,8 +209,7 @@ public class LocalePicker extends ListFragment { @Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - final ArrayAdapter adapter = constructAdapter(getActivity(), - isInDeveloperMode()); + final ArrayAdapter adapter = constructAdapter(getActivity()); setListAdapter(adapter); }