From 86ecbb5d73e8147a3e736759b846c5f25d1e32ba Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Tue, 16 Mar 2021 14:20:12 -0400 Subject: [PATCH] RESTRICT AUTOMERGE Implement latest design of brightness slider Test: manual Fixes: 182894266 Change-Id: I84f55d0d3605673f66ee3c629adfb1a79a755c84 --- .../brightness_progress_drawable_thick.xml | 33 +++++----------- .../brightness_progress_full_drawable.xml | 4 +- packages/SystemUI/res/values/dimens.xml | 14 ++++--- .../util/RoundedCornerProgressDrawable.kt | 38 ++----------------- 4 files changed, 25 insertions(+), 64 deletions(-) diff --git a/packages/SystemUI/res/drawable/brightness_progress_drawable_thick.xml b/packages/SystemUI/res/drawable/brightness_progress_drawable_thick.xml index 8efe0539207a1..73b02f4fa481f 100644 --- a/packages/SystemUI/res/drawable/brightness_progress_drawable_thick.xml +++ b/packages/SystemUI/res/drawable/brightness_progress_drawable_thick.xml @@ -18,33 +18,20 @@ android:paddingMode="stack" > - - - - - - - - - - - - + + + + + + + - \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/brightness_progress_full_drawable.xml b/packages/SystemUI/res/drawable/brightness_progress_full_drawable.xml index 5bc2773dc6575..41140a7a8c853 100644 --- a/packages/SystemUI/res/drawable/brightness_progress_full_drawable.xml +++ b/packages/SystemUI/res/drawable/brightness_progress_full_drawable.xml @@ -26,10 +26,10 @@ + android:right="@dimen/rounded_slider_icon_inset"> 20dp 6dp - 48dp + 44dp - 24dp - - 24dp - + 22dp + 20dp + 12dp + + 18dp + 8dp + + 4dp diff --git a/packages/SystemUI/src/com/android/systemui/util/RoundedCornerProgressDrawable.kt b/packages/SystemUI/src/com/android/systemui/util/RoundedCornerProgressDrawable.kt index 6aadd1020bce9..dc86d5893adb8 100644 --- a/packages/SystemUI/src/com/android/systemui/util/RoundedCornerProgressDrawable.kt +++ b/packages/SystemUI/src/com/android/systemui/util/RoundedCornerProgressDrawable.kt @@ -17,8 +17,6 @@ package com.android.systemui.util import android.content.res.Resources -import android.graphics.Canvas -import android.graphics.Path import android.graphics.Rect import android.graphics.drawable.Drawable import android.graphics.drawable.DrawableWrapper @@ -43,53 +41,25 @@ class RoundedCornerProgressDrawable @JvmOverloads constructor( private const val MAX_LEVEL = 10000 // Taken from Drawable } - private var clipPath: Path = Path() - - init { - setClipPath(Rect()) - } - override fun onLayoutDirectionChanged(layoutDirection: Int): Boolean { onLevelChange(level) return super.onLayoutDirectionChanged(layoutDirection) } override fun onBoundsChange(bounds: Rect) { - setClipPath(bounds) super.onBoundsChange(bounds) onLevelChange(level) } - private fun setClipPath(bounds: Rect) { - clipPath.reset() - clipPath.addRoundRect( - bounds.left.toFloat(), - bounds.top.toFloat(), - bounds.right.toFloat(), - bounds.bottom.toFloat(), - bounds.height().toFloat() / 2, - bounds.height().toFloat() / 2, - Path.Direction.CW - ) - } - override fun onLevelChange(level: Int): Boolean { val db = drawable?.bounds!! - val width = bounds.width() * level / MAX_LEVEL - // Extra space on the left to keep the rounded shape on the right end - val leftBound = bounds.left - bounds.height() - drawable?.setBounds(leftBound, db.top, bounds.left + width, db.bottom) + // On 0, the width is bounds.height (a circle), and on MAX_LEVEL, the width is bounds.width + val width = bounds.height() + (bounds.width() - bounds.height()) * level / MAX_LEVEL + drawable?.setBounds(bounds.left, db.top, bounds.left + width, db.bottom) return super.onLevelChange(level) } - override fun draw(canvas: Canvas) { - canvas.save() - canvas.clipPath(clipPath) - super.draw(canvas) - canvas.restore() - } - - override fun getConstantState(): ConstantState? { + override fun getConstantState(): ConstantState { // This should not be null as it was created with a state in the constructor. return RoundedCornerState(super.getConstantState()!!) }