summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/res/layout/volume_dialog.xml19
-rw-r--r--packages/SystemUI/res/values/dimens.xml4
-rw-r--r--packages/SystemUI/res/xml/volume_dialog_constraint_set.xml18
-rw-r--r--packages/SystemUI/res/xml/volume_dialog_half_folded_constraint_set.xml18
-rw-r--r--packages/SystemUI/res/xml/volume_dialog_scene.xml27
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/ui/binder/VolumeDialogRingerViewBinder.kt18
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dialog/settings/ui/binder/VolumeDialogSettingsButtonViewBinder.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogOverscrollViewBinder.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogSliderViewBinder.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogSlidersViewBinder.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dialog/ui/binder/VolumeDialogViewBinder.kt51
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogViewModel.kt8
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/ui/binder/VolumeDialogViewBinderKosmos.kt2
13 files changed, 74 insertions, 117 deletions
diff --git a/packages/SystemUI/res/layout/volume_dialog.xml b/packages/SystemUI/res/layout/volume_dialog.xml
index 889aefed0c5c..f41eaec8e18b 100644
--- a/packages/SystemUI/res/layout/volume_dialog.xml
+++ b/packages/SystemUI/res/layout/volume_dialog.xml
@@ -13,14 +13,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/volume_dialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
- android:clipChildren="false"
- app:layoutDescription="@xml/volume_dialog_scene">
+ android:clipChildren="false">
<View
android:id="@+id/volume_dialog_background"
@@ -52,7 +51,17 @@
<include
android:id="@+id/volume_dialog_main_slider_container"
- layout="@layout/volume_dialog_slider" />
+ layout="@layout/volume_dialog_slider"
+ android:layout_width="@dimen/volume_dialog_slider_width"
+ android:layout_height="0dp"
+ android:layout_marginTop="@dimen/volume_dialog_slider_vertical_margin"
+ android:layout_marginEnd="@dimen/volume_dialog_window_margin"
+ android:layout_marginBottom="@dimen/volume_dialog_slider_vertical_margin"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHeight_max="@dimen/volume_dialog_slider_height"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_bias="0.5" />
<FrameLayout
android:id="@+id/volume_dialog_bottom_section_container"
@@ -88,4 +97,4 @@
app:layout_constraintEnd_toStartOf="@id/volume_dialog_background"
app:layout_constraintTop_toTopOf="@id/volume_dialog_main_slider_container" />
-</androidx.constraintlayout.motion.widget.MotionLayout>
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 7d0c393f53b5..17a89b3a0394 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -2183,9 +2183,7 @@
orientation when the vertical space is limited
-->
<dimen name="volume_dialog_slider_vertical_margin">124dp</dimen>
-
- <fraction name="volume_dialog_half_opened_bias">0.2</fraction>
-
+ <dimen name="volume_dialog_half_opened_offset">-128dp</dimen>
<dimen name="volume_dialog_slider_max_deviation">56dp</dimen>
<dimen name="volume_dialog_background_square_corner_radius">12dp</dimen>
diff --git a/packages/SystemUI/res/xml/volume_dialog_constraint_set.xml b/packages/SystemUI/res/xml/volume_dialog_constraint_set.xml
deleted file mode 100644
index dcc5d4f6635f..000000000000
--- a/packages/SystemUI/res/xml/volume_dialog_constraint_set.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ConstraintSet xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/volume_dialog_constraint_set">
-
- <Constraint
- android:id="@id/volume_dialog_main_slider_container"
- android:layout_width="@dimen/volume_dialog_slider_width"
- android:layout_height="0dp"
- android:layout_marginTop="@dimen/volume_dialog_slider_vertical_margin"
- android:layout_marginEnd="@dimen/volume_dialog_window_margin"
- android:layout_marginBottom="@dimen/volume_dialog_slider_vertical_margin"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHeight_max="@dimen/volume_dialog_slider_height"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintVertical_bias="0.5" />
-</ConstraintSet> \ No newline at end of file
diff --git a/packages/SystemUI/res/xml/volume_dialog_half_folded_constraint_set.xml b/packages/SystemUI/res/xml/volume_dialog_half_folded_constraint_set.xml
deleted file mode 100644
index 3a5e41d5781a..000000000000
--- a/packages/SystemUI/res/xml/volume_dialog_half_folded_constraint_set.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ConstraintSet xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/volume_dialog_half_folded_constraint_set">
-
- <Constraint
- android:id="@id/volume_dialog_main_slider_container"
- android:layout_width="@dimen/volume_dialog_slider_width"
- android:layout_height="0dp"
- android:layout_marginTop="@dimen/volume_dialog_slider_vertical_margin"
- android:layout_marginEnd="@dimen/volume_dialog_window_margin"
- android:layout_marginBottom="@dimen/volume_dialog_slider_vertical_margin"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHeight_max="@dimen/volume_dialog_slider_height"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintVertical_bias="@fraction/volume_dialog_half_opened_bias" />
-</ConstraintSet> \ No newline at end of file
diff --git a/packages/SystemUI/res/xml/volume_dialog_scene.xml b/packages/SystemUI/res/xml/volume_dialog_scene.xml
deleted file mode 100644
index b813474490bb..000000000000
--- a/packages/SystemUI/res/xml/volume_dialog_scene.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!--
- ~ Copyright (C) 2024 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<MotionScene xmlns:motion="http://schemas.android.com/apk/res-auto">
-
- <Transition
- motion:autoTransition="none"
- motion:constraintSetEnd="@id/volume_dialog_half_folded_constraint_set"
- motion:constraintSetStart="@id/volume_dialog_constraint_set"
- motion:duration="150" />
-
- <Include motion:constraintSet="@xml/volume_dialog_constraint_set" />
- <Include motion:constraintSet="@xml/volume_dialog_half_folded_constraint_set" />
-</MotionScene> \ No newline at end of file
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 5ef03193820d..0bdf99e49b1b 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
@@ -27,6 +27,8 @@ import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.dynamicanimation.animation.FloatValueHolder
import androidx.dynamicanimation.animation.SpringAnimation
import androidx.dynamicanimation.animation.SpringForce
+import com.android.app.tracing.coroutines.launchInTraced
+import com.android.app.tracing.coroutines.launchTraced
import com.android.internal.R as internalR
import com.android.systemui.res.R
import com.android.systemui.volume.dialog.dagger.scope.VolumeDialogScope
@@ -47,9 +49,7 @@ import kotlin.properties.Delegates
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
-import kotlinx.coroutines.flow.launchIn
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.
@@ -115,7 +115,9 @@ constructor(
drawerContainer.setTransitionListener(ringerDrawerTransitionListener)
volumeDialogBackgroundView.background = volumeDialogBackgroundView.background.mutate()
ringerBackgroundView.background = ringerBackgroundView.background.mutate()
- launch { dialogViewModel.addTouchableBounds(ringerBackgroundView) }
+ launchTraced("VDRVB#addTouchableBounds") {
+ dialogViewModel.addTouchableBounds(ringerBackgroundView)
+ }
viewModel.ringerViewModel
.mapLatest { ringerState ->
@@ -222,7 +224,7 @@ constructor(
}
}
}
- .launchIn(this)
+ .launchInTraced("VDRVB#ringerViewModel", this)
}
private suspend fun MotionLayout.animateAndBindDrawerButtons(
@@ -252,7 +254,7 @@ constructor(
val selectedCornerRadius =
(selectedButton.background as GradientDrawable).cornerRadius
if (selectedCornerRadius.toInt() != selectedButtonUiModel.cornerRadius) {
- launch {
+ launchTraced("VDRVB#selectedButtonAnimation") {
selectedButton.animateTo(
selectedButtonUiModel,
if (uiModel.currentButtonIndex == count - 1) {
@@ -266,7 +268,7 @@ constructor(
val unselectedCornerRadius =
(unselectedButton.background as GradientDrawable).cornerRadius
if (unselectedCornerRadius.toInt() != unselectedButtonUiModel.cornerRadius) {
- launch {
+ launchTraced("VDRVB#unselectedButtonAnimation") {
unselectedButton.animateTo(
unselectedButtonUiModel,
if (previousIndex == count - 1) {
@@ -277,7 +279,7 @@ constructor(
)
}
}
- launch {
+ launchTraced("VDRVB#bindButtons") {
delay(CLOSE_DRAWER_DELAY)
bindButtons(viewModel, uiModel, onAnimationEnd, isAnimated = true)
}
@@ -386,7 +388,7 @@ constructor(
roundnessAnimation.minimumVisibleChange = BUTTON_MIN_VISIBLE_CHANGE
colorAnimation.minimumVisibleChange = BUTTON_MIN_VISIBLE_CHANGE
coroutineScope {
- launch {
+ launchTraced("VDRVB#colorAnimation") {
colorAnimation.suspendAnimate { value ->
val currentIconColor =
rgbEvaluator.evaluate(
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dialog/settings/ui/binder/VolumeDialogSettingsButtonViewBinder.kt b/packages/SystemUI/src/com/android/systemui/volume/dialog/settings/ui/binder/VolumeDialogSettingsButtonViewBinder.kt
index 54f04e274c03..cf9136b4daf4 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dialog/settings/ui/binder/VolumeDialogSettingsButtonViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/dialog/settings/ui/binder/VolumeDialogSettingsButtonViewBinder.kt
@@ -18,6 +18,8 @@ package com.android.systemui.volume.dialog.settings.ui.binder
import android.view.View
import android.widget.ImageButton
+import com.android.app.tracing.coroutines.launchInTraced
+import com.android.app.tracing.coroutines.launchTraced
import com.android.systemui.res.R
import com.android.systemui.volume.dialog.dagger.scope.VolumeDialogScope
import com.android.systemui.volume.dialog.settings.ui.viewmodel.VolumeDialogSettingsButtonViewModel
@@ -25,9 +27,7 @@ import com.android.systemui.volume.dialog.ui.binder.ViewBinder
import com.android.systemui.volume.dialog.ui.viewmodel.VolumeDialogViewModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
-import kotlinx.coroutines.launch
@VolumeDialogScope
class VolumeDialogSettingsButtonViewBinder
@@ -39,12 +39,12 @@ constructor(
override fun CoroutineScope.bind(view: View) {
val button = view.requireViewById<ImageButton>(R.id.volume_dialog_settings)
- launch { dialogViewModel.addTouchableBounds(button) }
+ launchTraced("VDSBVB#addTouchableBounds") { dialogViewModel.addTouchableBounds(button) }
viewModel.isVisible
.onEach { isVisible -> button.visibility = if (isVisible) View.VISIBLE else View.GONE }
- .launchIn(this)
+ .launchInTraced("VDSBVB#isVisible", this)
- viewModel.icon.onEach { button.setImageDrawable(it) }.launchIn(this)
+ viewModel.icon.onEach { button.setImageDrawable(it) }.launchInTraced("VDSBVB#icon", this)
button.setOnClickListener { viewModel.onButtonClicked() }
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogOverscrollViewBinder.kt b/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogOverscrollViewBinder.kt
index 38feb69aad7b..c361b50dd4ee 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogOverscrollViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogOverscrollViewBinder.kt
@@ -20,12 +20,12 @@ import android.view.View
import androidx.dynamicanimation.animation.FloatValueHolder
import androidx.dynamicanimation.animation.SpringAnimation
import androidx.dynamicanimation.animation.SpringForce
+import com.android.app.tracing.coroutines.launchInTraced
import com.android.systemui.volume.dialog.sliders.dagger.VolumeDialogSliderScope
import com.android.systemui.volume.dialog.sliders.ui.viewmodel.VolumeDialogOverscrollViewModel
import com.android.systemui.volume.dialog.sliders.ui.viewmodel.VolumeDialogOverscrollViewModel.OverscrollEventModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@VolumeDialogSliderScope
@@ -62,7 +62,7 @@ constructor(private val viewModel: VolumeDialogOverscrollViewModel) {
}
}
}
- .launchIn(this)
+ .launchInTraced("VDOVB#overscrollEvent", this)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogSliderViewBinder.kt b/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogSliderViewBinder.kt
index 2c9ee54878e5..1c0fabea6d63 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogSliderViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogSliderViewBinder.kt
@@ -39,7 +39,6 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.remember
-import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -99,7 +98,6 @@ private fun VolumeDialogSlider(
hapticsViewModelFactory: SliderHapticsViewModel.Factory?,
modifier: Modifier = Modifier,
) {
- val coroutineScope = rememberCoroutineScope()
val colors =
SliderDefaults.colors(
thumbColor = MaterialTheme.colorScheme.primary,
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogSlidersViewBinder.kt b/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogSlidersViewBinder.kt
index 0d970e5117c2..527f8bdeda91 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogSlidersViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/dialog/sliders/ui/VolumeDialogSlidersViewBinder.kt
@@ -21,6 +21,8 @@ import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.compose.ui.util.fastForEachIndexed
+import com.android.app.tracing.coroutines.launchInTraced
+import com.android.app.tracing.coroutines.launchTraced
import com.android.systemui.res.R
import com.android.systemui.volume.dialog.dagger.scope.VolumeDialogScope
import com.android.systemui.volume.dialog.sliders.dagger.VolumeDialogSliderComponent
@@ -29,9 +31,7 @@ import com.android.systemui.volume.dialog.ui.binder.ViewBinder
import com.android.systemui.volume.dialog.ui.viewmodel.VolumeDialogViewModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
-import kotlinx.coroutines.launch
@VolumeDialogScope
class VolumeDialogSlidersViewBinder
@@ -50,7 +50,9 @@ constructor(
val bottomSection: View = view.requireViewById(R.id.volume_dialog_bottom_section_container)
val topSection: View = view.requireViewById(R.id.volume_dialog_top_section_container)
- launch { dialogViewModel.addTouchableBounds(mainSliderContainer, floatingSlidersContainer) }
+ launchTraced("VDSVB#addTouchableBounds") {
+ dialogViewModel.addTouchableBounds(mainSliderContainer, floatingSlidersContainer)
+ }
viewModel.sliders
.onEach { uiModel ->
bindSlider(
@@ -69,7 +71,7 @@ constructor(
bindSlider(sliderComponent, sliderContainer, arrayOf(sliderContainer))
}
}
- .launchIn(this)
+ .launchInTraced("VDSVB#sliders", this)
}
private fun CoroutineScope.bindSlider(
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/binder/VolumeDialogViewBinder.kt b/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/binder/VolumeDialogViewBinder.kt
index 98042d5022f9..0c10aaa57a05 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/binder/VolumeDialogViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/binder/VolumeDialogViewBinder.kt
@@ -17,18 +17,22 @@
package com.android.systemui.volume.dialog.ui.binder
import android.app.Dialog
+import android.content.Context
import android.view.View
+import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.WindowInsets
import androidx.compose.ui.util.lerp
-import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.view.updatePadding
import androidx.dynamicanimation.animation.DynamicAnimation
import androidx.dynamicanimation.animation.FloatValueHolder
import androidx.dynamicanimation.animation.SpringAnimation
import androidx.dynamicanimation.animation.SpringForce
+import com.android.app.tracing.coroutines.launchInTraced
+import com.android.app.tracing.coroutines.launchTraced
import com.android.internal.view.RotationPolicy
import com.android.systemui.common.ui.view.onApplyWindowInsets
+import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.res.R
import com.android.systemui.util.kotlin.awaitCancellationThenDispose
import com.android.systemui.volume.dialog.dagger.scope.VolumeDialogScope
@@ -43,11 +47,9 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.scan
-import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
private const val SPRING_STIFFNESS = 700f
@@ -63,32 +65,43 @@ private const val ANIMATION_MINIMUM_VISIBLE_CHANGE = 0.01f
class VolumeDialogViewBinder
@Inject
constructor(
+ @Application context: Context,
private val viewModel: VolumeDialogViewModel,
private val jankListenerFactory: JankListenerFactory,
private val tracer: VolumeTracer,
private val viewBinders: List<@JvmSuppressWildcards ViewBinder>,
) {
+ private val halfOpenedOffsetPx: Float =
+ context.resources.getDimensionPixelSize(R.dimen.volume_dialog_half_opened_offset).toFloat()
+
fun CoroutineScope.bind(dialog: Dialog) {
val insets: MutableStateFlow<WindowInsets> =
MutableStateFlow(WindowInsets.Builder().build())
// Root view of the Volume Dialog.
- val root: MotionLayout = dialog.requireViewById(R.id.volume_dialog)
+ val root: ViewGroup = dialog.requireViewById(R.id.volume_dialog)
animateVisibility(root, dialog, viewModel.dialogVisibilityModel)
- viewModel.dialogTitle.onEach { dialog.window?.setTitle(it) }.launchIn(this)
- viewModel.motionState
- .scan(0) { acc, motionState ->
+ viewModel.dialogTitle
+ .onEach { dialog.window?.setTitle(it) }
+ .launchInTraced("VDVB#dialogTitle", this)
+ viewModel.isHalfOpened
+ .scan<Boolean, Boolean?>(null) { acc, isHalfOpened ->
// don't animate the initial state
- root.transitionToState(motionState, animate = acc != 0)
- acc + 1
+ root.applyVerticalOffset(
+ offsetPx = if (isHalfOpened) halfOpenedOffsetPx else 0f,
+ shouldAnimate = acc != null,
+ )
+ isHalfOpened
}
- .launchIn(this)
+ .launchInTraced("VDVB#isHalfOpened", this)
- launch { root.viewTreeObserver.listenToComputeInternalInsets() }
+ launchTraced("VDVB#viewTreeObserver") {
+ root.viewTreeObserver.listenToComputeInternalInsets()
+ }
- launch {
+ launchTraced("VDVB#insets") {
root
.onApplyWindowInsets { v, newInsets ->
val insetsValues = newInsets.getInsets(WindowInsets.Type.displayCutout())
@@ -135,7 +148,7 @@ constructor(
junkListener?.let(animation::removeUpdateListener)
junkListener =
jankListenerFactory.show(view).also(animation::addUpdateListener)
- animation.suspendAnimate(FRACTION_SHOW)
+ animation.animateToFinalPosition(FRACTION_SHOW)
}
is VolumeDialogVisibilityModel.Dismissed -> {
tracer.traceVisibilityEnd(it)
@@ -150,7 +163,7 @@ constructor(
}
}
}
- .launchIn(this)
+ .launchInTraced("VDVB#visibilityModel", this)
}
/**
@@ -180,11 +193,11 @@ constructor(
continuation.invokeOnCancellation { removeOnComputeInternalInsetsListener(listener) }
}
- private fun MotionLayout.transitionToState(newState: Int, animate: Boolean) {
- if (animate) {
- transitionToState(newState)
- } else {
- jumpToState(newState)
+ private suspend fun View.applyVerticalOffset(offsetPx: Float, shouldAnimate: Boolean) {
+ if (!shouldAnimate) {
+ translationY = offsetPx
+ return
}
+ animate().setDuration(150).translationY(offsetPx).suspendAnimate()
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogViewModel.kt b/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogViewModel.kt
index e47b53177189..8bfbc36b1423 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/dialog/ui/viewmodel/VolumeDialogViewModel.kt
@@ -56,18 +56,14 @@ constructor(
configurationController: ConfigurationController,
) {
- val motionState: Flow<Int> =
+ val isHalfOpened: Flow<Boolean> =
combine(
devicePostureController.devicePosture(),
configurationController.onConfigChanged.onStart {
emit(context.resources.configuration)
},
) { devicePosture, configuration ->
- if (shouldOffsetVolumeDialog(devicePosture, configuration)) {
- R.id.volume_dialog_half_folded_constraint_set
- } else {
- R.id.volume_dialog_constraint_set
- }
+ shouldOffsetVolumeDialog(devicePosture, configuration)
}
val dialogVisibilityModel: Flow<VolumeDialogVisibilityModel> =
dialogVisibilityInteractor.dialogVisibility
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/ui/binder/VolumeDialogViewBinderKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/ui/binder/VolumeDialogViewBinderKosmos.kt
index 386e0feb3b3a..54118844effc 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/ui/binder/VolumeDialogViewBinderKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/dialog/ui/binder/VolumeDialogViewBinderKosmos.kt
@@ -16,6 +16,7 @@
package com.android.systemui.volume.dialog.ui.binder
+import android.content.applicationContext
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.volume.dialog.ringer.volumeDialogRingerViewBinder
import com.android.systemui.volume.dialog.settings.ui.binder.volumeDialogSettingsButtonViewBinder
@@ -27,6 +28,7 @@ import com.android.systemui.volume.dialog.utils.volumeTracer
val Kosmos.volumeDialogViewBinder by
Kosmos.Fixture {
VolumeDialogViewBinder(
+ applicationContext,
volumeDialogViewModel,
jankListenerFactory,
volumeTracer,