From 5f6c303f0ba70c0bcfd73d06b63f0175669dafc1 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 30 Jun 2014 20:59:18 +0900 Subject: [PATCH] [HW2] Have a script for hardware keyboard Change-Id: I3ee85867c529156374ecc17db3243a50912e760b --- .../com/android/inputmethod/keyboard/KeyboardSwitcher.java | 4 ++++ java/src/com/android/inputmethod/latin/utils/ScriptUtils.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index dd71e9d4f..f35126750 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -39,6 +39,7 @@ import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.WordComposer; import com.android.inputmethod.latin.settings.SettingsValues; import com.android.inputmethod.latin.utils.ResourceUtils; +import com.android.inputmethod.latin.utils.ScriptUtils; public final class KeyboardSwitcher implements KeyboardState.SwitchActions { private static final String TAG = KeyboardSwitcher.class.getSimpleName(); @@ -372,6 +373,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { } public int getCurrentKeyboardScriptId() { + if (null == mKeyboardLayoutSet) { + return ScriptUtils.SCRIPT_UNKNOWN; + } return mKeyboardLayoutSet.getScriptId(); } } diff --git a/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java b/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java index 00355c307..9ab7c7778 100644 --- a/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java @@ -23,6 +23,8 @@ import java.util.TreeMap; * A class to help with handling different writing scripts. */ public class ScriptUtils { + // Used for hardware keyboards + public static final int SCRIPT_UNKNOWN = -1; // TODO: should we use ISO 15924 identifiers instead? public static final int SCRIPT_LATIN = 0; public static final int SCRIPT_CYRILLIC = 1; @@ -89,6 +91,8 @@ public class ScriptUtils { return (codePoint >= 0x370 && codePoint <= 0x3FF) || (codePoint >= 0x1F00 && codePoint <= 0x1FFF) || codePoint == 0xF2; + case SCRIPT_UNKNOWN: + return true; default: // Should never come here throw new RuntimeException("Impossible value of script: " + script);