diff --git a/java/res/xml-xlarge/kbd_number.xml b/java/res/xml-xlarge/kbd_number.xml new file mode 100644 index 000000000..dd251ea9f --- /dev/null +++ b/java/res/xml-xlarge/kbd_number.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/res/xml/kbd_number.xml b/java/res/xml/kbd_number.xml new file mode 100644 index 000000000..cde7205bc --- /dev/null +++ b/java/res/xml/kbd_number.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java index 68c35791c..b5dd3eed4 100644 --- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java @@ -40,6 +40,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha public static final int MODE_IM = 3; public static final int MODE_WEB = 4; public static final int MODE_PHONE = 5; + public static final int MODE_NUMBER = 6; // Changing DEFAULT_LAYOUT_ID also requires prefs_for_debug.xml to be matched with. public static final String DEFAULT_LAYOUT_ID = "5"; @@ -239,6 +240,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha case MODE_IM: return "im"; case MODE_WEB: return "web"; case MODE_PHONE: return "phone"; + case MODE_NUMBER: return "number"; } return null; } @@ -287,10 +289,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha KeyboardId id = getKeyboardId(mode, imeOptions, isSymbols); LatinKeyboard keyboard = getKeyboard(id); - if (mode == MODE_PHONE) { - mInputView.setPhoneKeyboard(keyboard); - } - mCurrentId = id; mInputView.setKeyboard(keyboard); } @@ -331,11 +329,26 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha final boolean enableShiftLock; if (isSymbols) { - xmlId = mode == MODE_PHONE ? R.xml.kbd_phone_symbols : R.xml.kbd_symbols; + if (mode == MODE_PHONE) { + xmlId = R.xml.kbd_phone_symbols; + } else if (mode == MODE_NUMBER) { + // Note: MODE_NUMBER keyboard layout has no "switch alpha symbol" key. + xmlId = R.xml.kbd_number; + } else { + xmlId = R.xml.kbd_symbols; + } enableShiftLock = false; - } else { // QWERTY - xmlId = mode == MODE_PHONE ? R.xml.kbd_phone : R.xml.kbd_qwerty; - enableShiftLock = mode == MODE_PHONE ? false : true; + } else { + if (mode == MODE_PHONE) { + xmlId = R.xml.kbd_phone; + enableShiftLock = false; + } else if (mode == MODE_NUMBER) { + xmlId = R.xml.kbd_number; + enableShiftLock = false; + } else { + xmlId = R.xml.kbd_qwerty; + enableShiftLock = true; + } } final int orientation = mInputMethodService.getResources().getConfiguration().orientation; final Locale locale = mSubtypeSwitcher.getInputLocale(); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 4989d8e3c..6554954ee 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -545,10 +545,8 @@ public class LatinIME extends InputMethodService switch (attribute.inputType & EditorInfo.TYPE_MASK_CLASS) { case EditorInfo.TYPE_CLASS_NUMBER: case EditorInfo.TYPE_CLASS_DATETIME: - // fall through - // NOTE: For now, we use the phone keyboard for NUMBER and DATETIME until we get - // a dedicated number entry keypad. - // TODO: Use a dedicated number entry keypad here when we get one. + mode = KeyboardSwitcher.MODE_NUMBER; + break; case EditorInfo.TYPE_CLASS_PHONE: mode = KeyboardSwitcher.MODE_PHONE; break; diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index 74aa899b6..c6e911680 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -189,6 +189,14 @@ public class LatinKeyboard extends BaseKeyboard { return mId.getXmlId() == R.xml.kbd_qwerty; } + public boolean isPhoneKeyboard() { + return mId.mMode == KeyboardSwitcher.MODE_PHONE; + } + + public boolean isNumberKeyboard() { + return mId.mMode == KeyboardSwitcher.MODE_NUMBER; + } + /** * @return a key which should be invalidated. */ diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java index fb8b69ed0..4fcfe01ba 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java @@ -40,8 +40,6 @@ public class LatinKeyboardView extends BaseKeyboardView { public static final int KEYCODE_PREV_LANGUAGE = -105; public static final int KEYCODE_CAPSLOCK = -106; - private LatinKeyboard mPhoneKeyboard; - /** Whether we've started dropping move events because we found a big jump */ private boolean mDroppingEvents; /** @@ -62,14 +60,12 @@ public class LatinKeyboardView extends BaseKeyboardView { super(context, attrs, defStyle); } - public void setPhoneKeyboard(LatinKeyboard phoneKeyboard) { - mPhoneKeyboard = phoneKeyboard; - } - @Override public void setPreviewEnabled(boolean previewEnabled) { - if (getLatinKeyboard() == mPhoneKeyboard) { - // Phone keyboard never shows popup preview (except language switch). + LatinKeyboard latinKeyboard = getLatinKeyboard(); + if (latinKeyboard != null + && (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard())) { + // Phone and number keyboard never shows popup preview (except language switch). super.setPreviewEnabled(false); } else { super.setPreviewEnabled(previewEnabled); @@ -100,7 +96,7 @@ public class LatinKeyboardView extends BaseKeyboardView { int primaryCode = key.codes[0]; if (primaryCode == KEYCODE_OPTIONS) { return invokeOnKey(KEYCODE_OPTIONS_LONGPRESS); - } else if (primaryCode == '0' && getLatinKeyboard() == mPhoneKeyboard) { + } else if (primaryCode == '0' && getLatinKeyboard().isPhoneKeyboard()) { // Long pressing on 0 in phone number keypad gives you a '+'. return invokeOnKey('+'); } else {