Loading core/java/com/android/internal/app/LocalePicker.java +48 −7 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.util.LocaleList; import android.util.Log; import android.view.LayoutInflater; import android.view.View; Loading @@ -45,6 +46,7 @@ import java.util.ArrayList; public class LocalePicker extends ListFragment { private static final String TAG = "LocalePicker"; private static final boolean DEBUG = false; private static final String[] pseudoLocales = { "en-XA", "ar-XB" }; public static interface LocaleSelectionListener { // You can add any argument if you really need it... Loading @@ -57,7 +59,7 @@ public class LocalePicker extends ListFragment { static final Collator sCollator = Collator.getInstance(); String label; Locale locale; final Locale locale; public LocaleInfo(String label, Locale locale) { this.label = label; Loading @@ -83,17 +85,30 @@ public class LocalePicker extends ListFragment { } } public static String[] getSystemAssetLocales() { return Resources.getSystem().getAssets().getLocales(); } public static String[] getSupportedLocales(Context context) { return context.getResources().getStringArray(R.array.supported_locales); } public static String[] getPseudoLocales() { return pseudoLocales; } public static List<LocaleInfo> getAllAssetLocales(Context context, boolean isInDeveloperMode) { final Resources resources = context.getResources(); final String[] locales = Resources.getSystem().getAssets().getLocales(); final String[] locales = getSystemAssetLocales(); List<String> localeList = new ArrayList<String>(locales.length); Collections.addAll(localeList, locales); // Don't show the pseudolocales unless we're in developer mode. http://b/17190407. if (!isInDeveloperMode) { localeList.remove("ar-XB"); localeList.remove("en-XA"); for (String locale : pseudoLocales) { localeList.remove(locale); } } Collections.sort(localeList); Loading Loading @@ -240,13 +255,24 @@ public class LocalePicker extends ListFragment { /** * Requests the system to update the system locale. Note that the system looks halted * for a while during the Locale migration, so the caller need to take care of it. * * @see #updateLocales(LocaleList) */ public static void updateLocale(Locale locale) { updateLocales(new LocaleList(locale)); } /** * Requests the system to update the list of system locales. * Note that the system looks halted for a while during the Locale migration, * so the caller need to take care of it. */ public static void updateLocales(LocaleList locales) { try { IActivityManager am = ActivityManagerNative.getDefault(); Configuration config = am.getConfiguration(); final IActivityManager am = ActivityManagerNative.getDefault(); final Configuration config = am.getConfiguration(); config.setLocale(locale); config.setLocales(locales); config.userSetLocale = true; am.updateConfiguration(config); Loading @@ -256,4 +282,19 @@ public class LocalePicker extends ListFragment { // Intentionally left blank } } /** * Get the locale list. * * @return The locale list. */ public static LocaleList getLocales() { try { return ActivityManagerNative.getDefault() .getConfiguration().getLocales(); } catch (RemoteException e) { // If something went wrong return LocaleList.getDefault(); } } } Loading
core/java/com/android/internal/app/LocalePicker.java +48 −7 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.util.LocaleList; import android.util.Log; import android.view.LayoutInflater; import android.view.View; Loading @@ -45,6 +46,7 @@ import java.util.ArrayList; public class LocalePicker extends ListFragment { private static final String TAG = "LocalePicker"; private static final boolean DEBUG = false; private static final String[] pseudoLocales = { "en-XA", "ar-XB" }; public static interface LocaleSelectionListener { // You can add any argument if you really need it... Loading @@ -57,7 +59,7 @@ public class LocalePicker extends ListFragment { static final Collator sCollator = Collator.getInstance(); String label; Locale locale; final Locale locale; public LocaleInfo(String label, Locale locale) { this.label = label; Loading @@ -83,17 +85,30 @@ public class LocalePicker extends ListFragment { } } public static String[] getSystemAssetLocales() { return Resources.getSystem().getAssets().getLocales(); } public static String[] getSupportedLocales(Context context) { return context.getResources().getStringArray(R.array.supported_locales); } public static String[] getPseudoLocales() { return pseudoLocales; } public static List<LocaleInfo> getAllAssetLocales(Context context, boolean isInDeveloperMode) { final Resources resources = context.getResources(); final String[] locales = Resources.getSystem().getAssets().getLocales(); final String[] locales = getSystemAssetLocales(); List<String> localeList = new ArrayList<String>(locales.length); Collections.addAll(localeList, locales); // Don't show the pseudolocales unless we're in developer mode. http://b/17190407. if (!isInDeveloperMode) { localeList.remove("ar-XB"); localeList.remove("en-XA"); for (String locale : pseudoLocales) { localeList.remove(locale); } } Collections.sort(localeList); Loading Loading @@ -240,13 +255,24 @@ public class LocalePicker extends ListFragment { /** * Requests the system to update the system locale. Note that the system looks halted * for a while during the Locale migration, so the caller need to take care of it. * * @see #updateLocales(LocaleList) */ public static void updateLocale(Locale locale) { updateLocales(new LocaleList(locale)); } /** * Requests the system to update the list of system locales. * Note that the system looks halted for a while during the Locale migration, * so the caller need to take care of it. */ public static void updateLocales(LocaleList locales) { try { IActivityManager am = ActivityManagerNative.getDefault(); Configuration config = am.getConfiguration(); final IActivityManager am = ActivityManagerNative.getDefault(); final Configuration config = am.getConfiguration(); config.setLocale(locale); config.setLocales(locales); config.userSetLocale = true; am.updateConfiguration(config); Loading @@ -256,4 +282,19 @@ public class LocalePicker extends ListFragment { // Intentionally left blank } } /** * Get the locale list. * * @return The locale list. */ public static LocaleList getLocales() { try { return ActivityManagerNative.getDefault() .getConfiguration().getLocales(); } catch (RemoteException e) { // If something went wrong return LocaleList.getDefault(); } } }