From 612263104b78a7e03360a3b1ba9ef8a6f41ba57b Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Mon, 29 Jul 2024 08:00:14 -0400 Subject: [PATCH] Animate the bubble badge The bubble badge now scales together with the expand and collapse animation of the bubble bar. The badge for the selected bubble is always kept at full scale. Flag: com.android.wm.shell.enable_bubble_bar Fixes: 349826874 Test: manual - create some bubbles in the bubble bar - expand and collapse the bar - observe badge icons scale accordingly Change-Id: I04e9174f4a921e404cb3162337f594c16478b16c --- .../launcher3/taskbar/bubbles/BubbleBarView.java | 9 ++++----- .../launcher3/taskbar/bubbles/BubbleView.java | 15 +++------------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index af371f25e7..974d56531b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -970,11 +970,14 @@ public class BubbleBarView extends FrameLayout { float fullElevationForChild = (MAX_BUBBLES * mBubbleElevation) - i; bv.setZ(fullElevationForChild * elevationState); - // only update the dot scale if we're expanding or collapsing + // only update the dot and badge scale if we're expanding or collapsing if (mWidthAnimator.isRunning()) { // The dot for the selected bubble scales in the opposite direction of the expansion // animation. bv.showDotIfNeeded(bv == mSelectedBubbleView ? 1 - widthState : widthState); + // The badge for the selected bubble is always at full scale. All other bubbles + // scale according to the expand animation. + bv.setBadgeScale(bv == mSelectedBubbleView ? 1 : widthState); } if (mIsBarExpanded) { @@ -983,16 +986,12 @@ public class BubbleBarView extends FrameLayout { // where the bubble will end up when the animation ends final float targetX = expandedX + expandedBarShift; bv.setTranslationX(widthState * (targetX - collapsedX) + collapsedX); - // When we're expanded, the badge is visible for all bubbles - bv.updateBadgeVisibility(/* show= */ true); bv.setAlpha(1); } else { // If bar is on the right, account for bubble bar expanding and shifting left final float collapsedBarShift = onLeft ? 0 : currentWidth - collapsedWidth; final float targetX = collapsedX + collapsedBarShift; bv.setTranslationX(widthState * (expandedX - targetX) + targetX); - // The badge is always visible for the first bubble - bv.updateBadgeVisibility(/* show= */ i == 0); // 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) { diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java index 6db42a4c53..9c427e78e5 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java @@ -300,18 +300,9 @@ public class BubbleView extends ConstraintLayout { } } - void updateBadgeVisibility(boolean show) { - if (mBubble instanceof BubbleBarOverflow) { - // The overflow bubble does not have a badge, so just bail. - return; - } - BubbleBarBubble bubble = (BubbleBarBubble) mBubble; - Bitmap appBadgeBitmap = bubble.getBadge(); - int translationX = mOnLeft - ? -(bubble.getIcon().getWidth() - appBadgeBitmap.getWidth()) - : 0; - mAppIcon.setTranslationX(translationX); - mAppIcon.setVisibility(show ? VISIBLE : GONE); + void setBadgeScale(float fraction) { + mAppIcon.setScaleX(fraction); + mAppIcon.setScaleY(fraction); } boolean hasUnseenContent() {