Handle edge case where overflow icon is overflowing
In certain situations, space in taskbar may be restricted so even the
overflow icon for running apps is technically overflowing available
space (i.e. not fully within intended margins). In such cases the
overflow icon was not rendered, as the size of the overflown icons was
larger than the number of running app icons, so the list of icons for
overflow icon was never fully initialized.
Handle this case by capping the number of items to add to overflow icon
to the number of available running apps.
Bug: 379774843
Test: Enable three button navigation, increase the display scaling (to
effectively reduce available space), and enter desktop session in
portrait orientation. Verify the taskbar overflow icon shows up.
Flag: com.android.launcher3.taskbar_overflow
Change-Id: I06371637d1b01e99eaf30aec98ae0920aa248652
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index 8816a6d..0fccd2b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -473,8 +473,8 @@
boolean supportsOverflow = Flags.taskbarOverflow();
int overflowSize = 0;
+ int numberOfSupportedRecents = 0;
if (supportsOverflow) {
- int numberOfSupportedRecents = 0;
for (GroupTask task : recentTasks) {
// TODO(b/343289567 and b/316004172): support app pairs and desktop mode.
if (!task.supportsMultipleTasks()) {
@@ -495,7 +495,8 @@
List<Task> overflownTasks = null;
// An extra item needs to be added to overflow button to account for the space taken up by
// the overflow button.
- final int itemsToAddToOverflow = overflowSize > 0 ? overflowSize + 1 : 0;
+ final int itemsToAddToOverflow =
+ (overflowSize > 0) ? Math.min(overflowSize + 1, numberOfSupportedRecents) : 0;
if (overflowSize > 0) {
overflownTasks = new ArrayList<Task>(itemsToAddToOverflow);
}