summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Michael Mikhail <michaelmikhil@google.com> 2025-01-08 23:52:37 +0000
committer Michael Mikhail <michaelmikhil@google.com> 2025-01-09 16:23:59 +0000
commit28ec2da3cf10c233ef5eb2ec1debbe3d9c58189d (patch)
tree3000c7f67da9a2b0c3aadb1b6450f5f7e288e620
parenta1764c81222f111080949558c4385d81ab57dd5b (diff)
Fix corner and color animation of ringer drawer
Flag: com.android.systemui.volume_redesign Fixes: 388234771 Test: Checked UI. Change-Id: Ibe951ce4340b8bd618a77cf9decc5b4d920a466c
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/ui/binder/VolumeDialogRingerViewBinder.kt64
1 files changed, 37 insertions, 27 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/ui/binder/VolumeDialogRingerViewBinder.kt b/packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/ui/binder/VolumeDialogRingerViewBinder.kt
index e8d19dd5e0e4..96630ca36b97 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/ui/binder/VolumeDialogRingerViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/ui/binder/VolumeDialogRingerViewBinder.kt
@@ -51,6 +51,8 @@ import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.launch
private const val CLOSE_DRAWER_DELAY = 300L
+// Ensure roundness and color of button is updated when progress is changed by a minimum fraction.
+private const val BUTTON_MIN_VISIBLE_CHANGE = 0.05F
@OptIn(ExperimentalCoroutinesApi::class)
@VolumeDialogScope
@@ -58,12 +60,12 @@ class VolumeDialogRingerViewBinder
@Inject
constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
private val roundnessSpringForce =
- SpringForce(0F).apply {
+ SpringForce(1F).apply {
stiffness = 800F
dampingRatio = 0.6F
}
private val colorSpringForce =
- SpringForce(0F).apply {
+ SpringForce(1F).apply {
stiffness = 3800F
dampingRatio = 1F
}
@@ -257,30 +259,35 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
// We only need to execute on roundness animation end and volume dialog background
// progress update once because these changes should be applied once on volume dialog
// background and ringer drawer views.
- val selectedCornerRadius = (selectedButton.background as GradientDrawable).cornerRadius
- if (selectedCornerRadius.toInt() != selectedButtonUiModel.cornerRadius) {
- selectedButton.animateTo(
- selectedButtonUiModel,
- if (uiModel.currentButtonIndex == count - 1) {
- onProgressChanged
- } else {
- { _, _ -> }
- },
- )
- }
- val unselectedCornerRadius =
- (unselectedButton.background as GradientDrawable).cornerRadius
- if (unselectedCornerRadius.toInt() != unselectedButtonUiModel.cornerRadius) {
- unselectedButton.animateTo(
- unselectedButtonUiModel,
- if (previousIndex == count - 1) {
- onProgressChanged
- } else {
- { _, _ -> }
- },
- )
- }
coroutineScope {
+ val selectedCornerRadius =
+ (selectedButton.background as GradientDrawable).cornerRadius
+ if (selectedCornerRadius.toInt() != selectedButtonUiModel.cornerRadius) {
+ launch {
+ selectedButton.animateTo(
+ selectedButtonUiModel,
+ if (uiModel.currentButtonIndex == count - 1) {
+ onProgressChanged
+ } else {
+ { _, _ -> }
+ },
+ )
+ }
+ }
+ val unselectedCornerRadius =
+ (unselectedButton.background as GradientDrawable).cornerRadius
+ if (unselectedCornerRadius.toInt() != unselectedButtonUiModel.cornerRadius) {
+ launch {
+ unselectedButton.animateTo(
+ unselectedButtonUiModel,
+ if (previousIndex == count - 1) {
+ onProgressChanged
+ } else {
+ { _, _ -> }
+ },
+ )
+ }
+ }
launch {
delay(CLOSE_DRAWER_DELAY)
bindButtons(viewModel, uiModel, onAnimationEnd, isAnimated = true)
@@ -383,11 +390,14 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
onProgressChanged: (Float, Boolean) -> Unit = { _, _ -> },
) {
val roundnessAnimation =
- SpringAnimation(FloatValueHolder(0F)).setSpring(roundnessSpringForce)
- val colorAnimation = SpringAnimation(FloatValueHolder(0F)).setSpring(colorSpringForce)
+ SpringAnimation(FloatValueHolder(0F), 1F).setSpring(roundnessSpringForce)
+ val colorAnimation = SpringAnimation(FloatValueHolder(0F), 1F).setSpring(colorSpringForce)
val radius = (background as GradientDrawable).cornerRadius
val cornerRadiusDiff =
ringerButtonUiModel.cornerRadius - (background as GradientDrawable).cornerRadius
+
+ roundnessAnimation.minimumVisibleChange = BUTTON_MIN_VISIBLE_CHANGE
+ colorAnimation.minimumVisibleChange = BUTTON_MIN_VISIBLE_CHANGE
coroutineScope {
launch {
colorAnimation.suspendAnimate { value ->