Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f8dd50b authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Save automatic shift state while orientation changing

Bug: 8734294
Change-Id: Ib2bc262aacedf786a318c2fe1bd4420a21e7d847
parent 9e0ffd35
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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;
+11 −0
Original line number Diff line number Diff line
@@ -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);