aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/android/inputmethod/latin/KeyboardSwitcher.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2009-07-21 15:47:11 -0700
committerJean-Baptiste Queru <jbq@google.com>2009-08-13 17:21:54 -0700
commitb19668cfc17ad30afcc3c8c0407d47238ce1a90d (patch)
tree2740edffbf98449b8ee024132d0ba811ff049912 /src/com/android/inputmethod/latin/KeyboardSwitcher.java
parent34386e698876c0f29b2d5b54b44db1e32b562c47 (diff)
downloadlatinime-b19668cfc17ad30afcc3c8c0407d47238ce1a90d.tar.gz
latinime-b19668cfc17ad30afcc3c8c0407d47238ce1a90d.tar.xz
latinime-b19668cfc17ad30afcc3c8c0407d47238ce1a90d.zip
Auto-switch back from symbols keyboard on space.
Also fix bug 1904029: Rotating keyboard while texting causes words to be deleted.
Diffstat (limited to 'src/com/android/inputmethod/latin/KeyboardSwitcher.java')
-rw-r--r--src/com/android/inputmethod/latin/KeyboardSwitcher.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/src/com/android/inputmethod/latin/KeyboardSwitcher.java
index 92b7cd4a1..a5aebfbfe 100644
--- a/src/com/android/inputmethod/latin/KeyboardSwitcher.java
+++ b/src/com/android/inputmethod/latin/KeyboardSwitcher.java
@@ -37,6 +37,10 @@ public class KeyboardSwitcher {
public static final int KEYBOARDMODE_EMAIL = R.id.mode_email;
public static final int KEYBOARDMODE_IM = R.id.mode_im;
+ private static final int SYMBOLS_MODE_STATE_NONE = 0;
+ private static final int SYMBOLS_MODE_STATE_BEGIN = 1;
+ private static final int SYMBOLS_MODE_STATE_SYMBOL = 2;
+
LatinKeyboardView mInputView;
LatinIME mContext;
@@ -50,6 +54,7 @@ public class KeyboardSwitcher {
private int mImeOptions;
private int mTextMode = MODE_TEXT_QWERTY;
private boolean mIsSymbols;
+ private int mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
private int mLastDisplayWidth;
@@ -228,5 +233,28 @@ public class KeyboardSwitcher {
void toggleSymbols() {
setKeyboardMode(mMode, mImeOptions, !mIsSymbols);
+ if (mIsSymbols) {
+ mSymbolsModeState = SYMBOLS_MODE_STATE_BEGIN;
+ } else {
+ mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
+ }
+ }
+
+ /**
+ * Updates state machine to figure out when to automatically switch back to alpha mode.
+ * Returns true if the keyboard needs to switch back
+ */
+ boolean onKey(int key) {
+ // Switch back to alpha mode if user types one or more non-space characters followed by
+ // a space.
+ switch (mSymbolsModeState) {
+ case SYMBOLS_MODE_STATE_BEGIN:
+ if (key != ' ' && key > 0) mSymbolsModeState = SYMBOLS_MODE_STATE_SYMBOL;
+ break;
+ case SYMBOLS_MODE_STATE_SYMBOL:
+ if (key == ' ') return true;
+ break;
+ }
+ return false;
}
}