From 757f8d96eea3dfb5951243d2ebb4b763db868471 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 26 Jan 2012 18:25:48 +0900 Subject: [PATCH] Add KeyboardState.SwitchActions.setAlphabetShiftLockShifted Change-Id: I6c49d8eb0a8272840ff03e0940d88a31c3d20bd9 --- .../inputmethod/keyboard/KeyboardSwitcher.java | 12 ++++++++++++ .../keyboard/internal/KeyboardState.java | 15 +++++++-------- .../internal/KeyboardStateMultiTouchTests.java | 4 ++-- .../internal/KeyboardStateSingleTouchTests.java | 12 ++++++------ .../keyboard/internal/MockKeyboardSwitcher.java | 11 +++++++++-- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 1398bae2a..5a59cc1c7 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -240,6 +240,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, private static final int ALPHABET_MANUAL_SHIFTED = 1; private static final int ALPHABET_AUTOMATIC_SHIFTED = 2; private static final int ALPHABET_SHIFT_LOCKED = 3; + private static final int ALPHABET_SHIFT_LOCK_SHIFTED = 4; // TODO: Remove this method. private void updateAlphabetKeyboardShiftState(int shiftMode) { @@ -260,6 +261,10 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, case ALPHABET_SHIFT_LOCKED: keyboard.setShiftLocked(true); break; + case ALPHABET_SHIFT_LOCK_SHIFTED: + keyboard.setShiftLocked(true); + keyboard.setShifted(true); + break; } mKeyboardView.invalidateAllKeys(); if (shiftMode != ALPHABET_SHIFT_LOCKED) { @@ -298,6 +303,13 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, updateAlphabetKeyboardShiftState(ALPHABET_SHIFT_LOCKED); } + // Implements {@link KeyboardState.SwitchActions}. + @Override + public void setAlphabetShiftLockShiftedKeyboard() { + setKeyboard(mKeyboardSet.getMainKeyboard()); + updateAlphabetKeyboardShiftState(ALPHABET_SHIFT_LOCK_SHIFTED); + } + // Implements {@link KeyboardState.SwitchActions}. @Override public void setSymbolsKeyboard() { diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index 38c31adce..a89356c50 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -43,8 +43,7 @@ public class KeyboardState { public void setAlphabetManualShiftedKeyboard(); public void setAlphabetAutomaticShiftedKeyboard(); public void setAlphabetShiftLockedKeyboard(); - // TODO: Add this. - //public void setAlphabetShiftLockShiftedKeyboard(); + public void setAlphabetShiftLockShiftedKeyboard(); public void setSymbolsKeyboard(); public void setSymbolsShiftedKeyboard(); @@ -157,14 +156,10 @@ public class KeyboardState { } } - // TODO: Remove this method. - public boolean isShiftLocked() { - return mAlphabetShiftState.isShiftLocked(); - } - private static final int UNSHIFT = 0; private static final int MANUAL_SHIFT = 1; private static final int AUTOMATIC_SHIFT = 2; + private static final int SHIFT_LOCK_SHIFTED = 3; private void setShifted(int shiftMode) { if (DEBUG_ACTION) { @@ -198,6 +193,10 @@ public class KeyboardState { mSwitchActions.setAlphabetKeyboard(); } break; + case SHIFT_LOCK_SHIFTED: + mAlphabetShiftState.setShifted(true); + mSwitchActions.setAlphabetShiftLockShiftedKeyboard(); + break; } } @@ -349,7 +348,7 @@ public class KeyboardState { if (mAlphabetShiftState.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. - setShifted(MANUAL_SHIFT); + setShifted(SHIFT_LOCK_SHIFTED); mShiftKeyState.onPress(); } else if (mAlphabetShiftState.isAutomaticTemporaryUpperCase()) { // Shift key is pressed while automatic temporary upper case, we have to move to diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java index bce63362a..d1887a1b9 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java @@ -40,9 +40,9 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press shift key and hold, enter into choring shift state. - pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + pressKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED); // Press/release letter key. - chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + chordingPressAndReleaseKey('Z', ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED); // Release shift key, switch back to alphabet shift locked. releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED); diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java index 2204fca89..a1f28dce1 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java @@ -246,13 +246,13 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { pressAndReleaseKey(CODE_SPACE, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); // Press/release shift key, back to alphabet. - pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Long press shift key, back to alphabet. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); } // Double tap shift key. @@ -265,7 +265,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { secondTapShiftKey(ALPHABET_SHIFT_LOCKED); // First shift key tap. - pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); // Second shift key tap. // Second tap is ignored in LatinKeyboardView.KeyTimerHandler. } @@ -289,7 +289,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Update shift state, remained in alphabet shift locked. updateShiftState(ALPHABET_SHIFT_LOCKED); // Long press shift key, back to alphabet. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); @@ -320,7 +320,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Update shift state, remained in alphabet shift locked (not automatic shifted). updateShiftState(ALPHABET_SHIFT_LOCKED); // Long press shift key, back to alphabet. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); // Load keyboard, should be in automatic shifted. loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); @@ -375,7 +375,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Alphabet shift locked -> "?123" key + letter -> alphabet shift locked. // Press and slide from shift key, enter alphabet shifted. - pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + pressAndSlideFromKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCKED); // Enter/release letter key, switch back to shift locked. pressAndReleaseKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); } diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java index fce698a1e..f17b45235 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java @@ -40,8 +40,9 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { public static final int ALPHABET_MANUAL_SHIFTED = 1; public static final int ALPHABET_AUTOMATIC_SHIFTED = 2; public static final int ALPHABET_SHIFT_LOCKED = 3; - public static final int SYMBOLS_UNSHIFTED = 4; - public static final int SYMBOLS_SHIFTED = 5; + public static final int ALPHABET_SHIFT_LOCK_SHIFTED = 4; + public static final int SYMBOLS_UNSHIFTED = 5; + public static final int SYMBOLS_SHIFTED = 6; } private int mLayout = Constants.ALPHABET_UNSHIFTED; @@ -62,6 +63,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { case Constants.ALPHABET_MANUAL_SHIFTED: return "ALPHABET_MANUAL_SHIFTED"; case Constants.ALPHABET_AUTOMATIC_SHIFTED: return "ALPHABET_AUTOMATIC_SHIFTED"; case Constants.ALPHABET_SHIFT_LOCKED: return "ALPHABET_SHIFT_LOCKED"; + case Constants.ALPHABET_SHIFT_LOCK_SHIFTED: return "ALPHABET_SHIFT_LOCK_SHIFTED"; case Constants.SYMBOLS_UNSHIFTED: return "SYMBOLS_UNSHIFTED"; case Constants.SYMBOLS_SHIFTED: return "SYMBOLS_SHIFTED"; default: return "UNKNOWN<" + layoutId + ">"; @@ -92,6 +94,11 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { mLayout = Constants.ALPHABET_SHIFT_LOCKED; } + @Override + public void setAlphabetShiftLockShiftedKeyboard() { + mLayout = Constants.ALPHABET_SHIFT_LOCK_SHIFTED; + } + @Override public void setSymbolsKeyboard() { mLayout = Constants.SYMBOLS_UNSHIFTED;