Save automatic shift state while orientation changing

Bug: 8734294
Change-Id: Ib2bc262aacedf786a318c2fe1bd4420a21e7d847
This commit is contained in:
Tadashi G. Takaoka 2013-05-02 14:43:03 +09:00
parent 9e0ffd35a5
commit 7f8dd50b8f
2 changed files with 18 additions and 2 deletions

View file

@ -95,6 +95,8 @@ public final class KeyboardState {
static final class SavedKeyboardState {
public boolean mIsValid;
public boolean mIsAlphabetMode;
// TODO: Use <code>int</code> 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;

View file

@ -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);