use of android.os.LocaleList in project android_frameworks_base by AOSPA.
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 AOSPA.
the class Paint method setTextLocale.
/**
* Set the text locale list to a one-member list consisting of just the locale.
*
* See {@link #setTextLocales(LocaleList)} for how the locale list affects
* the way the text is drawn for some languages.
*
* @param locale the paint's locale value for drawing text, must not be null.
*/
public void setTextLocale(@NonNull Locale locale) {
if (locale == null) {
throw new IllegalArgumentException("locale cannot be null");
}
if (mLocales != null && mLocales.size() == 1 && locale.equals(mLocales.get(0))) {
return;
}
mLocales = new LocaleList(locale);
syncTextLocalesWithMinikin();
}
use of android.os.LocaleList in project android_frameworks_base by AOSPA.
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 LocalePickerWithRegion method setListener.
/**
* Sets the listener and initializes the locale list.
*
* <p>Returns true if we need to show the list, false if not.</p>
*
* <p>Can return false because of an error, trying to show a list of countries,
* but no parent locale was provided.</p>
*
* <p>It can also return false if the caller tries to show the list in country mode and
* there is only one country available (i.e. Japanese => Japan).
* In this case we don't even show the list, we call the listener with that locale,
* "pretending" it was selected, and return false.</p>
*/
private boolean setListener(Context context, LocaleSelectedListener listener, LocaleStore.LocaleInfo parent, boolean translatedOnly) {
this.mParentLocale = parent;
this.mListener = listener;
this.mTranslatedOnly = translatedOnly;
setRetainInstance(true);
final HashSet<String> langTagsToIgnore = new HashSet<>();
if (!translatedOnly) {
final LocaleList userLocales = LocalePicker.getLocales();
final String[] langTags = userLocales.toLanguageTags().split(",");
Collections.addAll(langTagsToIgnore, langTags);
}
if (parent != null) {
mLocaleList = LocaleStore.getLevelLocales(context, langTagsToIgnore, parent, translatedOnly);
if (mLocaleList.size() <= 1) {
if (listener != null && (mLocaleList.size() == 1)) {
listener.onLocaleSelected(mLocaleList.iterator().next());
}
return false;
}
} else {
mLocaleList = LocaleStore.getLevelLocales(context, langTagsToIgnore, null, /* no parent */
translatedOnly);
}
return true;
}
use of android.os.LocaleList in project android_frameworks_base by ResurrectionRemix.
the class Paint method setTextLocale.
/**
* Set the text locale list to a one-member list consisting of just the locale.
*
* See {@link #setTextLocales(LocaleList)} for how the locale list affects
* the way the text is drawn for some languages.
*
* @param locale the paint's locale value for drawing text, must not be null.
*/
public void setTextLocale(@NonNull Locale locale) {
if (locale == null) {
throw new IllegalArgumentException("locale cannot be null");
}
if (mLocales != null && mLocales.size() == 1 && locale.equals(mLocales.get(0))) {
return;
}
mLocales = new LocaleList(locale);
syncTextLocalesWithMinikin();
}
Aggregations