aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-01-16 14:55:34 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-01-16 19:16:26 +0900
commit58e782a2258fb7438cf2def88d25b61a0a6a4be6 (patch)
tree35830f0ae7239ffa90c390ac09f20fb4c48e6152 /java/src
parente47bd3f4fbf38ae20c5b61fac563a3f6152037a3 (diff)
downloadlatinime-58e782a2258fb7438cf2def88d25b61a0a6a4be6.tar.gz
latinime-58e782a2258fb7438cf2def88d25b61a0a6a4be6.tar.xz
latinime-58e782a2258fb7438cf2def88d25b61a0a6a4be6.zip
Remove duplicate logic from KeyboardSwitcher and KeyboardState
Change-Id: I1d331ee7f71501baa4ec2df01df39340499834e4
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java21
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java11
2 files changed, 10 insertions, 22 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index df61689e1..7ccb2323e 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -221,19 +221,16 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
Keyboard keyboard = getKeyboard();
if (keyboard == null)
return;
- if (shiftMode == AUTOMATIC_SHIFT) {
+ switch (shiftMode) {
+ case AUTOMATIC_SHIFT:
keyboard.setAutomaticTemporaryUpperCase();
- } else {
- 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
- // 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
- // locked state with shift key pressing is handled by onReleaseShift().
- if (!hasDistinctMultitouch() && !shifted && mState.isShiftLocked()) {
- setShiftLocked(false);
- }
- keyboard.setShifted(shifted);
+ break;
+ case MANUAL_SHIFT:
+ keyboard.setShifted(true);
+ break;
+ case UNSHIFT:
+ keyboard.setShifted(false);
+ break;
}
mKeyboardView.invalidateAllKeys();
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
index 609593e44..bb75111b4 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
@@ -166,29 +166,20 @@ public class KeyboardState {
if (DEBUG_STATE) {
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) {
mKeyboardShiftState.setAutomaticTemporaryUpperCase();
} else {
- // TODO: Remove duplicated logic in KeyboardSwitcher#setShifted()
final boolean shifted = (shiftMode == SwitchActions.MANUAL_SHIFT);
// 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.
// On the other hand, on distinct multi touch panel device, turning off the shift
// locked state with shift key pressing is handled by onReleaseShift().
if (!mHasDistinctMultitouch && !shifted && mKeyboardShiftState.isShiftLocked()) {
- // Setting shift lock state should be delayed after
- // mSwitchActions.setShifted(shiftMode) is called, because in that call the state
- // is referenced.
- needsToTurnOffShiftLockedLater = true;
+ mSwitchActions.setShiftLocked(false);
}
mKeyboardShiftState.setShifted(shifted);
}
mSwitchActions.setShifted(shiftMode);
- if (needsToTurnOffShiftLockedLater) {
- mKeyboardShiftState.setShiftLocked(false);
- }
}
private void setShiftLocked(boolean shiftLocked) {