aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-12-05 18:16:40 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-12-05 18:54:43 +0900
commit6ddb07433fc8ed8675f0996a48790a05a97b61f0 (patch)
tree272baec0e7a4313f85623f178b17486f586e1ea2 /java/src
parent46831d5a4b135e5c21f2212d1d8aef09806800ed (diff)
downloadlatinime-6ddb07433fc8ed8675f0996a48790a05a97b61f0.tar.gz
latinime-6ddb07433fc8ed8675f0996a48790a05a97b61f0.tar.xz
latinime-6ddb07433fc8ed8675f0996a48790a05a97b61f0.zip
Merge setManualTemporaryUpperCase and setAutomaticTemporaryUpperCase
Bug: 5708602 Change-Id: I6a0b5f0dcccbb6331a271cd61a48c474a7800289
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java37
1 files changed, 19 insertions, 18 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index eff9b4229..19bfef38a 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -69,6 +69,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
private Resources mResources;
private KeyboardState mState;
+ private static final int UNSHIFT = 0;
+ private static final int MANUAL_SHIFT = 1;
+ private static final int AUTOMATIC_SHIFT = 2;
private KeyboardId mMainKeyboardId;
private KeyboardId mSymbolsKeyboardId;
@@ -391,7 +394,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
return false;
}
- public boolean isAutomaticTemporaryUpperCase() {
+ private boolean isAutomaticTemporaryUpperCase() {
LatinKeyboard latinKeyboard = getLatinKeyboard();
if (latinKeyboard != null)
return latinKeyboard.isAutomaticTemporaryUpperCase();
@@ -412,13 +415,19 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
return false;
}
- private void setManualTemporaryUpperCase(boolean shifted) {
+ private void setShift(int shiftMode) {
LatinKeyboard latinKeyboard = getLatinKeyboard();
- if (latinKeyboard != null) {
+ if (latinKeyboard == null)
+ return;
+ if (shiftMode == AUTOMATIC_SHIFT) {
+ latinKeyboard.setAutomaticTemporaryUpperCase();
+ mKeyboardView.invalidateAllKeys();
+ } else {
+ final boolean shifted = (shiftMode == 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().
+ // 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 && latinKeyboard.isShiftLocked()) {
latinKeyboard.setShiftLocked(false);
}
@@ -428,14 +437,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
}
- private void setAutomaticTemporaryUpperCase() {
- LatinKeyboard latinKeyboard = getLatinKeyboard();
- if (latinKeyboard != null) {
- latinKeyboard.setAutomaticTemporaryUpperCase();
- mKeyboardView.invalidateAllKeys();
- }
- }
-
private void setShiftLocked(boolean shiftLocked) {
LatinKeyboard latinKeyboard = getLatinKeyboard();
if (latinKeyboard != null && latinKeyboard.setShiftLocked(shiftLocked)) {
@@ -454,7 +455,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
+ " state=" + mState);
}
if (isAlphabetMode()) {
- setManualTemporaryUpperCase(!isShiftedOrShiftLocked());
+ setShift(isShiftedOrShiftLocked() ? UNSHIFT : MANUAL_SHIFT);
} else {
toggleShiftInSymbol();
}
@@ -516,9 +517,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
if (!isShiftLocked && !mState.isShiftKeyIgnoring()) {
if (mState.isShiftKeyReleasing() && mInputMethodService.getCurrentAutoCapsState()) {
// Only when shift key is releasing, automatic temporary upper case will be set.
- setAutomaticTemporaryUpperCase();
+ setShift(AUTOMATIC_SHIFT);
} else {
- setManualTemporaryUpperCase(mState.isShiftKeyMomentary());
+ setShift(mState.isShiftKeyMomentary() ? MANUAL_SHIFT : UNSHIFT);
}
}
}
@@ -541,11 +542,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
if (isShiftLocked) {
// Shift key is pressed while caps lock state, we will treat this state as shifted
// caps lock state and mark as if shift key pressed while normal state.
- setManualTemporaryUpperCase(true);
+ setShift(MANUAL_SHIFT);
} else if (isAutomaticTemporaryUpperCase) {
// Shift key is pressed while automatic temporary upper case, we have to move to
// manual temporary upper case.
- setManualTemporaryUpperCase(true);
+ setShift(MANUAL_SHIFT);
} else if (isShiftedOrShiftLocked) {
// In manual upper case state, we just record shift key has been pressing while
// shifted state.