aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java24
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ScriptUtils.java3
2 files changed, 27 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
index 3e5cfc11a..7ba3b3bd5 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
@@ -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;
diff --git a/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java b/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java
index 4dfb38d80..00355c307 100644
--- a/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java
@@ -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