Merge "[SD2] Add support for a new tag Feature in KeyboardLayoutSet"
commit
593009bc9f
|
@ -488,6 +488,17 @@
|
|||
<attr name="enableProximityCharsCorrection" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="KeyboardLayoutSet_Feature">
|
||||
<!-- This should be aligned with ScriptUtils.SCRIPT_* -->
|
||||
<attr name="supportedScript" format="enum">
|
||||
<enum name="latin" value="0" />
|
||||
<enum name="cyrillic" value="1" />
|
||||
<enum name="greek" value="2" />
|
||||
<enum name="arabic" value="3" />
|
||||
<enum name="hebrew" value="4" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="SeekBarDialogPreference">
|
||||
<attr name="maxValue" format="integer" />
|
||||
<attr name="minValue" format="integer" />
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
<KeyboardLayoutSet
|
||||
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin">
|
||||
<Feature
|
||||
latin:supportedScript="arabic" />
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_arabic"
|
||||
|
|
|
@ -40,6 +40,7 @@ import com.android.inputmethod.latin.LatinImeLogger;
|
|||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.SubtypeSwitcher;
|
||||
import com.android.inputmethod.latin.utils.InputTypeUtils;
|
||||
import com.android.inputmethod.latin.utils.ScriptUtils;
|
||||
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||
import com.android.inputmethod.latin.utils.XmlParseUtils;
|
||||
|
||||
|
@ -63,6 +64,7 @@ public final class KeyboardLayoutSet {
|
|||
|
||||
private static final String TAG_KEYBOARD_SET = "KeyboardLayoutSet";
|
||||
private static final String TAG_ELEMENT = "Element";
|
||||
private static final String TAG_FEATURE = "Feature";
|
||||
|
||||
private static final String KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX = "keyboard_layout_set_";
|
||||
|
||||
|
@ -111,6 +113,7 @@ public final class KeyboardLayoutSet {
|
|||
boolean mIsSpellChecker;
|
||||
int mKeyboardWidth;
|
||||
int mKeyboardHeight;
|
||||
int mScriptId;
|
||||
// Sparse array of KeyboardLayoutSet element parameters indexed by element's id.
|
||||
final SparseArray<ElementParams> mKeyboardLayoutSetElementIdToParamsMap =
|
||||
new SparseArray<>();
|
||||
|
@ -275,6 +278,10 @@ public final class KeyboardLayoutSet {
|
|||
mParams.mDisableTouchPositionCorrectionDataForTest = true;
|
||||
}
|
||||
|
||||
public void setScriptId(final int scriptId) {
|
||||
mParams.mScriptId = scriptId;
|
||||
}
|
||||
|
||||
public KeyboardLayoutSet build() {
|
||||
if (mParams.mSubtype == null)
|
||||
throw new RuntimeException("KeyboardLayoutSet subtype is not specified");
|
||||
|
@ -320,6 +327,8 @@ public final class KeyboardLayoutSet {
|
|||
final String tag = parser.getName();
|
||||
if (TAG_ELEMENT.equals(tag)) {
|
||||
parseKeyboardLayoutSetElement(parser);
|
||||
} else if (TAG_FEATURE.equals(tag)) {
|
||||
parseKeyboardLayoutSetFeature(parser);
|
||||
} else {
|
||||
throw new XmlParseUtils.IllegalStartTag(parser, tag, TAG_KEYBOARD_SET);
|
||||
}
|
||||
|
@ -361,6 +370,21 @@ public final class KeyboardLayoutSet {
|
|||
}
|
||||
}
|
||||
|
||||
private void parseKeyboardLayoutSetFeature(final XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException {
|
||||
final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser),
|
||||
R.styleable.KeyboardLayoutSet_Feature);
|
||||
try {
|
||||
final int scriptId = a.getInt(
|
||||
R.styleable.KeyboardLayoutSet_Feature_supportedScript,
|
||||
ScriptUtils.SCRIPT_LATIN);
|
||||
XmlParseUtils.checkEndTag(TAG_FEATURE, parser);
|
||||
setScriptId(scriptId);
|
||||
} finally {
|
||||
a.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
private static int getKeyboardMode(final EditorInfo editorInfo) {
|
||||
final int inputType = editorInfo.inputType;
|
||||
final int variation = inputType & InputType.TYPE_MASK_VARIATION;
|
||||
|
|
|
@ -23,9 +23,12 @@ import java.util.TreeMap;
|
|||
* A class to help with handling different writing scripts.
|
||||
*/
|
||||
public class ScriptUtils {
|
||||
// TODO: should we use ISO 15924 identifiers instead?
|
||||
public static final int SCRIPT_LATIN = 0;
|
||||
public static final int SCRIPT_CYRILLIC = 1;
|
||||
public static final int SCRIPT_GREEK = 2;
|
||||
public static final int SCRIPT_ARABIC = 3;
|
||||
public static final int SCRIPT_HEBREW = 4;
|
||||
public static final TreeMap<String, Integer> mLanguageToScript;
|
||||
static {
|
||||
// List of the supported languages and their associated script. We won't check
|
||||
|
|
Loading…
Reference in New Issue