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

Commit 5731b939 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Remove KeyboardSwicther.toggleCapslock

Change-Id: Id613c06e2df770659095d78d42637aed063d0c70
parent 2a884404
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -256,13 +256,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
        }
    }

    /**
     * Toggle caps lock state triggered by user touch event.
     */
    public void toggleCapsLock() {
        mState.onToggleCapsLock();
    }

    /**
     * Update keyboard shift state triggered by connected EditText status change.
     */
+13 −17
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import com.android.inputmethod.keyboard.Keyboard;
 * The input events are {@link #onLoadKeyboard(String, boolean)}, {@link #onSaveKeyboardState()},
 * {@link #onPressKey(int)}, {@link #onReleaseKey(int, boolean)},
 * {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)},
 * {@link #onUpdateShiftState(boolean)}, and {@link #onToggleCapsLock()}.
 * {@link #onUpdateShiftState(boolean)}.
 *
 * The actions are {@link SwitchActions}'s methods.
 */
@@ -403,6 +403,18 @@ public class KeyboardState {
                    + " single=" + isSinglePointer
                    + " autoCaps=" + autoCaps + " " + this);
        }

        if (mIsAlphabetMode && code == Keyboard.CODE_CAPSLOCK) {
            if (mKeyboardShiftState.isShiftLocked()) {
                setShiftLocked(false);
                // Shift key is long pressed or double tapped while caps lock state, we will
                // toggle back to normal state. And mark as if shift key is released.
                mShiftKeyState.onRelease();
            } else {
                setShiftLocked(true);
            }
        }

        switch (mSwitchState) {
        case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
            // Only distinct multi touch devices can be in this state.
@@ -471,22 +483,6 @@ public class KeyboardState {
        }
    }

    public void onToggleCapsLock() {
        if (DEBUG_EVENT) {
            Log.d(TAG, "onToggleCapsLock: " + this);
        }
        if (mIsAlphabetMode) {
            if (mKeyboardShiftState.isShiftLocked()) {
                setShiftLocked(false);
                // Shift key is long pressed while caps lock state, we will toggle back to normal
                // state. And mark as if shift key is released.
                mShiftKeyState.onRelease();
            } else {
                setShiftLocked(true);
            }
        }
    }

    private static String shiftModeToString(int shiftMode) {
        switch (shiftMode) {
        case SwitchActions.UNSHIFT: return "UNSHIFT";
+1 −1
Original line number Diff line number Diff line
@@ -1267,7 +1267,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
            onSettingsKeyPressed();
            break;
        case Keyboard.CODE_CAPSLOCK:
            switcher.toggleCapsLock();
            // Caps lock code is handled in KeyboardSwitcher.onCodeInput() below.
            hapticAndAudioFeedback(primaryCode);
            break;
        case Keyboard.CODE_SHORTCUT:
+0 −6
Original line number Diff line number Diff line
@@ -342,8 +342,6 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase
        mSwitcher.onPressKey(CODE_SHIFT);
        assertAlphabetManualShifted();
        // Long press recognized in LatinKeyboardView.KeyTimerHandler.
        mSwitcher.toggleCapsLock();
        assertAlphabetShiftLocked();
        mSwitcher.onCodeInput(CODE_CAPSLOCK);
        assertAlphabetShiftLocked();
        mSwitcher.onReleaseKey(CODE_SHIFT);
@@ -355,8 +353,6 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase
        mSwitcher.onPressKey(CODE_SHIFT);
        assertAlphabetManualShifted();
        // Long press recognized in LatinKeyboardView.KeyTimerHandler.
        mSwitcher.toggleCapsLock();
        assertAlphabetNormal();
        mSwitcher.onCodeInput(CODE_CAPSLOCK);
        assertAlphabetNormal();
        mSwitcher.onReleaseKey(CODE_SHIFT);
@@ -396,8 +392,6 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase
        assertAlphabetManualShifted();
        // Second shift key tap.
        // Double tap recognized in LatinKeyboardView.KeyTimerHandler.
        mSwitcher.toggleCapsLock();
        assertAlphabetShiftLocked();
        mSwitcher.onCodeInput(CODE_CAPSLOCK);
        assertAlphabetShiftLocked();

+3 −3
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.inputmethod.keyboard.internal;

import com.android.inputmethod.keyboard.Keyboard;

public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
    @Override
    public boolean hasDistinctMultitouch() {
@@ -27,7 +25,7 @@ public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
    // Shift key chording input.
    public void testShiftChording() {
        // Press shift key and hold, enter into choring shift state.
        mSwitcher.onPressKey(Keyboard.CODE_SHIFT);
        mSwitcher.onPressKey(CODE_SHIFT);
        assertAlphabetManualShifted();

        // Press/release letter keys.
@@ -114,4 +112,6 @@ public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
    }

    // TODO: Multitouch test

    // TODO: n-Keys roll over test
}
Loading