am 2764e1df: Merge "Remove duplicate logic from KeyboardSwitcher and KeyboardState"
* commit '2764e1dffe17510fd10f54eaadf3f2fb3551cc7e': Remove duplicate logic from KeyboardSwitcher and KeyboardStatemain
commit
e3f90db6a4
|
@ -221,19 +221,16 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
Keyboard keyboard = getKeyboard();
|
Keyboard keyboard = getKeyboard();
|
||||||
if (keyboard == null)
|
if (keyboard == null)
|
||||||
return;
|
return;
|
||||||
if (shiftMode == AUTOMATIC_SHIFT) {
|
switch (shiftMode) {
|
||||||
|
case AUTOMATIC_SHIFT:
|
||||||
keyboard.setAutomaticTemporaryUpperCase();
|
keyboard.setAutomaticTemporaryUpperCase();
|
||||||
} else {
|
break;
|
||||||
final boolean shifted = (shiftMode == MANUAL_SHIFT);
|
case MANUAL_SHIFT:
|
||||||
// TODO: Remove duplicated logic in KeyboardState#setShifted
|
keyboard.setShifted(true);
|
||||||
// On non-distinct multi touch panel device, we should also turn off the shift locked
|
break;
|
||||||
// state when shift key is pressed to go to normal mode.
|
case UNSHIFT:
|
||||||
// On the other hand, on distinct multi touch panel device, turning off the shift
|
keyboard.setShifted(false);
|
||||||
// locked state with shift key pressing is handled by onReleaseShift().
|
break;
|
||||||
if (!hasDistinctMultitouch() && !shifted && mState.isShiftLocked()) {
|
|
||||||
setShiftLocked(false);
|
|
||||||
}
|
|
||||||
keyboard.setShifted(shifted);
|
|
||||||
}
|
}
|
||||||
mKeyboardView.invalidateAllKeys();
|
mKeyboardView.invalidateAllKeys();
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,29 +166,20 @@ 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: 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()) {
|
||||||
// Setting shift lock state should be delayed after
|
mSwitchActions.setShiftLocked(false);
|
||||||
// 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) {
|
||||||
|
|
Loading…
Reference in New Issue