use of android.os.LocaleList in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class AutoReinflateContainer method onConfigurationChanged.
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
boolean shouldInflateLayout = false;
final int density = newConfig.densityDpi;
if (density != mDensity) {
mDensity = density;
shouldInflateLayout = true;
}
final LocaleList localeList = newConfig.getLocales();
if (localeList != mLocaleList) {
mLocaleList = localeList;
shouldInflateLayout = true;
}
if (shouldInflateLayout) {
inflateLayout();
}
}
use of android.os.LocaleList in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class InputMethodUtilsTest method assertDefaultEnabledImes.
private void assertDefaultEnabledImes(final ArrayList<InputMethodInfo> preinstalledImes, final Locale systemLocale, final boolean isSystemReady, String... expectedImeNames) {
final Context context = createTargetContextWithLocales(new LocaleList(systemLocale));
final String[] actualImeNames = getPackageNames(InputMethodUtils.getDefaultEnabledImes(context, isSystemReady, preinstalledImes));
assertEquals(expectedImeNames.length, actualImeNames.length);
for (int i = 0; i < expectedImeNames.length; ++i) {
assertEquals(expectedImeNames[i], actualImeNames[i]);
}
}
use of android.os.LocaleList in project platform_frameworks_base by android.
the class LocaleUtilsTest method testFilterByLanguageEmptySource.
@SmallTest
public void testFilterByLanguageEmptySource() throws Exception {
final ArrayList<Locale> availableLocales = new ArrayList<>();
final LocaleList preferredLocales = LocaleList.forLanguageTags("fr,en-US,ja-JP");
final ArrayList<Locale> dest = new ArrayList<>();
LocaleUtils.filterByLanguage(availableLocales, sIdentityMapper, preferredLocales, dest);
assertEquals(0, dest.size());
}
Aggregations