From 90d3a422f8a4be301809eb4131686e176005f241 Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Wed, 16 Aug 2023 10:06:08 -0400 Subject: [PATCH] Cap the width of the bubble bar when collapsed When the bubble bar is collapsed we now show at most 2 bubbles. Fixes: 295020145 Test: Manual - Add 1 bubble to the bubble bar - Collapse bubble bar -- Observe that only that bubble is visible - Expand the bubble bar -- Observe that both that bubble and the overflow are visible - Add another bubble -- Observe that 2 bubbles are visible when collapsed - Add another bubble -- Observe that only the first 2 bubbles are visible when collapsed Change-Id: I5f534f53eefe9a920b8b3258813d67d021c5f2a8 --- .../taskbar/bubbles/BubbleBarView.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index ffe077b288..c482911ae8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -280,7 +280,7 @@ public class BubbleBarView extends FrameLayout { // the position of the bubble when the bar is fully expanded final float expandedX = i * (mIconSize + mIconSpacing); // the position of the bubble when the bar is fully collapsed - final float collapsedX = i * mIconOverlapAmount; + final float collapsedX = i == 0 ? 0 : mIconOverlapAmount; if (mIsBarExpanded) { // where the bubble will end up when the animation ends @@ -292,12 +292,22 @@ public class BubbleBarView extends FrameLayout { } // When we're expanded, we're not stacked so we're not behind the stack bv.setBehindStack(false, animate); + bv.setAlpha(1); } else { final float targetX = currentWidth - collapsedWidth + collapsedX; bv.setTranslationX(widthState * (expandedX - targetX) + targetX); bv.setZ((MAX_BUBBLES * mBubbleElevation) - i); // If we're not the first bubble we're behind the stack bv.setBehindStack(i > 0, animate); + // If we're fully collapsed, hide all bubbles except for the first 2. If there are + // only 2 bubbles, hide the second bubble as well because it's the overflow. + if (widthState == 0) { + if (i > 1) { + bv.setAlpha(0); + } else if (i == 1 && bubbleCount == 2) { + bv.setAlpha(0); + } + } } } @@ -458,7 +468,11 @@ public class BubbleBarView extends FrameLayout { private float collapsedWidth() { final int childCount = getChildCount(); final int horizontalPadding = getPaddingStart() + getPaddingEnd(); - return mIconSize + ((childCount - 1) * mIconOverlapAmount) + horizontalPadding; + // If there are more than 2 bubbles, the first 2 should be visible when collapsed. + // Otherwise just the first bubble should be visible because we don't show the overflow. + return childCount > 2 + ? mIconSize + mIconOverlapAmount + horizontalPadding + : mIconSize + horizontalPadding; } /**