Use up-to-date hover tooltip text for recents.
Flag: EXEMPT bugfix Fix: 402776493 Test: go/testedequals Change-Id: I6f438ce8b3cd51beaece0cf6734876f21719bf3d
This commit is contained in:
@@ -26,6 +26,7 @@ import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLA
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.graphics.Rect;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -50,7 +51,6 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener {
|
||||
private final TaskbarView mTaskbarView;
|
||||
private final View mHoverView;
|
||||
private final ArrowTipView mHoverToolTipView;
|
||||
private final String mToolTipText;
|
||||
private final int mYOffset;
|
||||
|
||||
public TaskbarHoverToolTipController(TaskbarActivityContext activity, TaskbarView taskbarView,
|
||||
@@ -59,17 +59,6 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener {
|
||||
mTaskbarView = taskbarView;
|
||||
mHoverView = hoverView;
|
||||
|
||||
if (mHoverView instanceof BubbleTextView) {
|
||||
mToolTipText = ((BubbleTextView) mHoverView).getText().toString();
|
||||
} else if (mHoverView instanceof FolderIcon
|
||||
&& ((FolderIcon) mHoverView).mInfo.title != null) {
|
||||
mToolTipText = ((FolderIcon) mHoverView).mInfo.title.toString();
|
||||
} else if (mHoverView instanceof AppPairIcon) {
|
||||
mToolTipText = ((AppPairIcon) mHoverView).getTitleTextView().getText().toString();
|
||||
} else {
|
||||
mToolTipText = null;
|
||||
}
|
||||
|
||||
ContextThemeWrapper arrowContextWrapper = new ContextThemeWrapper(mActivity,
|
||||
R.style.ArrowTipTaskbarStyle);
|
||||
mHoverToolTipView = new ArrowTipView(arrowContextWrapper, /* isPointingUp = */ false,
|
||||
@@ -111,9 +100,15 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener {
|
||||
}
|
||||
|
||||
private void maybeRevealHoverToolTip() {
|
||||
if (mHoverView == null || mToolTipText == null) {
|
||||
if (mHoverView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String toolTipText = getToolTipText();
|
||||
if (TextUtils.isEmpty(toolTipText)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not show tooltip if taskbar icons are transitioning to hotseat.
|
||||
if (mActivity.isIconAlignedWithHotseat()) {
|
||||
return;
|
||||
@@ -128,7 +123,19 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener {
|
||||
}
|
||||
|
||||
Rect iconViewBounds = Utilities.getViewBounds(mHoverView);
|
||||
mHoverToolTipView.showAtLocation(mToolTipText, iconViewBounds.centerX(),
|
||||
mHoverToolTipView.showAtLocation(toolTipText, iconViewBounds.centerX(),
|
||||
mTaskbarView.getTop() - mYOffset, /* shouldAutoClose= */ false);
|
||||
}
|
||||
|
||||
private String getToolTipText() {
|
||||
if (mHoverView instanceof BubbleTextView btv) {
|
||||
return btv.getText().toString();
|
||||
} else if (mHoverView instanceof FolderIcon icon && icon.mInfo.title != null) {
|
||||
return icon.mInfo.title.toString();
|
||||
} else if (mHoverView instanceof AppPairIcon icon) {
|
||||
return icon.getTitleTextView().getText().toString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -736,7 +736,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
if (taskIcon != null) {
|
||||
taskIcon = taskIcon.getConstantState().newDrawable().mutate();
|
||||
}
|
||||
btv.applyIconAndLabel(taskIcon, task.titleDescription);
|
||||
btv.applyIconAndLabel(taskIcon, task.title, task.titleDescription);
|
||||
btv.setTag(singleTask);
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -147,6 +147,15 @@ class TaskbarHoverToolTipControllerTest {
|
||||
assertThat(isHoverToolTipOpen).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onHover_emptyTitle_noTooltip() {
|
||||
runOnMainSync {
|
||||
iconView.text = ""
|
||||
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)
|
||||
|
||||
@@ -473,10 +473,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
* Directly set the icon and label.
|
||||
*/
|
||||
@UiThread
|
||||
public void applyIconAndLabel(Drawable icon, CharSequence label) {
|
||||
public void applyIconAndLabel(Drawable icon, CharSequence title, CharSequence description) {
|
||||
applyCompoundDrawables(icon);
|
||||
setText(label);
|
||||
setContentDescription(label);
|
||||
setText(title);
|
||||
setContentDescription(description);
|
||||
}
|
||||
|
||||
/** Updates whether the app this view represents is currently running. */
|
||||
|
||||
Reference in New Issue
Block a user