am 3feb99fa: Merge "Save/restore alphabet shift locked state while rotating even in symbols mode"

* commit '3feb99fa6c5cf4b0a7d0ed2536b8b0891af884bf':
  Save/restore alphabet shift locked state while rotating even in symbols mode
main
Tadashi G. Takaoka 2012-01-31 02:28:48 -08:00 committed by Android Git Automerger
commit 0773460c34
2 changed files with 60 additions and 14 deletions

View File

@ -87,14 +87,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";
@ -124,11 +124,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;
@ -156,10 +156,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;
}
}

View File

@ -602,24 +602,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);
}
}