From 849a0c4e810254a5b049131c9beff5301bac6613 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Fri, 24 Jun 2022 23:37:01 -0700 Subject: [PATCH] Show IME switcher only when physical keyboard is connected in 3 button nav (instead of also when virtual keyboard is visible) Bug: 226489759 Test: connect to a physical keyboard in 3 button nav and make sure the ime switcher shows; and doesn't show with virtual keyboard Change-Id: Ib9a5880eb1bd6d5b877a9f3789ce858f399c4910 --- .../taskbar/NavbarButtonsViewController.java | 11 ++++++++--- .../launcher3/taskbar/TaskbarActivityContext.java | 2 ++ .../launcher3/taskbar/TaskbarViewController.java | 11 ++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index b363803ef3..9df31b820d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -108,8 +108,6 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT private static final int FLAG_SCREEN_PINNING_ACTIVE = 1 << 11; private static final int FLAG_VOICE_INTERACTION_WINDOW_SHOWING = 1 << 12; - private static final int MASK_IME_SWITCHER_VISIBLE = FLAG_SWITCHER_SUPPORTED | FLAG_IME_VISIBLE; - private static final String NAV_BUTTONS_SEPARATE_WINDOW_TITLE = "Taskbar Nav Buttons"; public static final int ALPHA_INDEX_IMMERSIVE_MODE = 0; @@ -191,7 +189,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT isThreeButtonNav ? mStartContextualContainer : mEndContextualContainer, mControllers.navButtonController, R.id.ime_switcher); mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton, - flags -> ((flags & MASK_IME_SWITCHER_VISIBLE) != 0) + flags -> ((flags & FLAG_SWITCHER_SUPPORTED) != 0) && ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0))); } @@ -506,6 +504,13 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT return (mState & FLAG_IME_VISIBLE) != 0; } + /** + * Returns true if IME switcher is visible + */ + public boolean isImeSwitcherVisible() { + return (mState & FLAG_SWITCHER_SUPPORTED) != 0; + } + /** * Returns true if the home button is disabled */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index d1994e720a..22f047ca83 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -463,6 +463,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext { fromInit); mControllers.taskbarViewController.setImeIsVisible( mControllers.navbarButtonsViewController.isImeVisible()); + mControllers.taskbarViewController.setIsImeSwitcherVisible( + mControllers.navbarButtonsViewController.isImeSwitcherVisible()); int shadeExpandedFlags = SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED | SYSUI_STATE_QUICK_SETTINGS_EXPANDED; onNotificationShadeExpandChanged((systemUiStateFlags & shadeExpandedFlags) != 0, fromInit); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 0cbd0d1c8e..23a03341d3 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -68,7 +68,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar public static final int ALPHA_INDEX_RECENTS_DISABLED = 3; public static final int ALPHA_INDEX_NOTIFICATION_EXPANDED = 4; public static final int ALPHA_INDEX_ASSISTANT_INVOKED = 5; - private static final int NUM_ALPHA_CHANNELS = 6; + public static final int ALPHA_INDEX_IME_BUTTON_NAV = 6; + private static final int NUM_ALPHA_CHANNELS = 7; private final TaskbarActivityContext mActivity; private final TaskbarView mTaskbarView; @@ -142,6 +143,14 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mTaskbarView.setTouchesEnabled(!isImeVisible); } + /** + * Should be called when the IME switcher visibility changes. + */ + public void setIsImeSwitcherVisible(boolean isImeSwitcherVisible) { + mTaskbarIconAlpha.getProperty(ALPHA_INDEX_IME_BUTTON_NAV).setValue( + isImeSwitcherVisible ? 0 : 1); + } + /** * Should be called when the recents button is disabled, so we can hide taskbar icons as well. */