From 4186cf1b968db95cf0c43daa4378b6a24bf3d409 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Mon, 4 Mar 2024 15:26:07 -0800 Subject: [PATCH] Fix bubble bar arrow visibility during animation Bubble bar pointer arrow was being drawn outside of BubbleBarView bounds. This caused issues when alpha was applied to the BubbleBarView. With alpha, BubbleBarView draw was clipped to its bounds and arrow was no longer visible. This led to the arrow flickering during move animations. Move animation updates alpha. Move the pointer arrow inside the bounds of the bar view. Update the bar height to include the arrow. Update callers who rely on bubble bar content height to take into account extra height for the arrow. Bug: 313661121 Flag: ACONFIG com.android.wm.shell.enable_bubble_bar DEVELOPMENT Test: move bubble bar left and right, observe arrow is visible Change-Id: I05866b5c944361b2f10437c3641527ed3c594047 --- quickstep/res/layout/transient_taskbar.xml | 3 +- quickstep/res/values/dimens.xml | 2 ++ .../taskbar/bubbles/BubbleBarBackground.kt | 28 +++++++++++++++---- .../taskbar/bubbles/BubbleBarController.java | 2 +- .../taskbar/bubbles/BubbleBarView.java | 8 ++++-- .../bubbles/BubbleBarViewController.java | 9 ++++-- 6 files changed, 41 insertions(+), 11 deletions(-) diff --git a/quickstep/res/layout/transient_taskbar.xml b/quickstep/res/layout/transient_taskbar.xml index d212ffdbbe..3c6878a6e5 100644 --- a/quickstep/res/layout/transient_taskbar.xml +++ b/quickstep/res/layout/transient_taskbar.xml @@ -41,9 +41,10 @@ @dimen/transient_taskbar_stashed_height @dimen/taskbar_stashed_handle_height 8dp + + 80dp 1dp 90dp diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt index aa2b29de39..9f14ebffff 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt @@ -19,6 +19,7 @@ import android.graphics.Canvas import android.graphics.Color import android.graphics.ColorFilter import android.graphics.Paint +import android.graphics.PixelFormat import android.graphics.drawable.Drawable import android.graphics.drawable.ShapeDrawable import com.android.app.animation.Interpolators @@ -122,14 +123,22 @@ class BubbleBarBackground(context: TaskbarActivityContext, private val backgroun // Draw background. val radius = backgroundHeight / 2f - val left = if (anchorLeft) 0f else canvas.width.toFloat() - width - val right = if (anchorLeft) width else canvas.width.toFloat() - canvas.drawRoundRect(left, 0f, right, canvas.height.toFloat(), radius, radius, paint) + val left = if (anchorLeft) 0f else bounds.width().toFloat() - width + val right = if (anchorLeft) width else bounds.width().toFloat() + canvas.drawRoundRect( + left, + pointerSize, + right, + bounds.height().toFloat(), + radius, + radius, + paint + ) if (showingArrow) { // Draw arrow. val transX = arrowPositionX - pointerSize / 2f - canvas.translate(transX, -pointerSize) + canvas.translate(transX, 0f) arrowDrawable.draw(canvas) } @@ -137,11 +146,20 @@ class BubbleBarBackground(context: TaskbarActivityContext, private val backgroun } override fun getOpacity(): Int { - return paint.alpha + return when (paint.alpha) { + 255 -> PixelFormat.OPAQUE + 0 -> PixelFormat.TRANSPARENT + else -> PixelFormat.TRANSLUCENT + } } override fun setAlpha(alpha: Int) { paint.alpha = alpha + arrowDrawable.paint.alpha = alpha + } + + override fun getAlpha(): Int { + return paint.alpha } override fun setColorFilter(colorFilter: ColorFilter?) { diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index b6c248cb10..1f3c4839ab 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -614,7 +614,7 @@ public class BubbleBarController extends IBubblesListener.Stub { location.right = currentBarBounds.right; } final int translation = (int) abs(mBubbleStashController.getBubbleBarTranslationY()); - location.top = displaySize.y - mBarView.getHeight() - translation; + location.top = displaySize.y - currentBarBounds.height() - translation; location.bottom = displaySize.y - translation; return location; } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index a328c90e4f..a5da65f660 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -110,6 +110,7 @@ public class BubbleBarView extends FrameLayout { private final float mIconSize; // The elevation of the bubbles within the bar private final float mBubbleElevation; + private final int mPointerSize; // Whether the bar is expanded (i.e. the bubble activity is being displayed). private boolean mIsBarExpanded = false; @@ -166,6 +167,8 @@ public class BubbleBarView extends FrameLayout { mIconSpacing = getResources().getDimensionPixelSize(R.dimen.bubblebar_icon_spacing); mIconSize = getResources().getDimensionPixelSize(R.dimen.bubblebar_icon_size); mBubbleElevation = getResources().getDimensionPixelSize(R.dimen.bubblebar_icon_elevation); + mPointerSize = getResources().getDimensionPixelSize(R.dimen.bubblebar_pointer_size); + setClipToPadding(false); mBubbleBarBackground = new BubbleBarBackground(activityContext, @@ -214,7 +217,7 @@ public class BubbleBarView extends FrameLayout { protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); mBubbleBarBounds.left = left; - mBubbleBarBounds.top = top; + mBubbleBarBounds.top = top + mPointerSize; mBubbleBarBounds.right = right; mBubbleBarBounds.bottom = bottom; @@ -272,6 +275,7 @@ public class BubbleBarView extends FrameLayout { if (bubbleBarLocation != mBubbleBarLocation) { mBubbleBarLocation = bubbleBarLocation; onBubbleBarLocationChanged(); + invalidate(); } } @@ -344,7 +348,7 @@ public class BubbleBarView extends FrameLayout { * Updates the bounds with translation that may have been applied and returns the result. */ public Rect getBubbleBarBounds() { - mBubbleBarBounds.top = getTop() + (int) getTranslationY(); + mBubbleBarBounds.top = getTop() + (int) getTranslationY() + mPointerSize; mBubbleBarBounds.bottom = getBottom() + (int) getTranslationY(); return mBubbleBarBounds; } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index cc5859e1e4..d46ee4020f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -55,6 +55,7 @@ public class BubbleBarViewController { private final TaskbarActivityContext mActivity; private final BubbleBarView mBarView; private final int mIconSize; + private final int mPointerSize; // Initialized in init. private BubbleStashController mBubbleStashController; @@ -87,6 +88,8 @@ public class BubbleBarViewController { mBubbleBarAlpha = new MultiValueAlpha(mBarView, 1 /* num alpha channels */); mBubbleBarAlpha.setUpdateVisibility(true); mIconSize = activity.getResources().getDimensionPixelSize(R.dimen.bubblebar_icon_size); + mPointerSize = activity.getResources().getDimensionPixelSize( + R.dimen.bubblebar_pointer_size); } public void init(TaskbarControllers controllers, BubbleControllers bubbleControllers) { @@ -97,9 +100,11 @@ public class BubbleBarViewController { mTaskbarInsetsController = controllers.taskbarInsetsController; mActivity.addOnDeviceProfileChangeListener(dp -> - mBarView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarHeight + mBarView.getLayoutParams().height = + mActivity.getDeviceProfile().taskbarHeight + mPointerSize ); - mBarView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarHeight; + mBarView.getLayoutParams().height = + mActivity.getDeviceProfile().taskbarHeight + mPointerSize; mBubbleBarScale.updateValue(1f); mBubbleClickListener = v -> onBubbleClicked(v); mBubbleBarClickListener = v -> onBubbleBarClicked();