Updated pointer to match visual specification.
Updated bubble bar view pointer to have rounded tip.
Test: BubbleBarViewAnimatorTest
Fixes: 333546362
Flag: ACONFIG com.android.wm.shell.enable_bubble_bar DEVELOPMENT
Change-Id: I7875426b06a330bc355a833c51849335f831317e
diff --git a/quickstep/res/layout/transient_taskbar.xml b/quickstep/res/layout/transient_taskbar.xml
index 3c6878a..7c55bf8 100644
--- a/quickstep/res/layout/transient_taskbar.xml
+++ b/quickstep/res/layout/transient_taskbar.xml
@@ -44,7 +44,7 @@
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:paddingTop="@dimen/bubblebar_pointer_visible_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 dc28614..9ca8060 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -420,7 +420,12 @@
<dimen name="bubblebar_stashed_handle_width">55dp</dimen>
<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>
+ <!-- this is a pointer height minus 1dp to ensure the pointer overlaps with the bubblebar
+ background appropriately when close to the rounded corner -->
+ <dimen name="bubblebar_pointer_visible_size">9dp</dimen>
+ <dimen name="bubblebar_pointer_width">12dp</dimen>
+ <dimen name="bubblebar_pointer_height">10dp</dimen>
+ <dimen name="bubblebar_pointer_radius">2dp</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>
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt
index 9799349..ec47c4f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt
@@ -22,13 +22,12 @@
import android.graphics.Paint
import android.graphics.PixelFormat
import android.graphics.drawable.Drawable
-import android.graphics.drawable.ShapeDrawable
import com.android.app.animation.Interpolators
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.Utilities.mapToRange
import com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound
-import com.android.wm.shell.common.TriangleShape
+import com.android.launcher3.popup.RoundedArrowDrawable
/** Drawable for the background of the bubble bar. */
class BubbleBarBackground(context: Context, private var backgroundHeight: Float) : Drawable() {
@@ -37,7 +36,10 @@
private val LIGHT_THEME_SHADOW_ALPHA = 25f
private val paint: Paint = Paint()
- private val pointerSize: Float
+ private val pointerWidth: Float
+ private val pointerHeight: Float
+ private val pointerTipRadius: Float
+ private val pointerVisibleHeight: Float
private val shadowAlpha: Float
private var shadowBlur = 0f
@@ -47,7 +49,7 @@
private set
private var showingArrow: Boolean = false
- private var arrowDrawable: ShapeDrawable
+ private var arrowDrawable: RoundedArrowDrawable
var width: Float = 0f
@@ -75,7 +77,10 @@
val res = context.resources
shadowBlur = res.getDimension(R.dimen.transient_taskbar_shadow_blur)
keyShadowDistance = res.getDimension(R.dimen.transient_taskbar_key_shadow_distance)
- pointerSize = res.getDimension(R.dimen.bubblebar_pointer_size)
+ pointerWidth = res.getDimension(R.dimen.bubblebar_pointer_width)
+ pointerHeight = res.getDimension(R.dimen.bubblebar_pointer_height)
+ pointerVisibleHeight = res.getDimension(R.dimen.bubblebar_pointer_visible_size)
+ pointerTipRadius = res.getDimension(R.dimen.bubblebar_pointer_radius)
shadowAlpha =
if (Utilities.isDarkTheme(context)) {
@@ -85,11 +90,14 @@
}
arrowDrawable =
- ShapeDrawable(TriangleShape.create(pointerSize, pointerSize, /* pointUp= */ true))
- arrowDrawable.setBounds(0, 0, pointerSize.toInt(), pointerSize.toInt())
- arrowDrawable.paint.flags = Paint.ANTI_ALIAS_FLAG
- arrowDrawable.paint.style = Paint.Style.FILL
- arrowDrawable.paint.color = context.getColor(R.color.taskbar_background)
+ RoundedArrowDrawable.createVerticalRoundedArrow(
+ pointerWidth,
+ pointerHeight,
+ pointerTipRadius,
+ /* isPointingUp= */ true,
+ context.getColor(R.color.taskbar_background)
+ )
+ arrowDrawable.setBounds(0, 0, pointerWidth.toInt(), pointerHeight.toInt())
}
fun showArrow(show: Boolean) {
@@ -114,7 +122,7 @@
keyShadowDistance,
setColorAlphaBound(Color.BLACK, Math.round(newShadowAlpha))
)
- arrowDrawable.paint.setShadowLayer(
+ arrowDrawable.setShadowLayer(
shadowBlur,
0f,
keyShadowDistance,
@@ -127,7 +135,7 @@
val right = if (anchorLeft) width else bounds.width().toFloat()
canvas.drawRoundRect(
left,
- pointerSize,
+ pointerVisibleHeight,
right,
bounds.height().toFloat(),
radius,
@@ -137,10 +145,8 @@
if (showingArrow) {
// Draw arrow.
- val transX = arrowPositionX - pointerSize / 2f
- // Shift arrow down by 1 pixel. Rounded rect has a 1 pixel border which will show up
- // between background and arrow otherwise.
- canvas.translate(transX, 1f)
+ val transX = arrowPositionX - pointerWidth / 2f
+ canvas.translate(transX, 0f)
arrowDrawable.draw(canvas)
}
@@ -157,7 +163,7 @@
override fun setAlpha(alpha: Int) {
paint.alpha = alpha
- arrowDrawable.paint.alpha = alpha
+ arrowDrawable.alpha = alpha
}
override fun getAlpha(): Int {
@@ -169,7 +175,7 @@
}
fun setArrowAlpha(alpha: Int) {
- arrowDrawable.paint.alpha = alpha
+ arrowDrawable.alpha = alpha
}
fun setHeight(newHeight: Float) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
index 1003c3f..110c30f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
@@ -177,7 +177,8 @@
R.dimen.bubblebar_expanded_icon_spacing);
mBubbleElevation = getResources().getDimensionPixelSize(R.dimen.bubblebar_icon_elevation);
mDragElevation = getResources().getDimensionPixelSize(R.dimen.bubblebar_drag_elevation);
- mPointerSize = getResources().getDimensionPixelSize(R.dimen.bubblebar_pointer_size);
+ mPointerSize = getResources()
+ .getDimensionPixelSize(R.dimen.bubblebar_pointer_visible_size);
setClipToPadding(false);
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt
index c124f03..1db04a8 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt
@@ -347,7 +347,7 @@
override fun updateArrowColor() {
mArrow.background =
- RoundedArrowDrawable(
+ RoundedArrowDrawable.createHorizontalRoundedArrow(
mArrowWidth.toFloat(),
mArrowHeight.toFloat(),
mArrowPointRadius.toFloat(),
diff --git a/src/com/android/launcher3/popup/RoundedArrowDrawable.java b/src/com/android/launcher3/popup/RoundedArrowDrawable.java
index 436aa51..575052c 100644
--- a/src/com/android/launcher3/popup/RoundedArrowDrawable.java
+++ b/src/com/android/launcher3/popup/RoundedArrowDrawable.java
@@ -84,11 +84,12 @@
* @param width of the arrow.
* @param height of the arrow.
* @param radius of the tip of the arrow.
- * @param isPointingLeft or not.
+ * @param isHorizontal or not.
+ * @param isLeftOrTop or not.
* @param color to draw the triangle.
*/
- public RoundedArrowDrawable(float width, float height, float radius, boolean isPointingLeft,
- int color) {
+ private RoundedArrowDrawable(float width, float height, float radius, boolean isHorizontal,
+ boolean isLeftOrTop, int color) {
mPath = new Path();
mPaint = new Paint();
mPaint.setColor(color);
@@ -98,10 +99,47 @@
// Make the drawable with the triangle pointing down...
addDownPointingRoundedTriangleToPath(width, height, radius, mPath);
- // ... then rotate it to the side it needs to point.
- Matrix pathTransform = new Matrix();
- pathTransform.setRotate(isPointingLeft ? 90 : -90, width * 0.5f, height * 0.5f);
- mPath.transform(pathTransform);
+ if (isHorizontal || isLeftOrTop) {
+ // ... then rotate it to the side it needs to point.
+ Matrix pathTransform = new Matrix();
+ int rotationAngle;
+ if (isHorizontal) {
+ rotationAngle = isLeftOrTop ? 90 : -90;
+ } else {
+ // it could only be vertical arrow pointing up
+ rotationAngle = 180;
+ }
+ pathTransform.setRotate(rotationAngle, width * 0.5f, height * 0.5f);
+ mPath.transform(pathTransform);
+ }
+ }
+
+ /**
+ * factory method for an arrow that points to the left or right.
+ *
+ * @param width of the arrow.
+ * @param height of the arrow.
+ * @param radius of the tip of the arrow.
+ * @param isPointingLeft or not.
+ * @param color to draw the triangle.
+ */
+ public static RoundedArrowDrawable createHorizontalRoundedArrow(float width, float height,
+ float radius, boolean isPointingLeft, int color) {
+ return new RoundedArrowDrawable(width, height, radius, true, isPointingLeft, color);
+ }
+
+ /**
+ * factory method for an arrow that points to the left or right.
+ *
+ * @param width of the arrow.
+ * @param height of the arrow.
+ * @param radius of the tip of the arrow.
+ * @param isPointingUp or not.
+ * @param color to draw the triangle.
+ */
+ public static RoundedArrowDrawable createVerticalRoundedArrow(float width, float height,
+ float radius, boolean isPointingUp, int color) {
+ return new RoundedArrowDrawable(width, height, radius, false, isPointingUp, color);
}
@Override
@@ -129,6 +167,14 @@
mPaint.setColorFilter(colorFilter);
}
+ /**
+ * Set shadow layer to internal {@link Paint#setShadowLayer(float, float, float, int) paint}
+ * object
+ */
+ public void setShadowLayer(float shadowBlur, float dx, float dy, int shadowColor) {
+ mPaint.setShadowLayer(shadowBlur, dx, dy, shadowColor);
+ }
+
private static void addDownPointingRoundedTriangleToPath(float width, float height,
float radius, Path path) {
// Calculated for the arrow pointing down, will be flipped later if needed.