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.
This commit is contained in:
Amith Yamasani 2009-09-01 14:05:19 -07:00
parent 5d11ccc27d
commit e3803800c5
2 changed files with 7 additions and 4 deletions

View file

@ -54,6 +54,7 @@ public class KeyboardSwitcher {
private int mImeOptions; private int mImeOptions;
private int mTextMode = MODE_TEXT_QWERTY; private int mTextMode = MODE_TEXT_QWERTY;
private boolean mIsSymbols; private boolean mIsSymbols;
private boolean mPreferSymbols;
private int mSymbolsModeState = SYMBOLS_MODE_STATE_NONE; private int mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
private int mLastDisplayWidth; private int mLastDisplayWidth;
@ -114,7 +115,10 @@ public class KeyboardSwitcher {
} }
void setKeyboardMode(int mode, int imeOptions) { 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) { void setKeyboardMode(int mode, int imeOptions, boolean isSymbols) {
@ -233,7 +237,7 @@ public class KeyboardSwitcher {
void toggleSymbols() { void toggleSymbols() {
setKeyboardMode(mMode, mImeOptions, !mIsSymbols); setKeyboardMode(mMode, mImeOptions, !mIsSymbols);
if (mIsSymbols) { if (mIsSymbols && !mPreferSymbols) {
mSymbolsModeState = SYMBOLS_MODE_STATE_BEGIN; mSymbolsModeState = SYMBOLS_MODE_STATE_BEGIN;
} else { } else {
mSymbolsModeState = SYMBOLS_MODE_STATE_NONE; mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;

View file

@ -260,9 +260,8 @@ public class LatinIME extends InputMethodService
switch (attribute.inputType&EditorInfo.TYPE_MASK_CLASS) { switch (attribute.inputType&EditorInfo.TYPE_MASK_CLASS) {
case EditorInfo.TYPE_CLASS_NUMBER: case EditorInfo.TYPE_CLASS_NUMBER:
case EditorInfo.TYPE_CLASS_DATETIME: case EditorInfo.TYPE_CLASS_DATETIME:
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT, mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_SYMBOLS,
attribute.imeOptions); attribute.imeOptions);
mKeyboardSwitcher.toggleSymbols();
break; break;
case EditorInfo.TYPE_CLASS_PHONE: case EditorInfo.TYPE_CLASS_PHONE:
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_PHONE, mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_PHONE,