From 2959fc0f13ec29e05eda2c4a1e9a728350a80557 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 29 May 2012 15:47:57 +0900 Subject: Delay shift lock transient until long pressed shift key is released Bug: 5424586 Change-Id: Ib602af1b38b1b109bdac9cb0c53132169556db2f --- .../inputmethod/keyboard/internal/KeyboardState.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index c85122ad3..43ffb85f7 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -85,6 +85,9 @@ public class KeyboardState { private boolean mPrevMainKeyboardWasShiftLocked; private boolean mPrevSymbolsKeyboardWasShifted; + // For handling long press. + private boolean mLongPressShiftLockFired; + // For handling double tap. private boolean mIsInAlphabetUnshiftedFromShifted; private boolean mIsInDoubleTapShiftKey; @@ -312,6 +315,7 @@ public class KeyboardState { } else { mSwitchActions.cancelDoubleTapTimer(); mSwitchActions.cancelLongPressTimer(); + mLongPressShiftLockFired = false; mShiftKeyState.onOtherKeyPressed(); mSymbolKeyState.onOtherKeyPressed(); // It is required to reset the auto caps state when all of the following conditions @@ -375,15 +379,7 @@ public class KeyboardState { ResearchLogger.keyboardState_onLongPressTimeout(code, this); } if (mIsAlphabetMode && code == Keyboard.CODE_SHIFT) { - if (mAlphabetShiftState.isShiftLocked()) { - setShiftLocked(false); - // Shift key is long pressed while shift locked state, we will toggle back to normal - // state. And mark as if shift key is released. - mShiftKeyState.onRelease(); - } else { - // Shift key is long pressed while shift unlocked state. - setShiftLocked(true); - } + mLongPressShiftLockFired = true; mSwitchActions.hapticAndAudioFeedback(code); } } @@ -413,6 +409,7 @@ public class KeyboardState { } private void onPressShift() { + mLongPressShiftLockFired = false; if (mIsAlphabetMode) { mIsInDoubleTapShiftKey = mSwitchActions.isInDoubleTapTimeout(); if (!mIsInDoubleTapShiftKey) { @@ -466,6 +463,8 @@ public class KeyboardState { // Double tap shift key has been handled in {@link #onPressShift}, so that just // ignore this release shift key here. mIsInDoubleTapShiftKey = false; + } else if (mLongPressShiftLockFired) { + setShiftLocked(!mAlphabetShiftState.isShiftLocked()); } else if (mShiftKeyState.isChording()) { if (mAlphabetShiftState.isShiftLockShifted()) { // After chording input while shift locked state. -- cgit v1.2.3-83-g751a