diff options
| author | Tadashi G. Takaoka <takaoka@google.com> | 2013-05-21 17:14:31 -0700 |
|---|---|---|
| committer | Tadashi G. Takaoka <takaoka@google.com> | 2013-06-04 18:20:06 +0900 |
| commit | 9552badf3c24d2098d227b0ddca0721b928a10b1 (patch) | |
| tree | c828bfe0f5b8d68fbb61d699cfaf0b2c8ff8d4a2 /java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java | |
| parent | 2a9882a433e2372ac32fbc0def578d4d9a97a676 (diff) | |
Add CODE_CAPSLOCK for long press shift key
This change utilizes the no panel auto more key feature to implement
long press shift key for shift lock.
Change-Id: I3995d25dc35aea3c67b5aa29299815462eff9cad
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java')
| -rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index bb6dec69e..e1cee427e 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -30,7 +30,7 @@ import com.android.inputmethod.latin.RecapitalizeStatus; * The input events are {@link #onLoadKeyboard()}, {@link #onSaveKeyboardState()}, * {@link #onPressKey(int,boolean,int)}, {@link #onReleaseKey(int,boolean)}, * {@link #onCodeInput(int,int)}, {@link #onFinishSlidingInput()}, {@link #onCancelInput()}, - * {@link #onUpdateShiftState(int,int)}, {@link #onLongPressTimeout(int)}. + * {@link #onUpdateShiftState(int,int)}. * * The actions are {@link SwitchActions}'s methods. */ @@ -56,8 +56,6 @@ public final class KeyboardState { public void startDoubleTapShiftKeyTimer(); public boolean isInDoubleTapShiftKeyTimeout(); public void cancelDoubleTapShiftKeyTimer(); - public void startLongPressTimer(int code); - public void cancelLongPressTimer(); } private final SwitchActions mSwitchActions; @@ -320,13 +318,16 @@ public final class KeyboardState { Log.d(TAG, "onPressKey: code=" + Constants.printableCode(code) + " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this); } + if (code != Constants.CODE_SHIFT) { + // Because the double tap shift key timer is to detect two consecutive shift key press, + // it should be canceled when a non-shift key is pressed. + mSwitchActions.cancelDoubleTapShiftKeyTimer(); + } if (code == Constants.CODE_SHIFT) { onPressShift(); } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { onPressSymbol(); } else { - mSwitchActions.cancelDoubleTapShiftKeyTimer(); - mSwitchActions.cancelLongPressTimer(); mLongPressShiftLockFired = false; mShiftKeyState.onOtherKeyPressed(); mSymbolKeyState.onOtherKeyPressed(); @@ -380,15 +381,6 @@ public final class KeyboardState { mSymbolKeyState.onRelease(); } - public void onLongPressTimeout(final int code) { - if (DEBUG_EVENT) { - Log.d(TAG, "onLongPressTimeout: code=" + Constants.printableCode(code) + " " + this); - } - if (mIsAlphabetMode && code == Constants.CODE_SHIFT) { - mLongPressShiftLockFired = true; - } - } - public void onUpdateShiftState(final int autoCaps, final int recapitalizeMode) { if (DEBUG_EVENT) { Log.d(TAG, "onUpdateShiftState: autoCaps=" + autoCaps + ", recapitalizeMode=" @@ -448,7 +440,9 @@ public final class KeyboardState { mLongPressShiftLockFired = false; // If we are recapitalizing, we don't do any of the normal processing, including // importantly the double tap timer. - if (RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE != mRecapitalizeMode) return; + if (RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE != mRecapitalizeMode) { + return; + } if (mIsAlphabetMode) { mIsInDoubleTapShiftKey = mSwitchActions.isInDoubleTapShiftKeyTimeout(); if (!mIsInDoubleTapShiftKey) { @@ -484,7 +478,6 @@ public final class KeyboardState { setShifted(MANUAL_SHIFT); mShiftKeyState.onPress(); } - mSwitchActions.startLongPressTimer(Constants.CODE_SHIFT); } } else { // In symbol mode, just toggle symbol and symbol more keyboard. @@ -617,6 +610,12 @@ public final class KeyboardState { break; } + if (code == Constants.CODE_CAPSLOCK) { + // Changing shift lock state will be handled at {@link #onPressShift()} when the shift + // key is released. + mLongPressShiftLockFired = true; + } + // If the code is a letter, update keyboard shift state. if (Constants.isLetterCode(code)) { updateAlphabetShiftState(autoCaps, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE); |
