From 6ba541642efadced6c620d03397c78a23db57533 Mon Sep 17 00:00:00 2001 From: mpodolian Date: Thu, 25 Jul 2024 03:00:43 +0100 Subject: [PATCH] Improvement for the Bubble Bar Bubbles' Shadows The issue was caused by the alpha animation applied to the bubble bar. Added code to check if the alpha applied to the bubble bar is less than 1 and instruct child bubble views not to provide a shadow outline in such cases. While this is not a full fix, but rather an improvement, b/345490679 should introduce a proper fix. Bug: 345484712 Test: visual - go to any application and stash/unstash bubble bar Flag: com.android.wm.shell.enable_bubble_bar Change-Id: Icb6bdb009f4d5998ec1638f97de89f7a4c9feccf --- .../launcher3/taskbar/bubbles/BubbleBarView.java | 11 +++++++++++ .../launcher3/taskbar/bubbles/BubbleView.java | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index 5d550ae6f6..af371f25e7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -307,6 +307,17 @@ public class BubbleBarView extends FrameLayout { } } + @Override + public void setAlpha(float alpha) { + super.setAlpha(alpha); + int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + View childView = getChildAt(i); + if (!(childView instanceof BubbleView)) continue; + ((BubbleView) childView).setProvideShadowOutline(alpha == 1f); + } + } + /** * Sets new icon sizes and newBubbleBarPadding between icons and bubble bar borders. * diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java index 3bcaa16f40..6db42a4c53 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleView.java @@ -70,6 +70,8 @@ public class BubbleView extends ConstraintLayout { // The current scale value of the dot private float mDotScale; + private boolean mProvideShadowOutline = true; + // TODO: (b/273310265) handle RTL // Whether the bubbles are positioned on the left or right side of the screen private boolean mOnLeft = false; @@ -113,17 +115,28 @@ public class BubbleView extends ConstraintLayout { }); } + //TODO(b/345490679) remove once proper shadow is applied + /** Set whether provide an outline. */ + public void setProvideShadowOutline(boolean provideOutline) { + if (mProvideShadowOutline == provideOutline) return; + mProvideShadowOutline = provideOutline; + invalidateOutline(); + } + private void getOutline(Outline outline) { updateBubbleSizeAndDotRender(); final int normalizedSize = IconNormalizer.getNormalizedCircleSize(mBubbleSize); final int inset = (mBubbleSize - normalizedSize) / 2; - outline.setOval(inset, inset, inset + normalizedSize, inset + normalizedSize); + if (mProvideShadowOutline) { + outline.setOval(inset, inset, inset + normalizedSize, inset + normalizedSize); + } } private void updateBubbleSizeAndDotRender() { int updatedBubbleSize = Math.min(getWidth(), getHeight()); if (updatedBubbleSize == mBubbleSize) return; mBubbleSize = updatedBubbleSize; + invalidateOutline(); if (mBubble == null || mBubble instanceof BubbleBarOverflow) return; Path dotPath = ((BubbleBarBubble) mBubble).getDotPath(); mDotRenderer = new DotRenderer(mBubbleSize, dotPath, DEFAULT_PATH_SIZE);