Use system locale for labels on no language keyboard
Bug: 6010147 Change-Id: I9a6ce1bf82ca13359f715f4d1fc5f2bf15d4ee6emain
parent
2be51f4fd0
commit
10f18f5fb7
|
@ -32,7 +32,9 @@ import com.android.inputmethod.keyboard.internal.KeyboardCodesSet;
|
|||
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||
import com.android.inputmethod.keyboard.internal.KeyboardLabelsSet;
|
||||
import com.android.inputmethod.latin.LatinImeLogger;
|
||||
import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
|
||||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.SubtypeLocale;
|
||||
import com.android.inputmethod.latin.Utils;
|
||||
import com.android.inputmethod.latin.XmlParseUtils;
|
||||
|
||||
|
@ -44,6 +46,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard
|
||||
|
@ -782,7 +785,17 @@ public class Keyboard {
|
|||
final String language = params.mId.mLocale.getLanguage();
|
||||
params.mCodesSet.setLanguage(language);
|
||||
params.mLabelsSet.setLanguage(language);
|
||||
params.mLabelsSet.loadStringResources(mContext);
|
||||
final RunInLocale<Void> job = new RunInLocale<Void>() {
|
||||
@Override
|
||||
protected Void job(Resources res) {
|
||||
params.mLabelsSet.loadStringResources(mContext);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
// Null means the current system locale.
|
||||
final Locale locale = language.equals(SubtypeLocale.NO_LANGUAGE)
|
||||
? null : params.mId.mLocale;
|
||||
job.runInLocale(mResources, locale);
|
||||
|
||||
final int resourceId = keyboardAttr.getResourceId(
|
||||
R.styleable.Keyboard_touchPositionCorrectionData, 0);
|
||||
|
|
|
@ -29,12 +29,10 @@ import android.view.inputmethod.InputMethodSubtype;
|
|||
|
||||
import com.android.inputmethod.compat.EditorInfoCompatUtils;
|
||||
import com.android.inputmethod.keyboard.KeyboardLayoutSet.Params.ElementParams;
|
||||
import com.android.inputmethod.keyboard.internal.KeySpecParser;
|
||||
import com.android.inputmethod.latin.InputTypeUtils;
|
||||
import com.android.inputmethod.latin.LatinIME;
|
||||
import com.android.inputmethod.latin.LatinImeLogger;
|
||||
import com.android.inputmethod.latin.LocaleUtils;
|
||||
import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
|
||||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.StringUtils;
|
||||
import com.android.inputmethod.latin.SubtypeLocale;
|
||||
|
@ -183,14 +181,7 @@ public class KeyboardLayoutSet {
|
|||
builder.setAutoGenerate(sKeysCache);
|
||||
}
|
||||
final int keyboardXmlId = elementParams.mKeyboardXmlId;
|
||||
final RunInLocale<Void> job = new RunInLocale<Void>() {
|
||||
@Override
|
||||
protected Void job(Resources res) {
|
||||
builder.load(keyboardXmlId, id);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
job.runInLocale(context.getResources(), id.mLocale);
|
||||
builder.load(keyboardXmlId, id);
|
||||
builder.setTouchPositionCorrectionEnabled(mParams.mTouchPositionCorrectionEnabled);
|
||||
builder.setProximityCharsCorrectionEnabled(
|
||||
elementParams.mProximityCharsCorrectionEnabled);
|
||||
|
@ -321,18 +312,11 @@ public class KeyboardLayoutSet {
|
|||
R.xml.keyboard_layout_set_qwerty);
|
||||
final String keyboardLayoutSetName = mParams.mKeyboardLayoutSetName;
|
||||
final int xmlId = mResources.getIdentifier(keyboardLayoutSetName, "xml", packageName);
|
||||
final RunInLocale<Void> job = new RunInLocale<Void>() {
|
||||
@Override
|
||||
protected Void job(Resources res) {
|
||||
try {
|
||||
parseKeyboardLayoutSet(res, xmlId);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage() + " in " + keyboardLayoutSetName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
job.runInLocale(mResources, mParams.mLocale);
|
||||
try {
|
||||
parseKeyboardLayoutSet(mResources, xmlId);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage() + " in " + keyboardLayoutSetName);
|
||||
}
|
||||
return new KeyboardLayoutSet(mContext, mParams);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue