use of android.os.LocaleList in project android_frameworks_base by AOSPA.
the class ResourcesLocaleTest method testEnglishIsAlwaysConsideredSupported.
@SmallTest
public void testEnglishIsAlwaysConsideredSupported() throws Exception {
final Resources resources = createResourcesWithApk(R.raw.locales);
ensureNoLanguage(resources, "en");
final LocaleList preferredLocales = LocaleList.forLanguageTags("en-US,pl-PL");
final Configuration config = new Configuration();
config.setLocales(preferredLocales);
resources.updateConfiguration(config, null);
// The APK we loaded has default and Polish languages. If English is first in the list,
// always take it the default (assumed to be English).
assertEquals(Locale.forLanguageTag("en-US"), resources.getConfiguration().getLocales().get(0));
}
use of android.os.LocaleList in project android_frameworks_base by AOSPA.
the class InputMethodManagerService method resetAllInternalStateLocked.
private void resetAllInternalStateLocked(final boolean updateOnlyWhenLocaleChanged, final boolean resetDefaultEnabledIme) {
if (!mSystemReady) {
// not system ready
return;
}
final LocaleList newLocales = mRes.getConfiguration().getLocales();
if (!updateOnlyWhenLocaleChanged || (newLocales != null && !newLocales.equals(mLastSystemLocales))) {
if (!updateOnlyWhenLocaleChanged) {
hideCurrentInputLocked(0, null);
resetCurrentMethodAndClient(InputMethodClient.UNBIND_REASON_RESET_IME);
}
if (DEBUG) {
Slog.i(TAG, "LocaleList has been changed to " + newLocales);
}
buildInputMethodListLocked(resetDefaultEnabledIme);
if (!updateOnlyWhenLocaleChanged) {
final String selectedImiId = mSettings.getSelectedInputMethod();
if (TextUtils.isEmpty(selectedImiId)) {
// This is the first time of the user switch and
// set the current ime to the proper one.
resetDefaultImeLocked(mContext);
}
} else {
// If the locale is changed, needs to reset the default ime
resetDefaultImeLocked(mContext);
}
updateFromSettingsLocked(true);
mLastSystemLocales = newLocales;
if (!updateOnlyWhenLocaleChanged) {
try {
startInputInnerLocked();
} catch (RuntimeException e) {
Slog.w(TAG, "Unexpected exception", e);
}
}
}
}
use of android.os.LocaleList in project android_frameworks_base by AOSPA.
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 android_frameworks_base by AOSPA.
the class LocaleUtilsTest method testFilterByLanguageEmptyLanguageList.
@SmallTest
public void testFilterByLanguageEmptyLanguageList() 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.getEmptyLocaleList();
final ArrayList<Locale> dest = new ArrayList<>();
LocaleUtils.filterByLanguage(availableLocales, sIdentityMapper, preferredLocales, dest);
assertEquals(0, dest.size());
}
use of android.os.LocaleList in project android_frameworks_base by AOSPA.
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