summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-11-16 11:51:19 -0800
committerTadashi G. Takaoka <takaoka@google.com>2011-11-16 16:50:44 -0800
commit628ca7a8549ddbb908f6aacb8fd9707f852e653f (patch)
tree2b26d6ff2460656a8f8948f6aae7f0f6afd3722a
parent25cbe8924a7ec5c45914c8818b5ad7b39e1f6103 (diff)
downloadLatinIME-628ca7a8549ddbb908f6aacb8fd9707f852e653f.tar.gz
Fix long press caps lock handling (DO NOT MERGE)
This is cherry-pick of I3850f283. Bug: 5627467 Change-Id: If46dcbe5bac42b975bd001fefb9f11520a0abb70
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java10
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java25
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java4
4 files changed, 36 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index a57b9d172..4578507fc 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -170,6 +170,10 @@ public class Keyboard {
return mShiftState.isShiftLocked();
}
+ public boolean isShiftLockShifted() {
+ return mShiftState.isShiftLockShifted();
+ }
+
public boolean setShifted(boolean newShiftState) {
for (final Key key : mShiftKeys) {
if (!newShiftState && !mShiftState.isShiftLocked()) {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 83871a602..ac718fc62 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -386,6 +386,13 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
return false;
}
+ private boolean isShiftLockShifted() {
+ LatinKeyboard latinKeyboard = getLatinKeyboard();
+ if (latinKeyboard != null)
+ return latinKeyboard.isShiftLockShifted();
+ return false;
+ }
+
public boolean isAutomaticTemporaryUpperCase() {
LatinKeyboard latinKeyboard = getLatinKeyboard();
if (latinKeyboard != null)
@@ -559,6 +566,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
if (shiftKeyState.isMomentary()) {
// After chording input while normal state.
toggleShift();
+ } else if (isShiftLocked() && !isShiftLockShifted() && shiftKeyState.isPressing()
+ && !withSliding) {
+ // Shift has been long pressed, ignore this release.
} else if (isShiftLocked() && !shiftKeyState.isIgnoring() && !withSliding) {
// Shift has been pressed without chording while caps lock state.
toggleCapsLock();
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index aab52e139..6ce3876b6 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -351,7 +351,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
// calling setAlreadyProcessed() nor remove the tracker from mPointerQueue.
final int primaryCode = ignore ? Keyboard.CODE_HAPTIC_AND_AUDIO_FEEDBACK_ONLY
: Keyboard.CODE_CAPSLOCK;
- mKeyboardActionListener.onCodeInput(primaryCode, null, 0, 0);
+ invokeCodeInput(primaryCode);
}
// This default implementation returns a more keys panel.
@@ -399,18 +399,22 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) {
tracker.onLongPressed();
// Long pressing on 0 in phone number keypad gives you a '+'.
- return invokeOnKey(Keyboard.CODE_PLUS);
+ invokeCodeInput(Keyboard.CODE_PLUS);
+ invokeReleaseKey(primaryCode);
+ return true;
}
if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) {
tracker.onLongPressed();
- return invokeOnKey(Keyboard.CODE_CAPSLOCK);
+ invokeCodeInput(Keyboard.CODE_CAPSLOCK);
+ invokeReleaseKey(primaryCode);
+ return true;
}
}
if (primaryCode == Keyboard.CODE_SETTINGS || primaryCode == Keyboard.CODE_SPACE) {
// Both long pressing settings key and space key invoke IME switcher dialog.
- if (getKeyboardActionListener().onCustomRequest(
- LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
+ if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
tracker.onLongPressed();
+ invokeReleaseKey(primaryCode);
return true;
} else {
return openMoreKeysPanel(parentKey, tracker);
@@ -420,11 +424,18 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
}
}
- private boolean invokeOnKey(int primaryCode) {
+ private boolean invokeCustomRequest(int code) {
+ return getKeyboardActionListener().onCustomRequest(code);
+ }
+
+ private void invokeCodeInput(int primaryCode) {
getKeyboardActionListener().onCodeInput(primaryCode, null,
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
- return true;
+ }
+
+ private void invokeReleaseKey(int primaryCode) {
+ getKeyboardActionListener().onRelease(primaryCode, false);
}
private boolean openMoreKeysPanel(Key parentKey, PointerTracker tracker) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
index fd98456a8..28a53cedc 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
@@ -103,6 +103,10 @@ public class KeyboardShiftState {
return mState == SHIFT_LOCKED || mState == SHIFT_LOCK_SHIFTED;
}
+ public boolean isShiftLockShifted() {
+ return mState == SHIFT_LOCK_SHIFTED;
+ }
+
public boolean isAutomaticTemporaryUpperCase() {
return mState == AUTO_SHIFTED;
}