Loading core/java/com/android/internal/app/LocalePicker.java +40 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.res.Resources; import android.os.Bundle; import android.os.RemoteException; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; Loading @@ -41,6 +42,7 @@ import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.ArrayList; import java.util.Arrays; public class LocalePicker extends ListFragment { private static final String TAG = "LocalePicker"; Loading Loading @@ -83,12 +85,28 @@ public class LocalePicker extends ListFragment { } } public static ArrayList<String> getLocaleArray(String[] locales, Resources resources) { String localeCodes = resources.getString(R.string.locale_codes); String[] localeCodesArray = null; if (localeCodes != null && !TextUtils.isEmpty(localeCodes.trim())) { localeCodes = localeCodes.replace('_', '-'); // ICU use "fil" instead of "tl" localeCodes = localeCodes.replaceAll("tl-", "fil-"); localeCodesArray = localeCodes.split(","); } ArrayList<String> localeList = new ArrayList<String>( Arrays.asList((localeCodesArray == null || localeCodesArray.length == 0) ? locales : localeCodesArray)); return localeList; } public static List<LocaleInfo> getAllAssetLocales(Context context, boolean isInDeveloperMode) { final Resources resources = context.getResources(); final String[] locales = Resources.getSystem().getAssets().getLocales(); List<String> localeList = new ArrayList<String>(locales.length); Collections.addAll(localeList, locales); String[] locales = Resources.getSystem().getAssets().getLocales(); // Check the locale_codes if the locales list is customized in data package overlay. // If locale_codes is customized, use the customized list instead of built-in locales. ArrayList<String> localeList = getLocaleArray(locales, resources); // Don't show the pseudolocales unless we're in developer mode. http://b/17190407. if (!isInDeveloperMode) { Loading Loading @@ -142,6 +160,25 @@ public class LocalePicker extends ListFragment { } } } // If customized to true, always show the country name boolean shallShowCountry = resources.getBoolean(R.bool.config_display_country_for_locale_codes); if (shallShowCountry) { for (LocaleInfo locale : localeInfos) { Locale l = locale.locale; String languageName = toTitleCase(l.getDisplayLanguage(l)); String displayName = toTitleCase(getDisplayName(l, specialLocaleCodes, specialLocaleNames)); if (locale.label.equals(languageName)) { if (displayName.equals(languageName)) { // Fix some cases where getDisplayName() not works(e.g. ar-EG). displayName = toTitleCase(String.format("%s (%s)", languageName, l.getDisplayCountry(l))); } locale.label = displayName; } } } Collections.sort(localeInfos); return localeInfos; Loading core/res/res/values/customize.xml +6 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,12 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <resources> <!-- Used in LocalePicker, default language must be contained --> <string name="locale_codes" translatable="false"></string> <!-- If configure to true, always show the country(locale) name in the language lable --> <bool name="config_display_country_for_locale_codes">false</bool> <!--Fully qualified class name of the plugin which would be dynamically loaded by TelephonyPluginDelegate--> <java-symbol type="string" name="telephony_plugin_class_name" /> Loading core/res/res/values/symbols.xml +4 −0 Original line number Diff line number Diff line Loading @@ -2331,6 +2331,10 @@ <java-symbol type="drawable" name="platlogo_m" /> <!-- language/locale picker extention feature --> <java-symbol type="string" name="locale_codes" /> <java-symbol type="bool" name="config_display_country_for_locale_codes" /> <!-- config softap extention feature --> <java-symbol type="bool" name="config_softap_extention" /> Loading Loading
core/java/com/android/internal/app/LocalePicker.java +40 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.res.Resources; import android.os.Bundle; import android.os.RemoteException; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; Loading @@ -41,6 +42,7 @@ import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.ArrayList; import java.util.Arrays; public class LocalePicker extends ListFragment { private static final String TAG = "LocalePicker"; Loading Loading @@ -83,12 +85,28 @@ public class LocalePicker extends ListFragment { } } public static ArrayList<String> getLocaleArray(String[] locales, Resources resources) { String localeCodes = resources.getString(R.string.locale_codes); String[] localeCodesArray = null; if (localeCodes != null && !TextUtils.isEmpty(localeCodes.trim())) { localeCodes = localeCodes.replace('_', '-'); // ICU use "fil" instead of "tl" localeCodes = localeCodes.replaceAll("tl-", "fil-"); localeCodesArray = localeCodes.split(","); } ArrayList<String> localeList = new ArrayList<String>( Arrays.asList((localeCodesArray == null || localeCodesArray.length == 0) ? locales : localeCodesArray)); return localeList; } public static List<LocaleInfo> getAllAssetLocales(Context context, boolean isInDeveloperMode) { final Resources resources = context.getResources(); final String[] locales = Resources.getSystem().getAssets().getLocales(); List<String> localeList = new ArrayList<String>(locales.length); Collections.addAll(localeList, locales); String[] locales = Resources.getSystem().getAssets().getLocales(); // Check the locale_codes if the locales list is customized in data package overlay. // If locale_codes is customized, use the customized list instead of built-in locales. ArrayList<String> localeList = getLocaleArray(locales, resources); // Don't show the pseudolocales unless we're in developer mode. http://b/17190407. if (!isInDeveloperMode) { Loading Loading @@ -142,6 +160,25 @@ public class LocalePicker extends ListFragment { } } } // If customized to true, always show the country name boolean shallShowCountry = resources.getBoolean(R.bool.config_display_country_for_locale_codes); if (shallShowCountry) { for (LocaleInfo locale : localeInfos) { Locale l = locale.locale; String languageName = toTitleCase(l.getDisplayLanguage(l)); String displayName = toTitleCase(getDisplayName(l, specialLocaleCodes, specialLocaleNames)); if (locale.label.equals(languageName)) { if (displayName.equals(languageName)) { // Fix some cases where getDisplayName() not works(e.g. ar-EG). displayName = toTitleCase(String.format("%s (%s)", languageName, l.getDisplayCountry(l))); } locale.label = displayName; } } } Collections.sort(localeInfos); return localeInfos; Loading
core/res/res/values/customize.xml +6 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,12 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <resources> <!-- Used in LocalePicker, default language must be contained --> <string name="locale_codes" translatable="false"></string> <!-- If configure to true, always show the country(locale) name in the language lable --> <bool name="config_display_country_for_locale_codes">false</bool> <!--Fully qualified class name of the plugin which would be dynamically loaded by TelephonyPluginDelegate--> <java-symbol type="string" name="telephony_plugin_class_name" /> Loading
core/res/res/values/symbols.xml +4 −0 Original line number Diff line number Diff line Loading @@ -2331,6 +2331,10 @@ <java-symbol type="drawable" name="platlogo_m" /> <!-- language/locale picker extention feature --> <java-symbol type="string" name="locale_codes" /> <java-symbol type="bool" name="config_display_country_for_locale_codes" /> <!-- config softap extention feature --> <java-symbol type="bool" name="config_softap_extention" /> Loading