aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java7
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java30
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java2
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateNonDistinctTests.java6
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTests.java6
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java4
6 files changed, 17 insertions, 38 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index fa87535b4..22ab3e4e5 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -257,13 +257,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
}
/**
- * Toggle caps lock state triggered by user touch event.
- */
- public void toggleCapsLock() {
- mState.onToggleCapsLock();
- }
-
- /**
* Update keyboard shift state triggered by connected EditText status change.
*/
public void updateShiftState() {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
index fbce937c6..c43b9852b 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java
@@ -29,7 +29,7 @@ import com.android.inputmethod.keyboard.Keyboard;
* The input events are {@link #onLoadKeyboard(String, boolean)}, {@link #onSaveKeyboardState()},
* {@link #onPressKey(int)}, {@link #onReleaseKey(int, boolean)},
* {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)},
- * {@link #onUpdateShiftState(boolean)}, and {@link #onToggleCapsLock()}.
+ * {@link #onUpdateShiftState(boolean)}.
*
* The actions are {@link SwitchActions}'s methods.
*/
@@ -403,6 +403,18 @@ public class KeyboardState {
+ " single=" + isSinglePointer
+ " autoCaps=" + autoCaps + " " + this);
}
+
+ if (mIsAlphabetMode && code == Keyboard.CODE_CAPSLOCK) {
+ if (mKeyboardShiftState.isShiftLocked()) {
+ setShiftLocked(false);
+ // Shift key is long pressed or double tapped while caps lock state, we will
+ // toggle back to normal state. And mark as if shift key is released.
+ mShiftKeyState.onRelease();
+ } else {
+ setShiftLocked(true);
+ }
+ }
+
switch (mSwitchState) {
case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
// Only distinct multi touch devices can be in this state.
@@ -471,22 +483,6 @@ public class KeyboardState {
}
}
- public void onToggleCapsLock() {
- if (DEBUG_EVENT) {
- Log.d(TAG, "onToggleCapsLock: " + this);
- }
- if (mIsAlphabetMode) {
- if (mKeyboardShiftState.isShiftLocked()) {
- setShiftLocked(false);
- // Shift key is long pressed while caps lock state, we will toggle back to normal
- // state. And mark as if shift key is released.
- mShiftKeyState.onRelease();
- } else {
- setShiftLocked(true);
- }
- }
- }
-
private static String shiftModeToString(int shiftMode) {
switch (shiftMode) {
case SwitchActions.UNSHIFT: return "UNSHIFT";
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index ee3b2d2e4..d11aaeb96 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1267,7 +1267,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
onSettingsKeyPressed();
break;
case Keyboard.CODE_CAPSLOCK:
- switcher.toggleCapsLock();
+ // Caps lock code is handled in KeyboardSwitcher.onCodeInput() below.
hapticAndAudioFeedback(primaryCode);
break;
case Keyboard.CODE_SHORTCUT:
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateNonDistinctTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateNonDistinctTests.java
index 59acd1666..e3f0e0718 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateNonDistinctTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateNonDistinctTests.java
@@ -342,8 +342,6 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase
mSwitcher.onPressKey(CODE_SHIFT);
assertAlphabetManualShifted();
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
- mSwitcher.toggleCapsLock();
- assertAlphabetShiftLocked();
mSwitcher.onCodeInput(CODE_CAPSLOCK);
assertAlphabetShiftLocked();
mSwitcher.onReleaseKey(CODE_SHIFT);
@@ -355,8 +353,6 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase
mSwitcher.onPressKey(CODE_SHIFT);
assertAlphabetManualShifted();
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
- mSwitcher.toggleCapsLock();
- assertAlphabetNormal();
mSwitcher.onCodeInput(CODE_CAPSLOCK);
assertAlphabetNormal();
mSwitcher.onReleaseKey(CODE_SHIFT);
@@ -396,8 +392,6 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase
assertAlphabetManualShifted();
// Second shift key tap.
// Double tap recognized in LatinKeyboardView.KeyTimerHandler.
- mSwitcher.toggleCapsLock();
- assertAlphabetShiftLocked();
mSwitcher.onCodeInput(CODE_CAPSLOCK);
assertAlphabetShiftLocked();
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTests.java
index fc5f68b1b..19339f72e 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTests.java
@@ -16,8 +16,6 @@
package com.android.inputmethod.keyboard.internal;
-import com.android.inputmethod.keyboard.Keyboard;
-
public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
@Override
public boolean hasDistinctMultitouch() {
@@ -27,7 +25,7 @@ public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
// Shift key chording input.
public void testShiftChording() {
// Press shift key and hold, enter into choring shift state.
- mSwitcher.onPressKey(Keyboard.CODE_SHIFT);
+ mSwitcher.onPressKey(CODE_SHIFT);
assertAlphabetManualShifted();
// Press/release letter keys.
@@ -114,4 +112,6 @@ public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
}
// TODO: Multitouch test
+
+ // TODO: n-Keys roll over test
}
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
index 71de0ce8a..1e294d179 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
@@ -121,10 +121,6 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState);
}
- public void toggleCapsLock() {
- mState.onToggleCapsLock();
- }
-
public void updateShiftState() {
mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState);
}