Loading packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/ui/binder/VolumeDialogRingerViewBinder.kt +37 −27 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 } Loading Loading @@ -257,8 +259,11 @@ 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 coroutineScope { val selectedCornerRadius = (selectedButton.background as GradientDrawable).cornerRadius if (selectedCornerRadius.toInt() != selectedButtonUiModel.cornerRadius) { launch { selectedButton.animateTo( selectedButtonUiModel, if (uiModel.currentButtonIndex == count - 1) { Loading @@ -268,9 +273,11 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) { }, ) } } val unselectedCornerRadius = (unselectedButton.background as GradientDrawable).cornerRadius if (unselectedCornerRadius.toInt() != unselectedButtonUiModel.cornerRadius) { launch { unselectedButton.animateTo( unselectedButtonUiModel, if (previousIndex == count - 1) { Loading @@ -280,7 +287,7 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) { }, ) } coroutineScope { } launch { delay(CLOSE_DRAWER_DELAY) bindButtons(viewModel, uiModel, onAnimationEnd, isAnimated = true) Loading Loading @@ -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 -> Loading Loading
packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/ui/binder/VolumeDialogRingerViewBinder.kt +37 −27 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 } Loading Loading @@ -257,8 +259,11 @@ 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 coroutineScope { val selectedCornerRadius = (selectedButton.background as GradientDrawable).cornerRadius if (selectedCornerRadius.toInt() != selectedButtonUiModel.cornerRadius) { launch { selectedButton.animateTo( selectedButtonUiModel, if (uiModel.currentButtonIndex == count - 1) { Loading @@ -268,9 +273,11 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) { }, ) } } val unselectedCornerRadius = (unselectedButton.background as GradientDrawable).cornerRadius if (unselectedCornerRadius.toInt() != unselectedButtonUiModel.cornerRadius) { launch { unselectedButton.animateTo( unselectedButtonUiModel, if (previousIndex == count - 1) { Loading @@ -280,7 +287,7 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) { }, ) } coroutineScope { } launch { delay(CLOSE_DRAWER_DELAY) bindButtons(viewModel, uiModel, onAnimationEnd, isAnimated = true) Loading Loading @@ -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 -> Loading