Fixed accidental switch to symbols mode from alphabet.
The KeyboardSwitcher was remembering state from a previous edittext
where the user was in symbols mode and applying the switch code
when user hits space in the new edittext for the first time.
Make sure to reset the state when a new keyboard mode is requested.
Also make sure that we don't switch from symbols to alphabet keyboard
when editing in a number/datetime field and hitting space.
diff --git a/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/src/com/android/inputmethod/latin/KeyboardSwitcher.java
index 16dd7b9..2da7036 100644
--- a/src/com/android/inputmethod/latin/KeyboardSwitcher.java
+++ b/src/com/android/inputmethod/latin/KeyboardSwitcher.java
@@ -54,6 +54,7 @@
private int mImeOptions;
private int mTextMode = MODE_TEXT_QWERTY;
private boolean mIsSymbols;
+ private boolean mPreferSymbols;
private int mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
private int mLastDisplayWidth;
@@ -114,7 +115,10 @@
}
void setKeyboardMode(int mode, int imeOptions) {
- setKeyboardMode(mode, imeOptions, false);
+ mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
+ mPreferSymbols = mode == MODE_SYMBOLS;
+ setKeyboardMode(mode == MODE_SYMBOLS ? MODE_TEXT : mode, imeOptions,
+ mPreferSymbols);
}
void setKeyboardMode(int mode, int imeOptions, boolean isSymbols) {
@@ -233,7 +237,7 @@
void toggleSymbols() {
setKeyboardMode(mMode, mImeOptions, !mIsSymbols);
- if (mIsSymbols) {
+ if (mIsSymbols && !mPreferSymbols) {
mSymbolsModeState = SYMBOLS_MODE_STATE_BEGIN;
} else {
mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
diff --git a/src/com/android/inputmethod/latin/LatinIME.java b/src/com/android/inputmethod/latin/LatinIME.java
index 01d70df..49ae93e 100644
--- a/src/com/android/inputmethod/latin/LatinIME.java
+++ b/src/com/android/inputmethod/latin/LatinIME.java
@@ -260,9 +260,8 @@
switch (attribute.inputType&EditorInfo.TYPE_MASK_CLASS) {
case EditorInfo.TYPE_CLASS_NUMBER:
case EditorInfo.TYPE_CLASS_DATETIME:
- mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT,
+ mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_SYMBOLS,
attribute.imeOptions);
- mKeyboardSwitcher.toggleSymbols();
break;
case EditorInfo.TYPE_CLASS_PHONE:
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_PHONE,