From 7f8dd50b8fe38738e52511e1d0bf082172b8932d Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 2 May 2013 14:43:03 +0900 Subject: [PATCH] Save automatic shift state while orientation changing Bug: 8734294 Change-Id: Ib2bc262aacedf786a318c2fe1bd4420a21e7d847 --- .../inputmethod/keyboard/internal/KeyboardState.java | 9 +++++++-- .../internal/KeyboardStateSingleTouchTests.java | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index b1d499702..71853f7ad 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -95,6 +95,8 @@ public final class KeyboardState { static final class SavedKeyboardState { public boolean mIsValid; public boolean mIsAlphabetMode; + // TODO: Use int to represent saved shift state. + public boolean mIsAlphabetAutomaticShifted; public boolean mIsAlphabetShiftLocked; public boolean mIsShifted; @@ -103,7 +105,8 @@ public final class KeyboardState { if (!mIsValid) return "INVALID"; if (mIsAlphabetMode) { if (mIsAlphabetShiftLocked) return "ALPHABET_SHIFT_LOCKED"; - return mIsShifted ? "ALPHABET_SHIFTED" : "ALPHABET"; + return mIsAlphabetAutomaticShifted ? "ALPHABET_AUTOMATIC_SHIFTED" + : (mIsShifted ? "ALPHABET_SHIFTED" : "ALPHABET"); } else { return mIsShifted ? "SYMBOLS_SHIFTED" : "SYMBOLS"; } @@ -133,6 +136,7 @@ public final class KeyboardState { state.mIsAlphabetMode = mIsAlphabetMode; if (mIsAlphabetMode) { state.mIsAlphabetShiftLocked = mAlphabetShiftState.isShiftLocked(); + state.mIsAlphabetAutomaticShifted = mAlphabetShiftState.isAutomaticShifted(); state.mIsShifted = !state.mIsAlphabetShiftLocked && mAlphabetShiftState.isShiftedOrShiftLocked(); } else { @@ -166,7 +170,8 @@ public final class KeyboardState { if (state.mIsAlphabetMode) { setShiftLocked(state.mIsAlphabetShiftLocked); if (!state.mIsAlphabetShiftLocked) { - setShifted(state.mIsShifted ? MANUAL_SHIFT : UNSHIFT); + setShifted(state.mIsAlphabetAutomaticShifted ? AUTOMATIC_SHIFT + : (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 df9ce5e31..a3f9dbdcc 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java @@ -597,6 +597,17 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Rotate device, remain in alphabet. rotateDevice(ALPHABET_UNSHIFTED); + // Alphabet automatic shifted -> rotate -> automatic shifted. + // Set capitalize the first character of all words mode. + setAutoCapsMode(CAP_MODE_WORDS); + // Press/release auto caps trigger letter to enter alphabet automatic shifted. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + // Rotate device, remain in alphabet. + rotateDevice(ALPHABET_AUTOMATIC_SHIFTED); + setAutoCapsMode(CAP_MODE_OFF); + // Press/release auto caps trigger letter to reset shift state. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_AUTOMATIC_SHIFTED, ALPHABET_UNSHIFTED); + // Alphabet shifted -> rotate -> alphabet shifted. // Press/release shift key, enter alphabet shifted. pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);