am 7f8dd50b: Save automatic shift state while orientation changing

* commit '7f8dd50b8fe38738e52511e1d0bf082172b8932d':
  Save automatic shift state while orientation changing
main
Tadashi G. Takaoka 2013-05-02 00:18:51 -07:00 committed by Android Git Automerger
commit 3c1a18c6a6
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);