aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 76f774c96..7afee3fad 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -227,6 +227,9 @@ public class LatinIME extends InputMethodService
private int mDeleteCount;
private long mLastKeyTime;
+ // Shift modifier key state
+ private ModifierKeyState mShiftKeyState = new ModifierKeyState();
+
private Tutorial mTutorial;
private AudioManager mAudioManager;
@@ -976,7 +979,8 @@ public class LatinIME extends InputMethodService
public void updateShiftKeyState(EditorInfo attr) {
InputConnection ic = getCurrentInputConnection();
if (ic != null && attr != null && mKeyboardSwitcher.isAlphabetMode()) {
- mKeyboardSwitcher.setShifted(mCapsLock || getCursorCapsMode(ic, attr) != 0);
+ mKeyboardSwitcher.setShifted(mShiftKeyState.isMomentary() || mCapsLock
+ || getCursorCapsMode(ic, attr) != 0);
}
}
@@ -1233,12 +1237,20 @@ public class LatinIME extends InputMethodService
ic.endBatchEdit();
}
+ private void resetShift() {
+ handleShiftInternal(true);
+ }
+
private void handleShift() {
+ handleShiftInternal(false);
+ }
+
+ private void handleShiftInternal(boolean forceNormal) {
mHandler.removeMessages(MSG_UPDATE_SHIFT_STATE);
KeyboardSwitcher switcher = mKeyboardSwitcher;
LatinKeyboardView inputView = switcher.getInputView();
if (switcher.isAlphabetMode()) {
- if (mCapsLock) {
+ if (mCapsLock || forceNormal) {
mCapsLock = false;
switcher.setShifted(false);
} else if (inputView != null) {
@@ -2146,15 +2158,26 @@ public class LatinIME extends InputMethodService
vibrate();
playKeyClick(primaryCode);
if (primaryCode == Keyboard.KEYCODE_SHIFT) {
+ mShiftKeyState.onPress();
handleShift();
+ } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
+ // TODO: We should handle KEYCODE_MODE_CHANGE (symbol) here as well.
+ } else {
+ mShiftKeyState.onOtherKeyPressed();
}
- // TODO: We should handle KEYCODE_MODE_CHANGE (symbol) here as well.
}
public void onRelease(int primaryCode) {
// Reset any drag flags in the keyboard
((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).keyReleased();
//vibrate();
+ if (primaryCode == Keyboard.KEYCODE_SHIFT) {
+ if (mShiftKeyState.isMomentary())
+ resetShift();
+ mShiftKeyState.onRelease();
+ } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
+ // TODO: We should handle KEYCODE_MODE_CHANGE (symbol) here as well.
+ }
}
private FieldContext makeFieldContext() {