use of android.os.LocaleList in project android_frameworks_base by crdroidandroid.
the class Configuration method readFromParcel.
public void readFromParcel(Parcel source) {
fontScale = source.readFloat();
mcc = source.readInt();
mnc = source.readInt();
final int localeListSize = source.readInt();
final Locale[] localeArray = new Locale[localeListSize];
for (int i = 0; i < localeListSize; ++i) {
localeArray[i] = Locale.forLanguageTag(source.readString());
}
mLocaleList = new LocaleList(localeArray);
locale = mLocaleList.get(0);
userSetLocale = (source.readInt() == 1);
touchscreen = source.readInt();
keyboard = source.readInt();
keyboardHidden = source.readInt();
hardKeyboardHidden = source.readInt();
navigation = source.readInt();
navigationHidden = source.readInt();
orientation = source.readInt();
screenLayout = source.readInt();
uiMode = source.readInt();
screenWidthDp = source.readInt();
screenHeightDp = source.readInt();
smallestScreenWidthDp = source.readInt();
densityDpi = source.readInt();
compatScreenWidthDp = source.readInt();
compatScreenHeightDp = source.readInt();
compatSmallestScreenWidthDp = source.readInt();
seq = source.readInt();
}
use of android.os.LocaleList in project android_frameworks_base by crdroidandroid.
the class ActivityThread method updateLocaleListFromAppContext.
/**
* The LocaleList set for the app's resources may have been shuffled so that the preferred
* Locale is at position 0. We must find the index of this preferred Locale in the
* original LocaleList.
*/
private void updateLocaleListFromAppContext(Context context, LocaleList newLocaleList) {
final Locale bestLocale = context.getResources().getConfiguration().getLocales().get(0);
final int newLocaleListSize = newLocaleList.size();
for (int i = 0; i < newLocaleListSize; i++) {
if (bestLocale.equals(newLocaleList.get(i))) {
LocaleList.setDefault(newLocaleList, i);
return;
}
}
// The app may have overridden the LocaleList with its own Locale
// (not present in the available list). Push the chosen Locale
// to the front of the list.
LocaleList.setDefault(new LocaleList(bestLocale, newLocaleList));
}
use of android.os.LocaleList in project android_frameworks_base by crdroidandroid.
the class InputMethodUtils method getImplicitlyApplicableSubtypesLocked.
@VisibleForTesting
public static ArrayList<InputMethodSubtype> getImplicitlyApplicableSubtypesLocked(Resources res, InputMethodInfo imi) {
final LocaleList systemLocales = res.getConfiguration().getLocales();
synchronized (sCacheLock) {
// it does not check if subtypes are also identical.
if (systemLocales.equals(sCachedSystemLocales) && sCachedInputMethodInfo == imi) {
return new ArrayList<>(sCachedResult);
}
}
// Note: Only resource info in "res" is used in getImplicitlyApplicableSubtypesLockedImpl().
// TODO: Refactor getImplicitlyApplicableSubtypesLockedImpl() so that it can receive
// LocaleList rather than Resource.
final ArrayList<InputMethodSubtype> result = getImplicitlyApplicableSubtypesLockedImpl(res, imi);
synchronized (sCacheLock) {
// Both LocaleList and InputMethodInfo are immutable. No need to copy them here.
sCachedSystemLocales = systemLocales;
sCachedInputMethodInfo = imi;
sCachedResult = new ArrayList<>(result);
}
return result;
}
use of android.os.LocaleList in project android_frameworks_base by crdroidandroid.
the class ResourcesLocaleTest method testSelectFirstSupportedLanguage.
@SmallTest
public void testSelectFirstSupportedLanguage() throws Exception {
final Resources resources = createResourcesWithApk(R.raw.locales);
ensureNoLanguage(resources, "fr");
final LocaleList preferredLocales = LocaleList.forLanguageTags("fr-FR,pl-PL");
final Configuration config = new Configuration();
config.setLocales(preferredLocales);
resources.updateConfiguration(config, null);
// The APK we loaded has default and Polish languages. We expect the Polish language to
// therefore be chosen.
assertEquals(Locale.forLanguageTag("pl-PL"), resources.getConfiguration().getLocales().get(0));
}
use of android.os.LocaleList in project android_frameworks_base by crdroidandroid.
the class LocaleUtilsTest method testFilterDoesNotMatchAnything.
@SmallTest
public void testFilterDoesNotMatchAnything() throws Exception {
final ArrayList<Locale> availableLocales = new ArrayList<>();
availableLocales.add(Locale.forLanguageTag("en-US"));
availableLocales.add(Locale.forLanguageTag("fr-CA"));
availableLocales.add(Locale.forLanguageTag("in"));
availableLocales.add(Locale.forLanguageTag("ja"));
availableLocales.add(Locale.forLanguageTag("fil"));
final LocaleList preferredLocales = LocaleList.forLanguageTags("zh-Hans-TW");
final ArrayList<Locale> dest = new ArrayList<>();
LocaleUtils.filterByLanguage(availableLocales, sIdentityMapper, preferredLocales, dest);
assertEquals(0, dest.size());
}
Aggregations