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

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

Revert "Use old IME Switch menu on watch and small screen"

This reverts commit 5c1f0775.

Reason for revert: Menu issue on small screens fixed in Icc1d6403d8368eba9ca4535eb6ca0062c59b32bc

Change-Id: I56a5081d27ea2e332837a1eaad0faa53dba06f30
parent 0e69a056
Loading
Loading
Loading
Loading
+15 −40
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ import android.content.pm.PackageManagerInternal;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.hardware.input.InputManager;
import android.inputmethodservice.InputMethodService;
@@ -302,28 +301,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    @NonNull
    private final String[] mNonPreemptibleInputMethods;

    /**
     * Whether the new Input Method Switcher menu is enabled.
     *
     * @see #shouldEnableNewInputMethodSwitcherMenu
     */
    @SharedByAllUsersField
    private final boolean mNewInputMethodSwitcherMenuEnabled;

    /**
     * Returns {@code true} if the new Input Method Switcher menu is enabled. This will be
     * {@code false} for watches and small screen devices.
     *
     * @param context the context to check the device configuration for.
     */
    private static boolean shouldEnableNewInputMethodSwitcherMenu(@NonNull Context context) {
        final boolean isWatch = context.getPackageManager()
                .hasSystemFeature(PackageManager.FEATURE_WATCH);
        final boolean isSmallScreen = (context.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL;
        return Flags.imeSwitcherRevamp() && !isWatch && !isSmallScreen;
    }

    /**
     * See {@link #shouldEnableConcurrentMultiUserMode(Context)} about when set to be {@code true}.
     */
@@ -612,7 +589,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    private void onSecureSettingsChangedLocked(@NonNull String key, @UserIdInt int userId) {
        switch (key) {
            case Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD: {
                if (!mNewInputMethodSwitcherMenuEnabled) {
                if (!Flags.imeSwitcherRevamp()) {
                    if (userId == mCurrentUserId) {
                        mMenuController.updateKeyboardFromSettingsLocked(userId);
                    }
@@ -680,7 +657,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                        return;
                    }
                    final int userId = mCurrentUserId;
                    if (mNewInputMethodSwitcherMenuEnabled) {
                    if (Flags.imeSwitcherRevamp()) {
                        final var bindingController = getInputMethodBindingController(userId);
                        mMenuControllerNew.hide(bindingController.getCurTokenDisplayId(), userId);
                    } else {
@@ -1205,7 +1182,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            mUserManagerInternal = LocalServices.getService(UserManagerInternal.class);

            mSlotIme = mContext.getString(com.android.internal.R.string.status_bar_ime);
            mNewInputMethodSwitcherMenuEnabled = shouldEnableNewInputMethodSwitcherMenu(mContext);

            mShowOngoingImeSwitcherForPhones = false;

@@ -1221,7 +1197,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                            : bindingControllerFactory, visibilityStateComputerFactory);

            mMenuController = new InputMethodMenuController(this);
            mMenuControllerNew = mNewInputMethodSwitcherMenuEnabled
            mMenuControllerNew = Flags.imeSwitcherRevamp()
                    ? new InputMethodMenuControllerNew() : null;
            mVisibilityApplier = new DefaultImeVisibilityApplier(this);

@@ -1810,7 +1786,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    ImeTracker.PHASE_SERVER_WAIT_IME);
            userData.mCurStatsToken = null;
            // TODO: Make mMenuController multi-user aware
            if (mNewInputMethodSwitcherMenuEnabled) {
            if (Flags.imeSwitcherRevamp()) {
                mMenuControllerNew.hide(bindingController.getCurTokenDisplayId(), userId);
            } else {
                mMenuController.hideInputMethodMenuLocked(userId);
@@ -2620,7 +2596,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        if (!mShowOngoingImeSwitcherForPhones) return false;
        // When the IME switcher dialog is shown, the IME switcher button should be hidden.
        // TODO(b/305849394): Make mMenuController multi-user aware.
        final boolean switcherMenuShowing = mNewInputMethodSwitcherMenuEnabled
        final boolean switcherMenuShowing = Flags.imeSwitcherRevamp()
                ? mMenuControllerNew.isShowing()
                : mMenuController.getSwitchingDialogLocked() != null;
        if (switcherMenuShowing) {
@@ -2640,8 +2616,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                || (visibility & InputMethodService.IME_INVISIBLE) != 0) {
            return false;
        }
        if (mWindowManagerInternal.isHardKeyboardAvailable()
                && !mNewInputMethodSwitcherMenuEnabled) {
        if (mWindowManagerInternal.isHardKeyboardAvailable() && !Flags.imeSwitcherRevamp()) {
            // When physical keyboard is attached, we show the ime switcher (or notification if
            // NavBar is not available) because SHOW_IME_WITH_HARD_KEYBOARD settings currently
            // exists in the IME switcher dialog.  Might be OK to remove this condition once
@@ -2652,7 +2627,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        }

        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        if (mNewInputMethodSwitcherMenuEnabled) {
        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());
@@ -2825,7 +2800,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            }
            final var curId = bindingController.getCurId();
            // TODO(b/305849394): Make mMenuController multi-user aware.
            final boolean switcherMenuShowing = mNewInputMethodSwitcherMenuEnabled
            final boolean switcherMenuShowing = Flags.imeSwitcherRevamp()
                    ? mMenuControllerNew.isShowing()
                    : mMenuController.getSwitchingDialogLocked() != null;
            if (switcherMenuShowing
@@ -2847,7 +2822,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    @GuardedBy("ImfLock.class")
    void updateFromSettingsLocked(boolean enabledMayChange, @UserIdInt int userId) {
        updateInputMethodsFromSettingsLocked(enabledMayChange, userId);
        if (!mNewInputMethodSwitcherMenuEnabled) {
        if (!Flags.imeSwitcherRevamp()) {
            mMenuController.updateKeyboardFromSettingsLocked(userId);
        }
    }
@@ -4016,7 +3991,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    @IInputMethodManagerImpl.PermissionVerified(Manifest.permission.TEST_INPUT_METHOD)
    public boolean isInputMethodPickerShownForTest() {
        synchronized (ImfLock.class) {
            return mNewInputMethodSwitcherMenuEnabled
            return Flags.imeSwitcherRevamp()
                    ? mMenuControllerNew.isShowing()
                    : mMenuController.isisInputMethodPickerShownForTestLocked();
        }
@@ -4661,7 +4636,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            proto.write(IS_INTERACTIVE, mIsInteractive);
            proto.write(BACK_DISPOSITION, bindingController.getBackDisposition());
            proto.write(IME_WINDOW_VISIBILITY, bindingController.getImeWindowVis());
            if (!mNewInputMethodSwitcherMenuEnabled) {
            if (!Flags.imeSwitcherRevamp()) {
                proto.write(SHOW_IME_WITH_HARD_KEYBOARD,
                        mMenuController.getShowImeWithHardKeyboard());
            }
@@ -4900,7 +4875,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            return;
        }

        if (mNewInputMethodSwitcherMenuEnabled) {
        if (Flags.imeSwitcherRevamp()) {
            if (DEBUG) {
                Slog.v(TAG, "Show IME switcher menu,"
                        + " showAuxSubtypes=" + showAuxSubtypes
@@ -4990,7 +4965,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

            // --------------------------------------------------------------
            case MSG_HARD_KEYBOARD_SWITCH_CHANGED:
                if (!mNewInputMethodSwitcherMenuEnabled) {
                if (!Flags.imeSwitcherRevamp()) {
                    mMenuController.handleHardKeyboardStatusChange(msg.arg1 == 1);
                }
                synchronized (ImfLock.class) {
@@ -5776,7 +5751,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                final var visibilityStateComputer = userData.mVisibilityStateComputer;
                if (visibilityStateComputer.getLastImeTargetWindow()
                        != userData.mImeBindingState.mFocusedWindow) {
                    if (mNewInputMethodSwitcherMenuEnabled) {
                    if (Flags.imeSwitcherRevamp()) {
                        final var bindingController = getInputMethodBindingController(userId);
                        mMenuControllerNew.hide(bindingController.getCurTokenDisplayId(), userId);
                    } else {
@@ -6134,7 +6109,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    };
            mUserDataRepository.forAllUserData(userDataDump);

            if (mNewInputMethodSwitcherMenuEnabled) {
            if (Flags.imeSwitcherRevamp()) {
                p.println("  menuControllerNew:");
                mMenuControllerNew.dump(p, "  ");
            } else {