Merge "Don't show tasks shown in taskbar within overflow UI" into main

This commit is contained in:
Treehugger Robot
2025-06-06 12:24:36 -07:00
committed by Android (Google) Code Review
4 changed files with 20 additions and 13 deletions
@@ -293,7 +293,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener {
// get pinned tasks - we care about all tasks, not just the one moved to the front
Set<Integer> taskbarPinnedTasks =
entry.getValue().getControllers().taskbarViewController
.getTaskIdsForPinnedApps();
.getShownTaskIds();
// filter out tasks already marked as perceptible
taskbarPinnedTasks.removeAll(mPerceptibleTasks);
@@ -203,7 +203,7 @@ public class TaskbarViewCallbacks {
mTaskbarView.getTaskbarOverflowView().getIsActive());
}
mControllers.keyboardQuickSwitchController.toggleQuickSwitchViewForTaskbar(
mControllers.taskbarViewController.getTaskIdsForPinnedApps(),
mControllers.taskbarViewController.getShownTaskIds(),
this::onKeyboardQuickSwitchViewClosed);
}
@@ -781,21 +781,25 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
}
/**
* @return A set of Task ids of running apps that are pinned in the taskbar.
* @return A set of Task ids shown in the taskbar - includes task ID for running tasks of pinned
* apps, and standalone running tasks.
*/
protected Set<Integer> getTaskIdsForPinnedApps() {
protected Set<Integer> getShownTaskIds() {
if (!ENABLE_TASKBAR_OVERFLOW.isTrue()) {
return Collections.emptySet();
}
Set<Integer> pinnedAppsWithTasks = new HashSet<>();
Set<Integer> shownTasks = new HashSet<>();
for (View iconView : getIconViews()) {
if (iconView instanceof BubbleTextView btv
&& btv.getTag() instanceof TaskItemInfo itemInfo) {
pinnedAppsWithTasks.add(itemInfo.getTaskId());
if (iconView instanceof BubbleTextView btv) {
if (btv.getTag() instanceof TaskItemInfo itemInfo) {
shownTasks.add(itemInfo.getTaskId());
} else if (btv.getTag() instanceof SingleTask task) {
shownTasks.add(task.getTask().getKey().id);
}
}
}
return pinnedAppsWithTasks;
return shownTasks;
}
private void updateRunningState(BubbleTextView btv) {
@@ -378,7 +378,7 @@ class TaskbarOverflowTest {
assertThat(getOnUiThread { keyboardQuickSwitchController.isShownFromTaskbar }).isTrue()
assertThat(getOnUiThread { keyboardQuickSwitchController.shownTaskIds() })
.containsExactlyElementsIn(0..<createdTasks)
.containsExactlyElementsIn(0..targetOverflowSize)
assertThat(getOverflowIconTooltipText()).isNull()
tapOverflowIcon()
@@ -452,7 +452,7 @@ class TaskbarOverflowTest {
assertThat(getOnUiThread { keyboardQuickSwitchController.isShownFromTaskbar }).isTrue()
assertThat(getOnUiThread { keyboardQuickSwitchController.shownTaskIds() })
.containsExactlyElementsIn(listOf(0) + (2..<createdTasks).toList())
.containsExactlyElementsIn(listOf(0) + (2..targetOverflowSize + 1).toList())
}
@Test
@@ -488,8 +488,11 @@ class TaskbarOverflowTest {
runOnMainSync { recentsModel.resolvePendingTaskRequests() }
assertThat(getOnUiThread { keyboardQuickSwitchController.isShownFromTaskbar }).isTrue()
// Taskbar is in overflow by `targetOverflowSize`, so overflow UI should have
// `targetOverflowSize + 1` items, to account for a spot in taskbar taken by the overflow
// icon. Task IDs for running desktop apps start at 1 - 0 is used for fullscreen task.
assertThat(getOnUiThread { keyboardQuickSwitchController.shownTaskIds() })
.containsExactlyElementsIn(listOf(1) + (3..<createdTasks + 1).toList())
.containsExactlyElementsIn(listOf(1) + (3..targetOverflowSize + 2).toList())
}
@Test
@@ -607,7 +610,7 @@ class TaskbarOverflowTest {
taskbarUnitTestRule.activityContext.dragLayer.findViewById(R.id.taskbar_view)
taskbarView.updateItems(hotseatItems, recentAppsController.shownTasks)
modelCallback.recentAppsController = recentAppsController
context.baseContext.appComponent.launcherAppState.model.addCallbacksAndLoad(modelCallback)
context.baseContext.appComponent.launcherAppState.model.addCallbacks(modelCallback)
modelCallback.bindItemsAdded(hotseatItems.toList())
return taskbarView
}