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
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index 224c05e..b145861 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -136,6 +136,7 @@
// Initialized in init.
private TaskbarControllers mControllers;
+ private boolean mIsImeRenderingNavButtons;
private View mA11yButton;
private int mSysuiStateFlags;
private View mBackButton;
@@ -168,13 +169,17 @@
mNavButtonTranslationYMultiplier.value = 1;
boolean isThreeButtonNav = mContext.isThreeButtonNav();
- // IME switcher
- View imeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH,
- isThreeButtonNav ? mStartContextualContainer : mEndContextualContainer,
- mControllers.navButtonController, R.id.ime_switcher);
- mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton,
- flags -> ((flags & MASK_IME_SWITCHER_VISIBLE) == MASK_IME_SWITCHER_VISIBLE)
- && ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0)));
+ mIsImeRenderingNavButtons =
+ InputMethodService.canImeRenderGesturalNavButtons() && mContext.isGestureNav();
+ if (!mIsImeRenderingNavButtons) {
+ // IME switcher
+ View imeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH,
+ isThreeButtonNav ? mStartContextualContainer : mEndContextualContainer,
+ mControllers.navButtonController, R.id.ime_switcher);
+ 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,12 +319,14 @@
mControllers.rotationButtonController.setRotationButton(mFloatingRotationButton,
mRotationButtonListener);
- 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
- mPropertyHolders.add(new StatePropertyHolder(imeDownButton,
- flags -> (flags & FLAG_IME_VISIBLE) != 0));
+ 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);
+ // Only show when IME is visible.
+ mPropertyHolders.add(new StatePropertyHolder(imeDownButton,
+ flags -> (flags & FLAG_IME_VISIBLE) != 0));
+ }
}
applyState();
@@ -592,7 +599,7 @@
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;
}
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index 54ff6a0..4d79202 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -103,6 +103,9 @@
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 @@
/** 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);
}