From 49bd49c8fbc394d277e89e8d105450d3e2818f50 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 31 Jan 2012 17:29:40 +0900 Subject: [PATCH] Save/restore alphabet shift locked state while rotating even in symbols mode Bug: 5730212 Change-Id: Id2342dacd149d6385d61001f880ebcd1883cf0b4 --- .../keyboard/internal/KeyboardState.java | 16 ++--- .../KeyboardStateSingleTouchTests.java | 58 ++++++++++++++++--- 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index 4af4e3cdf..38837f519 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -80,14 +80,14 @@ public class KeyboardState { static class SavedKeyboardState { public boolean mIsValid; public boolean mIsAlphabetMode; - public boolean mIsShiftLocked; + public boolean mIsAlphabetShiftLocked; public boolean mIsShifted; @Override public String toString() { if (!mIsValid) return "INVALID"; if (mIsAlphabetMode) { - if (mIsShiftLocked) return "ALPHABET_SHIFT_LOCKED"; + if (mIsAlphabetShiftLocked) return "ALPHABET_SHIFT_LOCKED"; return mIsShifted ? "ALPHABET_SHIFTED" : "ALPHABET"; } else { return mIsShifted ? "SYMBOLS_SHIFTED" : "SYMBOLS"; @@ -117,11 +117,11 @@ public class KeyboardState { final SavedKeyboardState state = mSavedKeyboardState; state.mIsAlphabetMode = mIsAlphabetMode; if (mIsAlphabetMode) { - state.mIsShiftLocked = mAlphabetShiftState.isShiftLocked(); - state.mIsShifted = !state.mIsShiftLocked + state.mIsAlphabetShiftLocked = mAlphabetShiftState.isShiftLocked(); + state.mIsShifted = !state.mIsAlphabetShiftLocked && mAlphabetShiftState.isShiftedOrShiftLocked(); } else { - state.mIsShiftLocked = false; + state.mIsAlphabetShiftLocked = mPrevMainKeyboardWasShiftLocked; state.mIsShifted = mIsSymbolShifted; } state.mIsValid = true; @@ -149,10 +149,12 @@ public class KeyboardState { state.mIsValid = false; if (state.mIsAlphabetMode) { - setShiftLocked(state.mIsShiftLocked); - if (!state.mIsShiftLocked) { + setShiftLocked(state.mIsAlphabetShiftLocked); + if (!state.mIsAlphabetShiftLocked) { setShifted(state.mIsShifted ? MANUAL_SHIFT : UNSHIFT); } + } else { + mPrevMainKeyboardWasShiftLocked = state.mIsAlphabetShiftLocked; } } diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java index e2feb9e84..2b11b636f 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java @@ -576,24 +576,68 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Change orientation. public void testChangeOrientation() { - // Press/release shift key. + // Alphabet -> rotate -> alphabet. + updateShiftState(ALPHABET_UNSHIFTED); + // Rotate device, remain in alphabet. + rotateDevice(ALPHABET_UNSHIFTED); + + // Alphabet shifted -> rotate -> alphabet shifted. + // Press/release shift key, enter alphabet shifted. pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); - // Rotate device. + // Rotate device, remain in alphabet shifted. rotateDevice(ALPHABET_MANUAL_SHIFTED); + // Alphabet shift locked -> rotate -> alphabet shift locked. // Long press shift key, enter alphabet shift locked. longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); - // Rotate device. + // Rotate device, remain in alphabet shift locked. rotateDevice(ALPHABET_SHIFT_LOCKED); - // Press/release "?123" key. + // Alphabet shift locked -> symbols -> rotate -> symbols -> + // Alphabet shift locked. + // Press/release "?123" key, enter symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Rotate device. + // Rotate device, remain in symbols, rotateDevice(SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, alphabet shift locked state should be maintained. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - // Press/release "=\<" key. + // Alphabet shift locked -> symbols shifted -> rotate -> symbols shifted -> + // Alphabet shift locked. + // Press/release "?123" key, enter symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter symbols shifted. pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Rotate device. + // Rotate device, remain in symbols shifted. rotateDevice(SYMBOLS_SHIFTED); + // Press/release "ABC" key, alphabet shift locked state should be maintained. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> symbols shifted -> alphabet shift locked -> rotate -> + // Alphabet shift locked -> symbols. + // Press/release "?123" key, enter symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, enter alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Rotate device, remain in alphabet shift locked. + rotateDevice(ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter symbols (not symbols shifted). + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + + // Alphabet -> symbols shifted -> alphabet -> rotate -> + // Alphabet -> symbols. + loadKeyboard(ALPHABET_UNSHIFTED); + // Press/release "?123" key, enter symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, enter alphabet. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Rotate device, remain in alphabet shift locked. + rotateDevice(ALPHABET_UNSHIFTED); + // Press/release "?123" key, enter symbols (not symbols shifted). + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); } }