Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a750a32 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Set volume dialog background corners to full." into main

parents 4914fd75 50e0d5dc
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:shape="rectangle">
    <corners android:bottomLeftRadius="@dimen/volume_dialog_background_corner_radius"
        android:bottomRightRadius="@dimen/volume_dialog_background_corner_radius"/>
    <corners android:radius="@dimen/volume_dialog_background_corner_radius"/>
    <solid android:color="@androidprv:color/materialColorSurface" />
</shape>
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
        android:id="@+id/ringer_buttons_background"
        android:layout_width="@dimen/volume_dialog_width"
        android:layout_height="0dp"
        android:visibility="gone"
        android:layout_marginTop="@dimen/volume_dialog_background_vertical_margin"
        android:layout_marginBottom="@dimen/volume_dialog_background_vertical_margin"
        android:background="@drawable/volume_dialog_ringer_background" />
+27 −6
Original line number Diff line number Diff line
@@ -83,6 +83,18 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
            view.context.resources.getDimensionPixelSize(
                R.dimen.volume_dialog_background_corner_radius
            )
        val bottomDefaultRadius = volumeDialogBgFullRadius.toFloat()
        val bottomCornerRadii =
            floatArrayOf(
                0F,
                0F,
                0F,
                0F,
                bottomDefaultRadius,
                bottomDefaultRadius,
                bottomDefaultRadius,
                bottomDefaultRadius,
            )
        var backgroundAnimationProgress: Float by
            Delegates.observable(0F) { _, _, progress ->
                ringerBackgroundView.applyCorners(
@@ -115,6 +127,8 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
                        drawerContainer.visibility = View.VISIBLE
                        when (uiModel.drawerState) {
                            is RingerDrawerState.Initial -> {
                                (volumeDialogBackgroundView.background as GradientDrawable)
                                    .cornerRadii = bottomCornerRadii
                                drawerContainer.animateAndBindDrawerButtons(
                                    viewModel,
                                    uiModel,
@@ -123,6 +137,7 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
                                )
                                ringerDrawerTransitionListener.setProgressChangeEnabled(true)
                                drawerContainer.closeDrawer(
                                    ringerBackgroundView,
                                    uiModel.currentButtonIndex,
                                    ringerState.orientation,
                                )
@@ -165,6 +180,7 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
                                            )
                                        }
                                        drawerContainer.closeDrawer(
                                            ringerBackgroundView,
                                            uiModel.currentButtonIndex,
                                            ringerState.orientation,
                                        )
@@ -187,7 +203,11 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
                                } else {
                                    ringerDrawerTransitionListener.setProgressChangeEnabled(true)
                                }
                                updateOpenState(drawerContainer, ringerState.orientation)
                                updateOpenState(
                                    drawerContainer,
                                    ringerState.orientation,
                                    ringerBackgroundView,
                                )
                                drawerContainer.transitionToState(
                                    R.id.volume_dialog_ringer_drawer_open
                                )
@@ -204,9 +224,6 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
                        volumeDialogBackgroundView.setBackgroundResource(
                            R.drawable.volume_dialog_background
                        )
                        ringerBackgroundView.setBackgroundResource(
                            R.drawable.volume_dialog_ringer_background
                        )
                    }
                }
            }
@@ -351,9 +368,13 @@ constructor(private val viewModel: VolumeDialogRingerDrawerViewModel) {
        }
    }

    private fun MotionLayout.closeDrawer(selectedIndex: Int, orientation: Int) {
    private fun MotionLayout.closeDrawer(
        ringerBackground: View,
        selectedIndex: Int,
        orientation: Int,
    ) {
        setTransition(R.id.close_to_open_transition)
        updateCloseState(this, selectedIndex, orientation)
        updateCloseState(this, selectedIndex, orientation, ringerBackground)
        transitionToState(R.id.volume_dialog_ringer_drawer_close)
    }

+9 −2
Original line number Diff line number Diff line
@@ -25,14 +25,21 @@ import androidx.constraintlayout.widget.ConstraintSet
import com.android.systemui.res.R
import com.android.systemui.util.children

fun updateOpenState(ringerDrawer: MotionLayout, orientation: Int) {
fun updateOpenState(ringerDrawer: MotionLayout, orientation: Int, ringerBackground: View) {
    val openSet = ringerDrawer.cloneConstraintSet(R.id.volume_dialog_ringer_drawer_open)
    openSet.setVisibility(ringerBackground.id, View.VISIBLE)
    openSet.adjustOpenConstraintsForDrawer(ringerDrawer, orientation)
    ringerDrawer.updateState(R.id.volume_dialog_ringer_drawer_open, openSet)
}

fun updateCloseState(ringerDrawer: MotionLayout, selectedIndex: Int, orientation: Int) {
fun updateCloseState(
    ringerDrawer: MotionLayout,
    selectedIndex: Int,
    orientation: Int,
    ringerBackground: View,
) {
    val closeSet = ringerDrawer.cloneConstraintSet(R.id.volume_dialog_ringer_drawer_close)
    closeSet.setVisibility(ringerBackground.id, View.VISIBLE)
    closeSet.adjustClosedConstraintsForDrawer(ringerDrawer, selectedIndex, orientation)
    ringerDrawer.updateState(R.id.volume_dialog_ringer_drawer_close, closeSet)
}