From 94db320a8409c5930f4dd9a8cf92519796d1f8c1 Mon Sep 17 00:00:00 2001 From: Toni Barzic Date: Fri, 7 Mar 2025 20:43:49 +0000 Subject: [PATCH] Update KQS task view borders Updates border color to have more contrast to the background, and adds 2dp padding between the border and the task content view - done by updating BorderAnimator not to assume the border width and stroke are the same. Adding padding between the border and task view content exopsed an issue where the second thumbnail in a split task's borders were not clipped correctly when adding a border (it looked like the clip rect was not properly scaled down). This is addressed by moving the tack view background (and the outline) from the root KeyboardQuickSwitchTaskViews to the content views (i.e. moving the outline to the view that does not get scaled when adding a border, and having the second thumbnail end edge of the clip rectangle match the clip rectangle of the clipped ancestor view). Bug: 398770098 Test: Manual Flag: EXEMPT (a11y) bug fix Change-Id: Ie058c932411a6b47815b0abf756f739c55b8342f --- .../keyboard_quick_switch_taskview.xml | 6 ++-- .../keyboard_quick_switch_taskview_square.xml | 6 ++-- ...keyboard_quick_switch_desktop_taskview.xml | 4 +-- ...eyboard_quick_switch_overview_taskview.xml | 4 +-- .../layout/keyboard_quick_switch_taskview.xml | 6 ++-- .../keyboard_quick_switch_taskview_square.xml | 6 ++-- quickstep/res/values/dimens.xml | 3 +- .../taskbar/KeyboardQuickSwitchTaskView.java | 4 ++- .../android/quickstep/util/BorderAnimator.kt | 29 +++++++++++++------ 9 files changed, 41 insertions(+), 27 deletions(-) diff --git a/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml b/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml index b44510d47c..b45a04ad2a 100644 --- a/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml +++ b/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml @@ -21,14 +21,14 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:importantForAccessibility="yes" - android:background="@drawable/keyboard_quick_switch_task_view_background" - android:clipToOutline="true" - launcher:focusBorderColor="@color/materialColorOutline"> + launcher:focusBorderColor="@color/materialColorSecondary"> + launcher:focusBorderColor="@color/materialColorSecondary"> + launcher:focusBorderColor="@color/materialColorSecondary"> + launcher:focusBorderColor="@color/materialColorSecondary"> 20dp - 4dp + 5dp + 3dp 104dp 136dp 52dp diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java index 15be03a55b..c49029daf9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java @@ -129,7 +129,9 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout { : resources.getDimensionPixelSize( R.dimen.keyboard_quick_switch_task_view_radius), /* borderWidthPx= */ resources.getDimensionPixelSize( - R.dimen.keyboard_quick_switch_border_width), + R.dimen.keyboard_quick_switch_border_width), + /* borderStrokePx= */ resources.getDimensionPixelSize( + R.dimen.keyboard_quick_switch_border_stroke), /* boundsBuilder= */ bounds -> { bounds.set(0, 0, getWidth(), getHeight()); return Unit.INSTANCE; diff --git a/quickstep/src/com/android/quickstep/util/BorderAnimator.kt b/quickstep/src/com/android/quickstep/util/BorderAnimator.kt index 7e51fcfedc..d1d47b9fa5 100644 --- a/quickstep/src/com/android/quickstep/util/BorderAnimator.kt +++ b/quickstep/src/com/android/quickstep/util/BorderAnimator.kt @@ -114,6 +114,8 @@ private constructor( * * @param borderRadiusPx the radius of the border's corners, in pixels * @param borderWidthPx the width of the border, in pixels + * @param borderStrokePx the stroke width used to paint the border, in pixels. If smaller + * than border width, it gets drawn at the outside edge of the border. * @param boundsBuilder callback to update the border bounds * @param targetView the view that will be drawing the border * @param contentView the view around which the border will be drawn. this view will be @@ -128,6 +130,7 @@ private constructor( fun createScalingBorderAnimator( @Px borderRadiusPx: Int, @Px borderWidthPx: Int, + @Px borderStrokePx: Int, boundsBuilder: (rect: Rect?) -> Unit, targetView: View, contentView: View, @@ -139,7 +142,13 @@ private constructor( return BorderAnimator( borderRadiusPx, borderColor, - ScalingParams(borderWidthPx, boundsBuilder, targetView, contentView), + ScalingParams( + borderWidthPx, + borderStrokePx, + boundsBuilder, + targetView, + contentView, + ), appearanceDurationMs, disappearanceDurationMs, interpolator, @@ -151,7 +160,7 @@ private constructor( val interpolatedProgress = interpolator.getInterpolation(borderAnimationProgress.value) borderAnimationParams.animationProgress = interpolatedProgress borderPaint.alpha = (255 * interpolatedProgress).roundToInt() - borderPaint.strokeWidth = borderAnimationParams.borderWidth + borderPaint.strokeWidth = borderAnimationParams.borderStroke borderAnimationParams.targetView.invalidate() } @@ -170,7 +179,7 @@ private constructor( /* bottom= */ borderBounds.bottom - alignmentAdjustment, /* rx= */ radius, /* ry= */ radius, - /* paint= */ borderPaint + /* paint= */ borderPaint, ) } } @@ -212,6 +221,7 @@ private constructor( /** Params for handling different target view layout situations. */ private abstract class BorderAnimationParams( @field:Px @param:Px val borderWidthPx: Int, + @field:Px @param:Px val borderStrokePx: Int, private val boundsBuilder: (rect: Rect) -> Unit, val targetView: View, ) { @@ -222,12 +232,12 @@ private constructor( abstract val alignmentAdjustmentInset: Int abstract val radiusAdjustment: Float - val borderWidth: Float - get() = borderWidthPx * animationProgress + val borderStroke: Float + get() = borderStrokePx * animationProgress val alignmentAdjustment: Float // Outset the border by half the width to create an outwards-growth animation - get() = -borderWidth / 2f + alignmentAdjustmentInset + get() = -borderStroke / 2f + alignmentAdjustmentInset open fun onShowBorder() { if (layoutChangeListener == null) { @@ -253,7 +263,7 @@ private constructor( @Px borderWidthPx: Int, boundsBuilder: (Rect) -> Unit, targetView: View, - ) : BorderAnimationParams(borderWidthPx, boundsBuilder, targetView) { + ) : BorderAnimationParams(borderWidthPx, borderWidthPx, boundsBuilder, targetView) { override val alignmentAdjustmentInset = 0 override val radiusAdjustment: Float get() = -alignmentAdjustment @@ -265,12 +275,13 @@ private constructor( */ private class ScalingParams( @Px borderWidthPx: Int, + @Px borderStrokePx: Int, boundsBuilder: (rect: Rect?) -> Unit, targetView: View, private val contentView: View, - ) : BorderAnimationParams(borderWidthPx, boundsBuilder, targetView) { + ) : BorderAnimationParams(borderWidthPx, borderStrokePx, boundsBuilder, targetView) { // Inset the border since we are scaling the container up - override val alignmentAdjustmentInset = borderWidthPx + override val alignmentAdjustmentInset = borderStrokePx override val radiusAdjustment: Float // Increase the radius since we are scaling the container up get() = alignmentAdjustment