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

Commit 8ad770b7 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Introduce StaticElementContentPicker (1/2)

This CL is a partial revert of ag/27025577, which allowed
ElementContentPicker.contentDuringTransition() to return null to
indicate that the element is neither transition.fromContent nor
transition.toContent. This was needed for movable elements, which needed
to know *at composition time* in which scenes/contents an element could
be.

Once overlays will be introduced, we will still need to be able to do
this check but we won't always have a transition when an overlay is
shown but not animating. This CL introduces StaticElementScenePicker,
which can provide the list of contents in which an element can be. This
StaticElementScenePicker must now be used for MovableElements.

This CL also converts some MovableElement from keyguard sections into
normal Elements. I expect those elements to not be used or not work
correctly anyways because these elements are using the default
HighestZIndexContentPicker, which does not work well with movable
elements that don't specify the scenes/contents in which they can be.

Bug: 353679003
Test: atest PlatformComposeSceneTransitionLayoutTests
Test: atest MovableElementTest
Test: atest MovableElementContentPickerTest
Flag: com.android.systemui.scene_container
Change-Id: I39a0427de2eaccd133bbf206ed435a801e07e539
parent 2a3134e6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ constructor(
        applyPadding: Boolean,
        modifier: Modifier = Modifier,
    ) {
        MovableElement(
        Element(
            key = if (isStart) StartButtonElementKey else EndButtonElementKey,
            modifier = modifier,
        ) {
@@ -98,7 +98,7 @@ constructor(
    fun SceneScope.IndicationArea(
        modifier: Modifier = Modifier,
    ) {
        MovableElement(
        Element(
            key = IndicationAreaElementKey,
            modifier = modifier.indicationAreaPadding(),
        ) {
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ constructor(
            )
        }

        MovableElement(key = largeClockElementKey, modifier = modifier) {
        Element(key = largeClockElementKey, modifier = modifier) {
            content {
                AndroidView(
                    factory = { context ->
+58 −52
Original line number Diff line number Diff line
@@ -65,13 +65,16 @@ constructor(
    ) {
        val resources = LocalContext.current.resources

        MovableElement(key = ClockElementKeys.smartspaceElementKey, modifier = modifier) {
        Element(key = ClockElementKeys.smartspaceElementKey, modifier = modifier) {
            content {
                Column(
                    modifier =
                        modifier
                            .onTopPlacementChanged(onTopChanged)
                            .padding(
                            top = { lockscreenContentViewModel.getSmartSpacePaddingTop(resources) },
                                top = {
                                    lockscreenContentViewModel.getSmartSpacePaddingTop(resources)
                                },
                                bottom = {
                                    resources.getDimensionPixelSize(
                                        R.dimen.keyguard_status_view_bottom_margin
@@ -83,7 +86,8 @@ constructor(
                        return@Column
                    }

                val paddingBelowClockStart = dimensionResource(R.dimen.below_clock_padding_start)
                    val paddingBelowClockStart =
                        dimensionResource(R.dimen.below_clock_padding_start)
                    val paddingBelowClockEnd = dimensionResource(R.dimen.below_clock_padding_end)

                    if (keyguardSmartspaceViewModel.isDateWeatherDecoupled) {
@@ -91,7 +95,8 @@ constructor(
                            verticalAlignment = Alignment.CenterVertically,
                            modifier =
                                Modifier.fillMaxWidth()
                                // All items will be constrained to be as tall as the shortest item.
                                    // All items will be constrained to be as tall as the shortest
                                    // item.
                                    .height(IntrinsicSize.Min)
                                    .padding(
                                        start = paddingBelowClockStart,
@@ -130,6 +135,7 @@ constructor(
                }
            }
        }
    }

    @Composable
    private fun Card(
+1 −1
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ constructor(
        elementKey: ElementKey,
        modifier: Modifier = Modifier,
    ) {
        MovableElement(key = elementKey, modifier) {
        Element(key = elementKey, modifier) {
            content {
                AndroidView(
                    factory = {
+5 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import androidx.compose.ui.layout.layout
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.viewinterop.AndroidView
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.MovableElementKey
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.media.controls.ui.controller.MediaCarouselController
import com.android.systemui.media.controls.ui.view.MediaHost
@@ -38,7 +38,10 @@ import com.android.systemui.util.animation.MeasurementInput
object MediaCarousel {
    object Elements {
        internal val Content =
            ElementKey(debugName = "MediaCarouselContent", contentPicker = MediaContentPicker)
            MovableElementKey(
                debugName = "MediaCarouselContent",
                contentPicker = MediaContentPicker,
            )
    }
}

Loading