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

View file

@ -260,9 +260,8 @@ public class LatinIME extends InputMethodService
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,