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

Commit 57ffc002 authored by satok's avatar satok
Browse files

Add a way that subtype will be excluded from a last input method

Bug: 3382702

- Added SUBTYPE_EXTRAVALUE_EXCLUDE_FROM_LAST_IME and if subtype has this extra value,
It will be excluded from a last input method which will be called from switchToLastInputMethod

Change-Id: I03ae10e07f978dcc3a83dd77b10613048dce7f22
parent 9c265fcc
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -121,6 +121,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    private static final String SUBTYPE_MODE_KEYBOARD = "keyboard";
    private static final String SUBTYPE_MODE_VOICE = "voice";

    // TODO: Will formalize this value as API
    private static final String SUBTYPE_EXTRAVALUE_EXCLUDE_FROM_LAST_IME =
            "excludeFromLastInputMethod";

    final Context mContext;
    final Resources mRes;
    final Handler mHandler;
@@ -1901,13 +1905,27 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }
    }

    private boolean canAddToLastInputMethod(InputMethodSubtype subtype) {
        if (subtype == null) return true;
        String[] extraValues = subtype.getExtraValue().split(",");
        final int N = extraValues.length;
        for (int i = 0; i < N; ++i) {
            if (SUBTYPE_EXTRAVALUE_EXCLUDE_FROM_LAST_IME.equals(extraValues[i])) {
                return false;
            }
        }
        return true;
    }

    private void saveCurrentInputMethodAndSubtypeToHistory() {
        String subtypeId = NOT_A_SUBTYPE_ID_STR;
        if (mCurrentSubtype != null) {
            subtypeId = String.valueOf(mCurrentSubtype.hashCode());
        }
        if (canAddToLastInputMethod(mCurrentSubtype)) {
            mSettings.addSubtypeToHistory(mCurMethodId, subtypeId);
        }
    }

    private void setSelectedInputMethodAndSubtypeLocked(InputMethodInfo imi, int subtypeId,
            boolean setSubtypeOnly) {