[HW2] Have a script for hardware keyboard

Change-Id: I3ee85867c529156374ecc17db3243a50912e760b
Jean Chalard 2014-06-30 20:59:18 +09:00
parent 87d907bda9
commit 5f6c303f0b
2 changed files with 8 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -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);