use of android.os.LocaleList in project android_frameworks_base by ResurrectionRemix.
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());
}
use of android.os.LocaleList in project android_frameworks_base by ResurrectionRemix.
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());
}
use of android.os.LocaleList in project android_frameworks_base by ResurrectionRemix.
the class LocaleTile method toggleLocale.
private void toggleLocale() {
if (currentLocaleBackup == null) {
currentLocaleBackup = mLocaleList.get(0);
}
Locale[] newLocales = new Locale[mLocaleList.size()];
for (int i = 0; i < newLocales.length; i++) {
newLocales[i] = mLocaleList.get((i + 1) % newLocales.length);
}
mLocaleList = new LocaleList(newLocales);
mHandler.removeCallbacks(applyLocale);
mHandler.postDelayed(applyLocale, TOGGLE_DELAY);
refreshState();
}
use of android.os.LocaleList in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
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));
}
Aggregations