diff options
author | Narayan Kamath <narayan@google.com> | 2014-07-14 16:28:24 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-07-14 16:29:22 +0100 |
commit | 9e6d9d4c812d01ac07180c5d6ab64c36fb9b2aa7 (patch) | |
tree | 2a8bbc9502dc09dcb3535da9167f98e0e264c189 | |
parent | 7850f95dc55c4e4801cf145c42a1bc98b49a87d6 (diff) | |
download | base-9e6d9d4c812d01ac07180c5d6ab64c36fb9b2aa7.tar.gz |
Add an internal API to get all asset locales.
This will allow us to not copy paste this code verbatim into
bundled apps.
bug: 10090157
Change-Id: I008dc683ecbef2ad8b7a26968cb3cbda7e5a8388
-rw-r--r-- | core/java/com/android/internal/app/LocalePicker.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/core/java/com/android/internal/app/LocalePicker.java b/core/java/com/android/internal/app/LocalePicker.java index f5c498a8fbc9..229df8f23293 100644 --- a/core/java/com/android/internal/app/LocalePicker.java +++ b/core/java/com/android/internal/app/LocalePicker.java @@ -36,7 +36,6 @@ import android.widget.ListView; import android.widget.TextView; import java.text.Collator; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Locale; @@ -106,22 +105,21 @@ public class LocalePicker extends ListFragment { return constructAdapter(context, layoutId, fieldId, false /* disable pseudolocales */); } - public static ArrayAdapter<LocaleInfo> constructAdapter(Context context, - final int layoutId, final int fieldId, final boolean isInDeveloperMode) { + public static List<LocaleInfo> getAllAssetLocales(Context context, boolean isInDeveloperMode) { final Resources resources = context.getResources(); - String[] locales = Resources.getSystem().getAssets().getLocales(); + final String[] locales = Resources.getSystem().getAssets().getLocales(); List<String> localeList = new ArrayList<String>(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"); - * } - */ + /** - TODO: Enable when zz_ZY Pseudolocale is complete + * if (!localeList.contains("zz_ZY")) { + * localeList.add("zz_ZY"); + * } + */ } Collections.sort(localeList); @@ -179,6 +177,13 @@ public class LocalePicker extends ListFragment { } Collections.sort(localeInfos); + return localeInfos; + } + + public static ArrayAdapter<LocaleInfo> constructAdapter(Context context, + final int layoutId, final int fieldId, final boolean isInDeveloperMode) { + final List<LocaleInfo> localeInfos = getAllAssetLocales(context, isInDeveloperMode); + final LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); return new ArrayAdapter<LocaleInfo>(context, layoutId, fieldId, localeInfos) { |