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

Commit a393b9ba authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Hide IME switch button for single IME and subtype

Previously in [1] we started showing the IME switcher button also if we
had a single IME with a single subtype, if the IME specified a
(language) settings activity, to allow users to easily open this and add
keyboard languages. However, this is impacting users that accidentally
open the menu, as they previously did not have the button visible.

This reverts the change to also show the button if the current IME
specified a (language) settings activity.

  [1]: I1005cb6b10682f3e91a7ed847c290fcc206b5faa

Flag: android.view.inputmethod.ime_switcher_revamp
Test: show IME with a single IME and subtype enabled
Bug: 383059282
Change-Id: I590740e5e9dd8fca74000c69afc557e8a82836f8
parent 9856bf30
Loading
Loading
Loading
Loading
+5 −15
Original line number Diff line number Diff line
@@ -2723,17 +2723,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            return false;
        }

        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        if (Flags.imeSwitcherRevamp()) {
            // The IME switcher button should be shown when the current IME specified a
            // language settings activity.
            final var curImi = settings.getMethodMap().get(settings.getSelectedInputMethod());
            if (curImi != null && curImi.createImeLanguageSettingsActivityIntent() != null) {
                return true;
            }
        }

        return hasMultipleSubtypesForSwitcher(false /* nonAuxOnly */, settings);
        return hasMultipleSubtypesForSwitcher(false /* nonAuxOnly */, userId);
    }

    /**
@@ -2741,10 +2731,11 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
     * across all enabled IMEs for the given user.
     *
     * @param nonAuxOnly whether to check only for non auxiliary subtypes.
     * @param settings   the input method settings under the given user ID.
     * @param userId     the id of the user for which to check the number of subtypes.
     */
    private static boolean hasMultipleSubtypesForSwitcher(boolean nonAuxOnly,
            @NonNull InputMethodSettings settings) {
            @UserIdInt int userId) {
        final var settings = InputMethodSettingsRepository.get(userId);
        List<InputMethodInfo> imes = settings.getEnabledInputMethodListWithFilter(
                InputMethodInfo::shouldShowInInputMethodPicker);
        final int numImes = imes.size();
@@ -4130,8 +4121,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    @GuardedBy("ImfLock.class")
    private void onImeSwitchButtonClickLocked(int displayId, @NonNull UserData userData) {
        final int userId = userData.mUserId;
        final var settings = InputMethodSettingsRepository.get(userId);
        if (hasMultipleSubtypesForSwitcher(true /* nonAuxOnly */, settings)) {
        if (hasMultipleSubtypesForSwitcher(true /* nonAuxOnly */, userId)) {
            switchToNextInputMethodLocked(false /* onlyCurrentIme */, userData);
        } else {
            showInputMethodPickerFromSystem(