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

Commit f6e98fdc authored by Tony Wickham's avatar Tony Wickham
Browse files

Don't add IME back and switcher buttons if IME renders them

- Also cache InputMethodService.canImeRenderGesturalNavButtons() since it doesn't change at runtime

Test: Enable persist.sys.ime.can_render_gestural_nav_buttons setprop, then ensure we don't draw IME back button or switcher button when gesture nav is enabled
Test: We still show back button in setup, regardless of nav mode
Bug: 205803355
Change-Id: Iab8c47521ab9e561881e4ffb45142888e4c427e4
parent 2718fd67
Loading
Loading
Loading
Loading
+21 −14
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT

    // Initialized in init.
    private TaskbarControllers mControllers;
    private boolean mIsImeRenderingNavButtons;
    private View mA11yButton;
    private int mSysuiStateFlags;
    private View mBackButton;
@@ -168,6 +169,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        mNavButtonTranslationYMultiplier.value = 1;

        boolean isThreeButtonNav = mContext.isThreeButtonNav();
        mIsImeRenderingNavButtons =
                InputMethodService.canImeRenderGesturalNavButtons() && mContext.isGestureNav();
        if (!mIsImeRenderingNavButtons) {
            // IME switcher
            View imeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH,
                    isThreeButtonNav ? mStartContextualContainer : mEndContextualContainer,
@@ -175,6 +179,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
            mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton,
                    flags -> ((flags & MASK_IME_SWITCHER_VISIBLE) == MASK_IME_SWITCHER_VISIBLE)
                            && ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0)));
        }

        mPropertyHolders.add(new StatePropertyHolder(
                mControllers.taskbarViewController.getTaskbarIconAlpha()
@@ -314,13 +319,15 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
            mControllers.rotationButtonController.setRotationButton(mFloatingRotationButton,
                    mRotationButtonListener);

            if (!mIsImeRenderingNavButtons) {
                View imeDownButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK,
                        mStartContextualContainer, mControllers.navButtonController, R.id.back);
                imeDownButton.setRotation(Utilities.isRtl(mContext.getResources()) ? 90 : -90);
            // Rotate when Ime visible
                // Only show when IME is visible.
                mPropertyHolders.add(new StatePropertyHolder(imeDownButton,
                        flags -> (flags & FLAG_IME_VISIBLE) != 0));
            }
        }

        applyState();
        mPropertyHolders.forEach(StatePropertyHolder::endAnimation);
@@ -592,7 +599,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
            return;
        }

        if (InputMethodService.canImeRenderGesturalNavButtons() && mContext.isGestureNav()) {
        if (mIsImeRenderingNavButtons) {
            // IME is rendering the nav buttons, so we don't need to create a new layer for them.
            return;
        }
+4 −1
Original line number Diff line number Diff line
@@ -103,6 +103,9 @@ public class RecentsAnimationDeviceState implements
    private final RotationTouchHelper mRotationTouchHelper;
    private final TaskStackChangeListener mPipListener;
    private final List<ComponentName> mGestureBlockedActivities;
    // Cache for better performance since it doesn't change at runtime.
    private final boolean mCanImeRenderGesturalNavButtons =
            InputMethodService.canImeRenderGesturalNavButtons();

    private final ArrayList<Runnable> mOnDestroyActions = new ArrayList<>();

@@ -596,7 +599,7 @@ public class RecentsAnimationDeviceState implements

    /** Returns whether IME is rendering nav buttons, and IME is currently showing. */
    public boolean isImeRenderingNavButtons() {
        return InputMethodService.canImeRenderGesturalNavButtons() && mMode == NO_BUTTON
        return mCanImeRenderGesturalNavButtons && mMode == NO_BUTTON
                && ((mSystemUiStateFlags & SYSUI_STATE_IME_SHOWING) != 0);
    }