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

Commit e3803800 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Fixed accidental switch to symbols mode from alphabet.

The KeyboardSwitcher was remembering state from a previous edittext
where the user was in symbols mode and applying the switch code
when user hits space in the new edittext for the first time.
Make sure to reset the state when a new keyboard mode is requested.

Also make sure that we don't switch from symbols to alphabet keyboard
when editing in a number/datetime field and hitting space.
parent 5d11ccc2
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ public class KeyboardSwitcher {
    private int mImeOptions;
    private int mTextMode = MODE_TEXT_QWERTY;
    private boolean mIsSymbols;
    private boolean mPreferSymbols;
    private int mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;

    private int mLastDisplayWidth;
@@ -114,7 +115,10 @@ public class KeyboardSwitcher {
    }

    void setKeyboardMode(int mode, int imeOptions) {
        setKeyboardMode(mode, imeOptions, false);
        mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
        mPreferSymbols = mode == MODE_SYMBOLS;
        setKeyboardMode(mode == MODE_SYMBOLS ? MODE_TEXT : mode, imeOptions,
                mPreferSymbols);
    }

    void setKeyboardMode(int mode, int imeOptions, boolean isSymbols) {
@@ -233,7 +237,7 @@ public class KeyboardSwitcher {

    void toggleSymbols() {
        setKeyboardMode(mMode, mImeOptions, !mIsSymbols);
        if (mIsSymbols) {
        if (mIsSymbols && !mPreferSymbols) {
            mSymbolsModeState = SYMBOLS_MODE_STATE_BEGIN;
        } else {
            mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
+1 −2
Original line number Diff line number Diff line
@@ -260,9 +260,8 @@ public class LatinIME extends InputMethodService
        switch (attribute.inputType&EditorInfo.TYPE_MASK_CLASS) {
            case EditorInfo.TYPE_CLASS_NUMBER:
            case EditorInfo.TYPE_CLASS_DATETIME:
                mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT,
                mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_SYMBOLS,
                        attribute.imeOptions);
                mKeyboardSwitcher.toggleSymbols();
                break;
            case EditorInfo.TYPE_CLASS_PHONE:
                mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_PHONE,