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
diff --git a/quickstep/res/layout/transient_taskbar.xml b/quickstep/res/layout/transient_taskbar.xml
index d212ffd..3c6878a 100644
--- a/quickstep/res/layout/transient_taskbar.xml
+++ b/quickstep/res/layout/transient_taskbar.xml
@@ -41,9 +41,10 @@
<com.android.launcher3.taskbar.bubbles.BubbleBarView
android:id="@+id/taskbar_bubbles"
android:layout_width="wrap_content"
- android:layout_height="@dimen/bubblebar_size"
+ android:layout_height="@dimen/bubblebar_size_with_pointer"
android:layout_gravity="bottom|end"
android:layout_marginHorizontal="@dimen/transient_taskbar_bottom_margin"
+ android:paddingTop="@dimen/bubblebar_pointer_size"
android:paddingEnd="@dimen/taskbar_icon_spacing"
android:paddingStart="@dimen/taskbar_icon_spacing"
android:visibility="gone"
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 3331321..0e18fb4 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -413,6 +413,8 @@
<dimen name="bubblebar_stashed_size">@dimen/transient_taskbar_stashed_height</dimen>
<dimen name="bubblebar_stashed_handle_height">@dimen/taskbar_stashed_handle_height</dimen>
<dimen name="bubblebar_pointer_size">8dp</dimen>
+ <!-- Container size with pointer included: bubblebar_size + bubblebar_pointer_size -->
+ <dimen name="bubblebar_size_with_pointer">80dp</dimen>
<dimen name="bubblebar_elevation">1dp</dimen>
<dimen name="bubblebar_hotseat_adjustment_threshold">90dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt
index aa2b29d..9f14ebf 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.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 @@
// 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 @@
}
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 b6c248c..1f3c483 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 @@
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 a328c90..a5da65f 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 @@
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 @@
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 @@
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 @@
if (bubbleBarLocation != mBubbleBarLocation) {
mBubbleBarLocation = bubbleBarLocation;
onBubbleBarLocationChanged();
+ invalidate();
}
}
@@ -344,7 +348,7 @@
* 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 cc5859e..d46ee40 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 @@
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 @@
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 @@
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();