use of android.os.LocaleList in project android_frameworks_base by DirtyUnicorns.
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 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 AOSPA.
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 android_frameworks_base by AOSPA.
the class InputManagerService method visitKeyboardLayoutsInPackage.
private void visitKeyboardLayoutsInPackage(PackageManager pm, ActivityInfo receiver, String keyboardName, int requestedPriority, KeyboardLayoutVisitor visitor) {
Bundle metaData = receiver.metaData;
if (metaData == null) {
return;
}
int configResId = metaData.getInt(InputManager.META_DATA_KEYBOARD_LAYOUTS);
if (configResId == 0) {
Slog.w(TAG, "Missing meta-data '" + InputManager.META_DATA_KEYBOARD_LAYOUTS + "' on receiver " + receiver.packageName + "/" + receiver.name);
return;
}
CharSequence receiverLabel = receiver.loadLabel(pm);
String collection = receiverLabel != null ? receiverLabel.toString() : "";
int priority;
if ((receiver.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
priority = requestedPriority;
} else {
priority = 0;
}
try {
Resources resources = pm.getResourcesForApplication(receiver.applicationInfo);
XmlResourceParser parser = resources.getXml(configResId);
try {
XmlUtils.beginDocument(parser, "keyboard-layouts");
for (; ; ) {
XmlUtils.nextElement(parser);
String element = parser.getName();
if (element == null) {
break;
}
if (element.equals("keyboard-layout")) {
TypedArray a = resources.obtainAttributes(parser, com.android.internal.R.styleable.KeyboardLayout);
try {
String name = a.getString(com.android.internal.R.styleable.KeyboardLayout_name);
String label = a.getString(com.android.internal.R.styleable.KeyboardLayout_label);
int keyboardLayoutResId = a.getResourceId(com.android.internal.R.styleable.KeyboardLayout_keyboardLayout, 0);
String languageTags = a.getString(com.android.internal.R.styleable.KeyboardLayout_locale);
LocaleList locales = getLocalesFromLanguageTags(languageTags);
int vid = a.getInt(com.android.internal.R.styleable.KeyboardLayout_vendorId, -1);
int pid = a.getInt(com.android.internal.R.styleable.KeyboardLayout_productId, -1);
if (name == null || label == null || keyboardLayoutResId == 0) {
Slog.w(TAG, "Missing required 'name', 'label' or 'keyboardLayout' " + "attributes in keyboard layout " + "resource from receiver " + receiver.packageName + "/" + receiver.name);
} else {
String descriptor = KeyboardLayoutDescriptor.format(receiver.packageName, receiver.name, name);
if (keyboardName == null || name.equals(keyboardName)) {
KeyboardLayout layout = new KeyboardLayout(descriptor, label, collection, priority, locales, vid, pid);
visitor.visitKeyboardLayout(resources, keyboardLayoutResId, layout);
}
}
} finally {
a.recycle();
}
} else {
Slog.w(TAG, "Skipping unrecognized element '" + element + "' in keyboard layout resource from receiver " + receiver.packageName + "/" + receiver.name);
}
}
} finally {
parser.close();
}
} catch (Exception ex) {
Slog.w(TAG, "Could not parse keyboard layout resource from receiver " + receiver.packageName + "/" + receiver.name, ex);
}
}
use of android.os.LocaleList in project android_frameworks_base by AOSPA.
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));
}
Aggregations