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

Commit 792980d4 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Avoid calling switchToLastInputMethod when other IMEs are in effect (DO NOT MERGE)

Bug: 7299050
Change-Id: Ife6721a5fcbc4872bd36ffd8a8b81b04d73aebec
parent 448e7322
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -1219,22 +1219,25 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
        mConnection.performEditorAction(actionId);
        mConnection.performEditorAction(actionId);
    }
    }


    // TODO: Revise the language switch key behavior to make it much smarter and more reasonable.
    private void handleLanguageSwitchKey() {
    private void handleLanguageSwitchKey() {
        final boolean includesOtherImes = mCurrentSettings.mIncludesOtherImesInLanguageSwitchList;
        final IBinder token = getWindow().getWindow().getAttributes().token;
        final IBinder token = getWindow().getWindow().getAttributes().token;
        if (mCurrentSettings.mIncludesOtherImesInLanguageSwitchList) {
            mImm.switchToNextInputMethod(token, false /* onlyCurrentIme */);
            return;
        }
        if (mShouldSwitchToLastSubtype) {
        if (mShouldSwitchToLastSubtype) {
            final InputMethodSubtype lastSubtype = mImm.getLastInputMethodSubtype();
            final InputMethodSubtype lastSubtype = mImm.getLastInputMethodSubtype();
            final boolean lastSubtypeBelongsToThisIme =
            final boolean lastSubtypeBelongsToThisIme =
                    ImfUtils.checkIfSubtypeBelongsToThisImeAndEnabled(this, lastSubtype);
                    ImfUtils.checkIfSubtypeBelongsToThisImeAndEnabled(this, lastSubtype);
            if ((includesOtherImes || lastSubtypeBelongsToThisIme)
            if (lastSubtypeBelongsToThisIme && mImm.switchToLastInputMethod(token)) {
                    && mImm.switchToLastInputMethod(token)) {
                mShouldSwitchToLastSubtype = false;
                mShouldSwitchToLastSubtype = false;
            } else {
            } else {
                mImm.switchToNextInputMethod(token, !includesOtherImes);
                mImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
                mShouldSwitchToLastSubtype = true;
                mShouldSwitchToLastSubtype = true;
            }
            }
        } else {
        } else {
            mImm.switchToNextInputMethod(token, !includesOtherImes);
            mImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
        }
        }
    }
    }