NIU Tooltip : tooltip timer changes
Tooltip will hide only when the user tapped anywhere on the screen. Earlier tooltip was auto dismissed after 10 seconds.
Bug: 194775081
Test: Local build and run on Pixel 4a
Change-Id: I22f5cdd20e602fc261218d4fa801e80910083c62
(cherry picked from commit 89f7d40c217a81d17519ebf04bcb6b24c2c76b8a)
diff --git a/go/quickstep/src/com/android/quickstep/views/GoOverviewActionsView.java b/go/quickstep/src/com/android/quickstep/views/GoOverviewActionsView.java
index 6e2e6cb..8d7aac6 100644
--- a/go/quickstep/src/com/android/quickstep/views/GoOverviewActionsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/GoOverviewActionsView.java
@@ -91,7 +91,8 @@
mArrowTipView = new ArrowTipView(getContext(), /* isPointingUp= */ false)
.showAtLocation(getResources().getString(textResourceId),
/* arrowXCoord= */ location[0] + findViewById(viewId).getWidth() / 2,
- /* yCoord= */ location[1] - topMargin);
+ /* yCoord= */ location[1] - topMargin,
+ /* shouldAutoClose= */ false);
mArrowTipView.bringToFront();
return mArrowTipView;
diff --git a/src/com/android/launcher3/views/ArrowTipView.java b/src/com/android/launcher3/views/ArrowTipView.java
index e449a4b..239b5ff 100644
--- a/src/com/android/launcher3/views/ArrowTipView.java
+++ b/src/com/android/launcher3/views/ArrowTipView.java
@@ -133,6 +133,21 @@
* @return The tooltip.
*/
public ArrowTipView show(String text, int gravity, int arrowMarginStart, int top) {
+ return show(text, gravity, arrowMarginStart, top, true);
+ }
+
+ /**
+ * Show the ArrowTipView (tooltip) center, start, or end aligned.
+ *
+ * @param text The text to be shown in the tooltip.
+ * @param gravity The gravity aligns the tooltip center, start, or end.
+ * @param arrowMarginStart The margin from start to place arrow (ignored if center)
+ * @param top The Y coordinate of the bottom of tooltip.
+ * @param shouldAutoClose If Tooltip should be auto close.
+ * @return The tooltip.
+ */
+ public ArrowTipView show(
+ String text, int gravity, int arrowMarginStart, int top, boolean shouldAutoClose) {
((TextView) findViewById(R.id.text)).setText(text);
ViewGroup parent = mActivity.getDragLayer();
parent.addView(this);
@@ -157,7 +172,9 @@
post(() -> setY(top - (mIsPointingUp ? 0 : getHeight())));
mIsOpen = true;
- mHandler.postDelayed(() -> handleClose(true), AUTO_CLOSE_TIMEOUT_MILLIS);
+ if (shouldAutoClose) {
+ mHandler.postDelayed(() -> handleClose(true), AUTO_CLOSE_TIMEOUT_MILLIS);
+ }
setAlpha(0);
animate()
.alpha(1f)
@@ -181,10 +198,32 @@
*/
@Nullable public ArrowTipView showAtLocation(String text, @Px int arrowXCoord, @Px int yCoord) {
return showAtLocation(
+ text,
+ arrowXCoord,
+ /* yCoordDownPointingTip= */ yCoord,
+ /* yCoordUpPointingTip= */ yCoord,
+ /* shouldAutoClose= */ true);
+ }
+
+ /**
+ * Show the ArrowTipView (tooltip) custom aligned. The tooltip is vertically flipped if it
+ * cannot fit on screen in the requested orientation.
+ *
+ * @param text The text to be shown in the tooltip.
+ * @param arrowXCoord The X coordinate for the arrow on the tooltip. The arrow is usually in the
+ * center of tooltip unless the tooltip goes beyond screen margin.
+ * @param yCoord The Y coordinate of the pointed tip end of the tooltip.
+ * @param shouldAutoClose If Tooltip should be auto close.
+ * @return The tool tip view. {@code null} if the tip can not be shown.
+ */
+ @Nullable public ArrowTipView showAtLocation(
+ String text, @Px int arrowXCoord, @Px int yCoord, boolean shouldAutoClose) {
+ return showAtLocation(
text,
arrowXCoord,
/* yCoordDownPointingTip= */ yCoord,
- /* yCoordUpPointingTip= */ yCoord);
+ /* yCoordUpPointingTip= */ yCoord,
+ /* shouldAutoClose= */ shouldAutoClose);
}
/**
@@ -204,7 +243,8 @@
text,
arrowXCoord,
/* yCoordDownPointingTip= */ rect.top - margin,
- /* yCoordUpPointingTip= */ rect.bottom + margin);
+ /* yCoordUpPointingTip= */ rect.bottom + margin,
+ /* shouldAutoClose= */ true);
}
/**
@@ -218,10 +258,11 @@
* tooltip is placed pointing downwards.
* @param yCoordUpPointingTip The Y coordinate of the pointed tip end of the tooltip when the
* tooltip is placed pointing upwards.
+ * @param shouldAutoClose If Tooltip should be auto close.
* @return The tool tip view. {@code null} if the tip can not be shown.
*/
@Nullable private ArrowTipView showAtLocation(String text, @Px int arrowXCoord,
- @Px int yCoordDownPointingTip, @Px int yCoordUpPointingTip) {
+ @Px int yCoordDownPointingTip, @Px int yCoordUpPointingTip, boolean shouldAutoClose) {
ViewGroup parent = mActivity.getDragLayer();
@Px int parentViewWidth = parent.getWidth();
@Px int parentViewHeight = parent.getHeight();
@@ -279,7 +320,9 @@
});
mIsOpen = true;
- mHandler.postDelayed(() -> handleClose(true), AUTO_CLOSE_TIMEOUT_MILLIS);
+ if (shouldAutoClose) {
+ mHandler.postDelayed(() -> handleClose(true), AUTO_CLOSE_TIMEOUT_MILLIS);
+ }
setAlpha(0);
animate()
.alpha(1f)