Don't show hover tooltip while an app popup is open

Flag: EXEMPT bugfix
Test: TaskbarHoverToolTipControllerTest
Fixes: 397243128
Change-Id: I1b67d065e9e79e13a5a341a5d133da700ef5f40c
This commit is contained in:
Tony Wickham committed 2025-03-17 22:36:27 +00:00
1 parent 131c68b11b
commit 88a9e18f7c
4 files changed
+24 -6

No files matched your search

@@ -19,6 +19,7 @@ import static android.view.MotionEvent.ACTION_HOVER_ENTER;
import static android.view.MotionEvent.ACTION_HOVER_EXIT;
import static android.view.View.ALPHA;
import static com.android.launcher3.AbstractFloatingView.TYPE_ACTION_POPUP;
import static com.android.launcher3.AbstractFloatingView.TYPE_FOLDER;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_HOVERING_ICONS;
@@ -98,20 +99,18 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener {
@Override
public boolean onHover(View v, MotionEvent event) {
boolean isFolderOpen = AbstractFloatingView.hasOpenView(mActivity, TYPE_FOLDER);
// If hover leaves a taskbar icon animate the tooltip closed.
if (event.getAction() == ACTION_HOVER_EXIT) {
mHoverToolTipView.close(/* animate= */ false);
mActivity.setAutohideSuspendFlag(FLAG_AUTOHIDE_SUSPEND_HOVERING_ICONS, false);
} else if (!isFolderOpen && event.getAction() == ACTION_HOVER_ENTER) {
// Do not reveal if any floating views such as folders or edu pop-ups are open.
revealHoverToolTip();
} else if (event.getAction() == ACTION_HOVER_ENTER) {
maybeRevealHoverToolTip();
mActivity.setAutohideSuspendFlag(FLAG_AUTOHIDE_SUSPEND_HOVERING_ICONS, true);
}
return false;
}
private void revealHoverToolTip() {
private void maybeRevealHoverToolTip() {
if (mHoverView == null || mToolTipText == null) {
return;
}
@@ -122,6 +121,12 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener {
if (mHoverView instanceof FolderIcon && !((FolderIcon) mHoverView).getIconVisible()) {
return;
}
// Do not reveal if floating views such as folders or app pop-ups are open,
// as these views will overlap and not look great.
if (AbstractFloatingView.hasOpenView(mActivity, TYPE_FOLDER | TYPE_ACTION_POPUP)) {
return;
}
Rect iconViewBounds = Utilities.getViewBounds(mHoverView);
mHoverToolTipView.showAtLocation(mToolTipText, iconViewBounds.centerX(),
mTaskbarView.getTop() - mYOffset, /* shouldAutoClose= */ false);
@@ -83,7 +83,7 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
// Initialized in init.
private TaskbarControllers mControllers;
private boolean mAllowInitialSplitSelection;
private AppInfo[] mAppInfosList;
private AppInfo[] mAppInfosList = AppInfo.EMPTY_ARRAY;
// Saves the ItemInfos in the hotseat without the predicted items.
private SparseArray<ItemInfo> mHotseatInfosList;
private ManageWindowsTaskbarShortcut<BaseTaskbarContext> mManageWindowsTaskbarShortcut;
@@ -48,6 +48,7 @@ class TaskbarHoverToolTipControllerTest {
@get:Rule(order = 1) val taskbarUnitTestRule = TaskbarUnitTestRule(this, context)
@InjectController lateinit var autohideSuspendController: TaskbarAutohideSuspendController
@InjectController lateinit var popupController: TaskbarPopupController
private val taskbarContext: TaskbarActivityContext by taskbarUnitTestRule::activityContext
@@ -137,6 +138,15 @@ class TaskbarHoverToolTipControllerTest {
assertThat(isHoverToolTipOpen).isFalse()
}
@Test
fun onHover_hoverEnterPopupOpen_noToolTip() {
runOnMainSync {
popupController.showForIcon(iconView)
iconView.dispatchGenericMotionEvent(HOVER_ENTER)
}
assertThat(isHoverToolTipOpen).isFalse()
}
companion object {
private val HOVER_EXIT = MotionEvent.obtain(0, 0, ACTION_HOVER_EXIT, 0f, 0f, 0)
private val HOVER_ENTER = MotionEvent.obtain(0, 0, ACTION_HOVER_ENTER, 0f, 0f, 0)
@@ -28,6 +28,7 @@ import com.android.launcher3.taskbar.TaskbarActivityContext
import com.android.launcher3.taskbar.TaskbarControllers
import com.android.launcher3.taskbar.TaskbarManager
import com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarNavButtonCallbacks
import com.android.launcher3.taskbar.TaskbarUIController
import com.android.launcher3.taskbar.bubbles.BubbleControllers
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.InjectController
import com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR
@@ -117,6 +118,8 @@ class TaskbarUnitTestRule(
super.recreateTaskbars()
if (currentActivityContext != null) {
injectControllers()
// TODO(b/346394875): we should test a non-default uiController.
activityContext.setUIController(TaskbarUIController.DEFAULT)
controllerInjectionCallback.invoke()
}
}