Permalink
Browse files

Merge "Fix long press caps lock handling (DO NOT MERGE)" into ics-mr1

  • Loading branch information...
2 parents 620b1fa + 628ca7a commit 875c16adc3a42b156cc9f215fd6fbaa4e959a905 Tadashi G. Takaoka committed with Android (Google) Code Review Nov 17, 2011
@@ -170,6 +170,10 @@ public boolean isShiftLocked() {
return mShiftState.isShiftLocked();
}
+ public boolean isShiftLockShifted() {
+ return mShiftState.isShiftLockShifted();
+ }
+
public boolean setShifted(boolean newShiftState) {
for (final Key key : mShiftKeys) {
if (!newShiftState && !mShiftState.isShiftLocked()) {
@@ -386,6 +386,13 @@ public boolean isShiftLocked() {
return false;
}
+ private boolean isShiftLockShifted() {
+ LatinKeyboard latinKeyboard = getLatinKeyboard();
+ if (latinKeyboard != null)
+ return latinKeyboard.isShiftLockShifted();
+ return false;
+ }
+
public boolean isAutomaticTemporaryUpperCase() {
LatinKeyboard latinKeyboard = getLatinKeyboard();
if (latinKeyboard != null)
@@ -559,6 +566,9 @@ public void onReleaseShift(boolean withSliding) {
if (shiftKeyState.isMomentary()) {
// After chording input while normal state.
toggleShift();
+ } else if (isShiftLocked() && !isShiftLockShifted() && shiftKeyState.isPressing()
+ && !withSliding) {
+ // Shift has been long pressed, ignore this release.
} else if (isShiftLocked() && !shiftKeyState.isIgnoring() && !withSliding) {
// Shift has been pressed without chording while caps lock state.
toggleCapsLock();
@@ -351,7 +351,7 @@ private void onDoubleTapShiftKey(@SuppressWarnings("unused") PointerTracker trac
// calling setAlreadyProcessed() nor remove the tracker from mPointerQueue.
final int primaryCode = ignore ? Keyboard.CODE_HAPTIC_AND_AUDIO_FEEDBACK_ONLY
: Keyboard.CODE_CAPSLOCK;
- mKeyboardActionListener.onCodeInput(primaryCode, null, 0, 0);
+ invokeCodeInput(primaryCode);
}
// This default implementation returns a more keys panel.
@@ -399,18 +399,22 @@ protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) {
tracker.onLongPressed();
// Long pressing on 0 in phone number keypad gives you a '+'.
- return invokeOnKey(Keyboard.CODE_PLUS);
+ invokeCodeInput(Keyboard.CODE_PLUS);
+ invokeReleaseKey(primaryCode);
+ return true;
}
if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) {
tracker.onLongPressed();
- return invokeOnKey(Keyboard.CODE_CAPSLOCK);
+ invokeCodeInput(Keyboard.CODE_CAPSLOCK);
+ invokeReleaseKey(primaryCode);
+ return true;
}
}
if (primaryCode == Keyboard.CODE_SETTINGS || primaryCode == Keyboard.CODE_SPACE) {
// Both long pressing settings key and space key invoke IME switcher dialog.
- if (getKeyboardActionListener().onCustomRequest(
- LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
+ if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
tracker.onLongPressed();
+ invokeReleaseKey(primaryCode);
return true;
} else {
return openMoreKeysPanel(parentKey, tracker);
@@ -420,11 +424,18 @@ protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
}
}
- private boolean invokeOnKey(int primaryCode) {
+ private boolean invokeCustomRequest(int code) {
+ return getKeyboardActionListener().onCustomRequest(code);
+ }
+
+ private void invokeCodeInput(int primaryCode) {
getKeyboardActionListener().onCodeInput(primaryCode, null,
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
- return true;
+ }
+
+ private void invokeReleaseKey(int primaryCode) {
+ getKeyboardActionListener().onRelease(primaryCode, false);
}
private boolean openMoreKeysPanel(Key parentKey, PointerTracker tracker) {
@@ -103,6 +103,10 @@ public boolean isShiftLocked() {
return mState == SHIFT_LOCKED || mState == SHIFT_LOCK_SHIFTED;
}
+ public boolean isShiftLockShifted() {
+ return mState == SHIFT_LOCK_SHIFTED;
+ }
+
public boolean isAutomaticTemporaryUpperCase() {
return mState == AUTO_SHIFTED;
}

0 comments on commit 875c16a

Please sign in to comment.