Merge "Show and hide taskbar tooltips immediately." into main
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 9c954d1..cd1eea2 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -25,6 +25,7 @@
 import static android.window.SplashScreen.SPLASH_SCREEN_STYLE_UNDEFINED;
 
 import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
+import static com.android.launcher3.AbstractFloatingView.TYPE_ON_BOARD_POPUP;
 import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
 import static com.android.launcher3.AbstractFloatingView.TYPE_TASKBAR_OVERLAY_PROXY;
 import static com.android.launcher3.Flags.enableCursorHoverStates;
@@ -1514,6 +1515,12 @@
                 itemView.setHapticFeedbackEnabled(true);
                 return false;
             });
+
+            // Close any open taskbar tooltips.
+            if (AbstractFloatingView.hasOpenView(this, TYPE_ON_BOARD_POPUP)) {
+                AbstractFloatingView.getOpenView(this, TYPE_ON_BOARD_POPUP)
+                        .close(/* animate= */ false);
+            }
         });
     }
 
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarHoverToolTipController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarHoverToolTipController.java
index dd14109..8c7879d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarHoverToolTipController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarHoverToolTipController.java
@@ -18,30 +18,22 @@
 import static android.view.MotionEvent.ACTION_HOVER_ENTER;
 import static android.view.MotionEvent.ACTION_HOVER_EXIT;
 import static android.view.View.ALPHA;
-import static android.view.View.SCALE_Y;
-import static android.view.accessibility.AccessibilityManager.FLAG_CONTENT_TEXT;
 
-import static com.android.app.animation.Interpolators.LINEAR;
-import static com.android.launcher3.AbstractFloatingView.TYPE_ALL_EXCEPT_ON_BOARD_POPUP;
+import static com.android.launcher3.AbstractFloatingView.TYPE_FOLDER;
 import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_HOVERING_ICONS;
-import static com.android.launcher3.views.ArrowTipView.TEXT_ALPHA;
 
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
 import android.graphics.Rect;
-import android.os.Handler;
-import android.os.Looper;
 import android.view.ContextThemeWrapper;
 import android.view.MotionEvent;
 import android.view.View;
 
-import com.android.app.animation.Interpolators;
 import com.android.launcher3.AbstractFloatingView;
 import com.android.launcher3.BubbleTextView;
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
 import com.android.launcher3.apppairs.AppPairIcon;
-import com.android.launcher3.compat.AccessibilityManagerCompat;
 import com.android.launcher3.folder.FolderIcon;
 import com.android.launcher3.views.ArrowTipView;
 
@@ -49,13 +41,9 @@
  * Controls showing a tooltip in the taskbar above each icon when it is hovered.
  */
 public class TaskbarHoverToolTipController implements View.OnHoverListener {
-
-    private static final int HOVER_TOOL_TIP_REVEAL_DURATION = 250;
-    private static final int HOVER_TOOL_TIP_EXIT_DURATION = 150;
-
-    private final Handler mHoverToolTipHandler = new Handler(Looper.getMainLooper());
-    private final Runnable mRevealHoverToolTipRunnable = this::revealHoverToolTip;
-    private final Runnable mHideHoverToolTipRunnable = this::hideHoverToolTip;
+    // Short duration to reveal tooltip, as it is positioned in the x/y via a post() call in
+    // parallel with the open animation. An instant animation could show in the wrong location.
+    private static final int HOVER_TOOL_TIP_REVEAL_DURATION = 15;
 
     private final TaskbarActivityContext mActivity;
     private final TaskbarView mTaskbarView;
@@ -90,35 +78,11 @@
                 R.dimen.taskbar_tooltip_horizontal_padding);
         mHoverToolTipView.findViewById(R.id.text).setPadding(horizontalPadding, verticalPadding,
                 horizontalPadding, verticalPadding);
-
-        AnimatorSet hoverCloseAnimator = new AnimatorSet();
-        ObjectAnimator textCloseAnimator = ObjectAnimator.ofInt(mHoverToolTipView, TEXT_ALPHA, 0);
-        textCloseAnimator.setInterpolator(Interpolators.clampToProgress(LINEAR, 0, 0.33f));
-        ObjectAnimator alphaCloseAnimator = ObjectAnimator.ofFloat(mHoverToolTipView, ALPHA, 0);
-        alphaCloseAnimator.setInterpolator(Interpolators.clampToProgress(LINEAR, 0.33f, 0.66f));
-        ObjectAnimator scaleCloseAnimator = ObjectAnimator.ofFloat(mHoverToolTipView, SCALE_Y, 0);
-        scaleCloseAnimator.setInterpolator(Interpolators.STANDARD);
-        hoverCloseAnimator.playTogether(
-                textCloseAnimator,
-                alphaCloseAnimator,
-                scaleCloseAnimator);
-        hoverCloseAnimator.setStartDelay(0);
-        hoverCloseAnimator.setDuration(HOVER_TOOL_TIP_EXIT_DURATION);
-        mHoverToolTipView.setCustomCloseAnimation(hoverCloseAnimator);
+        mHoverToolTipView.setAlpha(0);
 
         AnimatorSet hoverOpenAnimator = new AnimatorSet();
-        ObjectAnimator textOpenAnimator =
-                ObjectAnimator.ofInt(mHoverToolTipView, TEXT_ALPHA, 0, 255);
-        textOpenAnimator.setInterpolator(Interpolators.clampToProgress(LINEAR, 0.15f, 0.75f));
-        ObjectAnimator scaleOpenAnimator =
-                ObjectAnimator.ofFloat(mHoverToolTipView, SCALE_Y, 0f, 1f);
-        scaleOpenAnimator.setInterpolator(Interpolators.EMPHASIZED);
         ObjectAnimator alphaOpenAnimator = ObjectAnimator.ofFloat(mHoverToolTipView, ALPHA, 0f, 1f);
-        alphaOpenAnimator.setInterpolator(Interpolators.clampToProgress(LINEAR, 0f, 0.33f));
-        hoverOpenAnimator.playTogether(
-                scaleOpenAnimator,
-                textOpenAnimator,
-                alphaOpenAnimator);
+        hoverOpenAnimator.play(alphaOpenAnimator);
         hoverOpenAnimator.setDuration(HOVER_TOOL_TIP_REVEAL_DURATION);
         mHoverToolTipView.setCustomOpenAnimation(hoverOpenAnimator);
 
@@ -131,28 +95,17 @@
 
     @Override
     public boolean onHover(View v, MotionEvent event) {
-        boolean isAnyOtherFloatingViewOpen =
-                AbstractFloatingView.hasOpenView(mActivity, TYPE_ALL_EXCEPT_ON_BOARD_POPUP);
-        if (isAnyOtherFloatingViewOpen) {
-            mHoverToolTipHandler.removeCallbacksAndMessages(null);
-        }
+        boolean isFolderOpen = AbstractFloatingView.hasOpenView(mActivity, TYPE_FOLDER);
         // If hover leaves a taskbar icon animate the tooltip closed.
         if (event.getAction() == ACTION_HOVER_EXIT) {
-            startHideHoverToolTip();
+            mHoverToolTipView.close(/* animate= */ false);
             mActivity.setAutohideSuspendFlag(FLAG_AUTOHIDE_SUSPEND_HOVERING_ICONS, false);
-            return true;
-        } else if (!isAnyOtherFloatingViewOpen && event.getAction() == ACTION_HOVER_ENTER) {
-            // If hovering above a taskbar icon starts, animate the tooltip open. Do not
-            // reveal if any floating views such as folders or edu pop-ups are open.
-            startRevealHoverToolTip();
+        } 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();
             mActivity.setAutohideSuspendFlag(FLAG_AUTOHIDE_SUSPEND_HOVERING_ICONS, true);
-            return true;
         }
-        return false;
-    }
-
-    private void startRevealHoverToolTip() {
-        mHoverToolTipHandler.post(mRevealHoverToolTipRunnable);
+        return true;
     }
 
     private void revealHoverToolTip() {
@@ -170,14 +123,4 @@
         mHoverToolTipView.showAtLocation(mToolTipText, iconViewBounds.centerX(),
                 mTaskbarView.getTop(), /* shouldAutoClose= */ false);
     }
-
-    private void startHideHoverToolTip() {
-        int accessibilityHideTimeout = AccessibilityManagerCompat.getRecommendedTimeoutMillis(
-                mActivity, /* originalTimeout= */ 0, FLAG_CONTENT_TEXT);
-        mHoverToolTipHandler.postDelayed(mHideHoverToolTipRunnable, accessibilityHideTimeout);
-    }
-
-    private void hideHoverToolTip() {
-        mHoverToolTipView.close(/* animate = */ true);
-    }
 }
diff --git a/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarHoverToolTipControllerTest.java b/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarHoverToolTipControllerTest.java
index ef3a833..67a0ee4 100644
--- a/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarHoverToolTipControllerTest.java
+++ b/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarHoverToolTipControllerTest.java
@@ -202,7 +202,7 @@
         boolean hoverHandled =
                 mTaskbarHoverToolTipController.onHover(mHoverFolderIcon, mMotionEvent);
 
-        assertThat(hoverHandled).isFalse();
+        assertThat(hoverHandled).isTrue();
     }
 
     @Test
@@ -213,7 +213,7 @@
         boolean hoverHandled =
                 mTaskbarHoverToolTipController.onHover(mHoverFolderIcon, mMotionEvent);
 
-        assertThat(hoverHandled).isFalse();
+        assertThat(hoverHandled).isTrue();
     }
 
     @Test
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index 876b643..d3ee364 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -138,9 +138,6 @@
     public static final int TYPE_TOUCH_CONTROLLER_NO_INTERCEPT = TYPE_ALL & ~TYPE_DISCOVERY_BOUNCE
             & ~TYPE_LISTENER & ~TYPE_TASKBAR_OVERLAYS;
 
-    public static final int TYPE_ALL_EXCEPT_ON_BOARD_POPUP = TYPE_ALL & ~TYPE_ON_BOARD_POPUP
-            & ~TYPE_PIN_IME_POPUP;
-
     protected boolean mIsOpen;
 
     public AbstractFloatingView(Context context, AttributeSet attrs) {