Fix double tap shift key to turn off capslock mode

Bug: 5873562
Change-Id: If1f5ae1684905c1418ae43e55df38509444d29e2
main
Tadashi G. Takaoka 2012-01-16 18:23:48 +09:00
parent d3f1caec0e
commit 7bc61ca183
2 changed files with 12 additions and 3 deletions

View File

@ -225,12 +225,13 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
keyboard.setAutomaticTemporaryUpperCase(); keyboard.setAutomaticTemporaryUpperCase();
} else { } else {
final boolean shifted = (shiftMode == MANUAL_SHIFT); final boolean shifted = (shiftMode == MANUAL_SHIFT);
// TODO: Remove duplicated logic in KeyboardState#setShifted
// On non-distinct multi touch panel device, we should also turn off the shift locked // On non-distinct multi touch panel device, we should also turn off the shift locked
// state when shift key is pressed to go to normal mode. // state when shift key is pressed to go to normal mode.
// On the other hand, on distinct multi touch panel device, turning off the shift // On the other hand, on distinct multi touch panel device, turning off the shift
// locked state with shift key pressing is handled by onReleaseShift(). // locked state with shift key pressing is handled by onReleaseShift().
if (!hasDistinctMultitouch() && !shifted && mState.isShiftLocked()) { if (!hasDistinctMultitouch() && !shifted && mState.isShiftLocked()) {
keyboard.setShiftLocked(false); setShiftLocked(false);
} }
keyboard.setShifted(shifted); keyboard.setShifted(shifted);
} }

View File

@ -166,21 +166,29 @@ public class KeyboardState {
if (DEBUG_STATE) { if (DEBUG_STATE) {
Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode)); Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode));
} }
// TODO: Remove this hack in conjunction with duplicated logic below.
boolean needsToTurnOffShiftLockedLater = false;
if (shiftMode == SwitchActions.AUTOMATIC_SHIFT) { if (shiftMode == SwitchActions.AUTOMATIC_SHIFT) {
mKeyboardShiftState.setAutomaticTemporaryUpperCase(); mKeyboardShiftState.setAutomaticTemporaryUpperCase();
} else { } else {
// TODO: Duplicated logic in KeyboardSwitcher#setShifted() // TODO: Remove duplicated logic in KeyboardSwitcher#setShifted()
final boolean shifted = (shiftMode == SwitchActions.MANUAL_SHIFT); final boolean shifted = (shiftMode == SwitchActions.MANUAL_SHIFT);
// On non-distinct multi touch panel device, we should also turn off the shift locked // On non-distinct multi touch panel device, we should also turn off the shift locked
// state when shift key is pressed to go to normal mode. // state when shift key is pressed to go to normal mode.
// On the other hand, on distinct multi touch panel device, turning off the shift // On the other hand, on distinct multi touch panel device, turning off the shift
// locked state with shift key pressing is handled by onReleaseShift(). // locked state with shift key pressing is handled by onReleaseShift().
if (!mHasDistinctMultitouch && !shifted && mKeyboardShiftState.isShiftLocked()) { if (!mHasDistinctMultitouch && !shifted && mKeyboardShiftState.isShiftLocked()) {
mKeyboardShiftState.setShiftLocked(false); // Setting shift lock state should be delayed after
// mSwitchActions.setShifted(shiftMode) is called, because in that call the state
// is referenced.
needsToTurnOffShiftLockedLater = true;
} }
mKeyboardShiftState.setShifted(shifted); mKeyboardShiftState.setShifted(shifted);
} }
mSwitchActions.setShifted(shiftMode); mSwitchActions.setShifted(shiftMode);
if (needsToTurnOffShiftLockedLater) {
mKeyboardShiftState.setShiftLocked(false);
}
} }
private void setShiftLocked(boolean shiftLocked) { private void setShiftLocked(boolean shiftLocked) {