Merge "Update KQS task view borders" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
6fcd77c19a
@@ -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">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="@dimen/keyboard_quick_switch_taskview_width"
|
||||
android:layout_height="@dimen/keyboard_quick_switch_taskview_height"
|
||||
android:background="@drawable/keyboard_quick_switch_task_view_background"
|
||||
android:clipToOutline="true"
|
||||
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
@@ -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="@androidprv:color/materialColorOutline">
|
||||
launcher:focusBorderColor="@color/materialColorSecondary">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/keyboard_quick_switch_taskview_height"
|
||||
android:background="@drawable/keyboard_quick_switch_task_view_background"
|
||||
android:clipToOutline="true"
|
||||
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
||||
@@ -20,9 +20,8 @@
|
||||
xmlns:launcher="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToOutline="true"
|
||||
android:importantForAccessibility="yes"
|
||||
launcher:focusBorderColor="@androidprv:color/materialColorOutline"
|
||||
launcher:focusBorderColor="@color/materialColorSecondary"
|
||||
launcher:focusBorderRadius="@dimen/keyboard_quick_switch_text_button_radius">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -31,6 +30,7 @@
|
||||
android:layout_height="@dimen/keyboard_quick_switch_taskview_height"
|
||||
android:background="@drawable/keyboard_quick_switch_text_button_background"
|
||||
android:backgroundTint="@androidprv:color/materialColorSurfaceContainer"
|
||||
android:clipToOutline="true"
|
||||
android:paddingHorizontal="@dimen/keyboard_quick_switch_text_button_horizontal_padding"
|
||||
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
||||
@@ -20,9 +20,8 @@
|
||||
xmlns:launcher="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToOutline="true"
|
||||
android:importantForAccessibility="yes"
|
||||
launcher:focusBorderColor="@androidprv:color/materialColorOutline"
|
||||
launcher:focusBorderColor="@color/materialColorSecondary"
|
||||
launcher:focusBorderRadius="@dimen/keyboard_quick_switch_text_button_radius">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -31,6 +30,7 @@
|
||||
android:layout_height="@dimen/keyboard_quick_switch_taskview_height"
|
||||
android:background="@drawable/keyboard_quick_switch_text_button_background"
|
||||
android:backgroundTint="@androidprv:color/materialColorSurfaceBright"
|
||||
android:clipToOutline="true"
|
||||
android:paddingHorizontal="@dimen/keyboard_quick_switch_text_button_horizontal_padding"
|
||||
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
||||
@@ -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">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="@dimen/keyboard_quick_switch_taskview_width"
|
||||
android:layout_height="@dimen/keyboard_quick_switch_taskview_height"
|
||||
android:background="@drawable/keyboard_quick_switch_task_view_background"
|
||||
android:clipToOutline="true"
|
||||
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
@@ -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="@androidprv:color/materialColorOutline">
|
||||
launcher:focusBorderColor="@color/materialColorSecondary">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/keyboard_quick_switch_taskview_height"
|
||||
android:background="@drawable/keyboard_quick_switch_task_view_background"
|
||||
android:clipToOutline="true"
|
||||
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
||||
@@ -510,7 +510,8 @@
|
||||
<dimen name="starting_surface_exit_animation_window_shift_length">20dp</dimen>
|
||||
|
||||
<!-- Keyboard Quick Switch -->
|
||||
<dimen name="keyboard_quick_switch_border_width">4dp</dimen>
|
||||
<dimen name="keyboard_quick_switch_border_width">5dp</dimen>
|
||||
<dimen name="keyboard_quick_switch_border_stroke">3dp</dimen>
|
||||
<dimen name="keyboard_quick_switch_taskview_width">104dp</dimen>
|
||||
<dimen name="keyboard_quick_switch_taskview_height">136dp</dimen>
|
||||
<dimen name="keyboard_quick_switch_taskview_icon_size">52dp</dimen>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user