Merge "Add tooltip for taskbar overflow button" into main

This commit is contained in:
Treehugger Robot
2025-06-05 09:02:43 -07:00
committed by Android (Google) Code Review
5 changed files with 30 additions and 1 deletions

View File

@@ -319,7 +319,7 @@
<!-- Accessibility title for the Taskbar vertical divider icon. [CHAR_LIMIT=NONE] -->
<string name="taskbar_divider_a11y_title">Taskbar Divider</string>
<!-- Accessibility title for the Taskbar Overflow icon. [CHAR_LIMIT=NONE] -->
<string name="taskbar_overflow_a11y_title">Taskbar Overflow</string>
<string name="taskbar_overflow_a11y_title">Other recent apps</string>
<!-- Label for moving drop target to the top or left side of the screen, depending on orientation (from the Taskbar only). -->

View File

@@ -134,6 +134,8 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener {
return icon.mInfo.title.toString();
} else if (mHoverView instanceof AppPairIcon icon) {
return icon.getTitleTextView().getText().toString();
} else if (mHoverView instanceof TaskbarOverflowView icon) {
return icon.getTextForTooltipPopup();
} else {
return null;
}

View File

@@ -39,6 +39,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.core.graphics.ColorUtils;
import com.android.app.animation.Interpolators;
import com.android.launcher3.R;
import com.android.launcher3.Reorderable;
import com.android.launcher3.Utilities;
import com.android.launcher3.icons.IconNormalizer;
@@ -339,6 +340,17 @@ public class TaskbarOverflowView extends FrameLayout implements Reorderable {
}
}
/**
* @return Tooltip to be used for the taskbar overflow view - returns null if the view should
* not have a tooltip.
*/
public String getTextForTooltipPopup() {
if (mIsActive) {
return null;
}
return getResources().getString(R.string.taskbar_overflow_a11y_title);
}
/**
* Returns the view's state (whether it shows a set of app icons or a leave-behind circle).
*/

View File

@@ -363,6 +363,9 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
mControllerCallbacks.getOverflowOnClickListener());
mTaskbarOverflowView.setOnLongClickListener(
mControllerCallbacks.getOverflowOnLongClickListener());
if (enableCursorHoverStates()) {
setHoverListenerForIcon(mTaskbarOverflowView);
}
}
if (ENABLE_TASKBAR_OVERFLOW.isTrue()) {

View File

@@ -369,6 +369,8 @@ class TaskbarOverflowTest {
createDesktopTask(createdTasks)
assertThat(taskbarOverflowIconIndex).isEqualTo(initialIconCount)
assertThat(getOverflowIconTooltipText()).isEqualTo("Other recent apps")
tapOverflowIcon()
// Keyboard quick switch view is shown only after list of recent task is asynchronously
// retrieved from the recents model.
@@ -377,9 +379,11 @@ class TaskbarOverflowTest {
assertThat(getOnUiThread { keyboardQuickSwitchController.isShownFromTaskbar }).isTrue()
assertThat(getOnUiThread { keyboardQuickSwitchController.shownTaskIds() })
.containsExactlyElementsIn(0..<createdTasks)
assertThat(getOverflowIconTooltipText()).isNull()
tapOverflowIcon()
assertThat(keyboardQuickSwitchController.isShown).isFalse()
assertThat(getOverflowIconTooltipText()).isEqualTo("Other recent apps")
}
@Test
@@ -721,6 +725,14 @@ class TaskbarOverflowTest {
}
}
private fun getOverflowIconTooltipText(): String? {
return getOnUiThread {
val overflowIcon =
taskbarViewController.iconViews.firstOrNull { it is TaskbarOverflowView }
(overflowIcon as? TaskbarOverflowView)?.getTextForTooltipPopup()
}
}
/**
* Adds enough running apps for taskbar to enter overflow of `targetOverflowSize`, and verifies
* * max number of icons in the taskbar remains unchanged