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

Commit b7efb555 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Always draw new Expandables in a graphics layer

This CL makes all Expandables draw their content in a graphics layer,
ensuring that we don't make assumptions about drawing order between the
Expandable window and the dialog window. See b/397904604#comment6 for
details.

Bug: 397904604
Test: Manual
Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Change-Id: Ia753d96a264dde46caec9e389c223889b8c020e5
parent a7ba59c9
Loading
Loading
Loading
Loading
+12 −18
Original line number Diff line number Diff line
@@ -308,34 +308,28 @@ private fun Modifier.expandable(
    interactionSource: MutableInteractionSource? = null,
): Modifier {
    val controller = controller as ExpandableControllerImpl
    val graphicsLayer = rememberGraphicsLayer()

    val isAnimating = controller.isAnimating
    val drawInOverlayModifier =
    if (isAnimating) {
            val graphicsLayer = rememberGraphicsLayer()

        FullScreenComposeViewInOverlay(controller.overlay) { view ->
            Modifier.then(DrawExpandableInOverlayElement(view, controller, graphicsLayer))
        }

            Modifier.drawWithContent { graphicsLayer.record { this@drawWithContent.drawContent() } }
        } else {
            null
    }

    val drawContent = !isAnimating && !controller.isDialogShowing
    return this.thenIf(onClick != null) { Modifier.minimumInteractiveComponentSize() }
        .thenIf(!isAnimating) {
        .thenIf(drawContent) {
            Modifier.border(controller)
                .then(clickModifier(controller, onClick, interactionSource))
                .background(controller.color, controller.shape)
        }
        .thenIf(drawInOverlayModifier != null) { drawInOverlayModifier!! }
        .onPlaced { controller.boundsInComposeViewRoot = it.boundsInRoot() }
        .thenIf(!isAnimating && controller.isDialogShowing) {
            Modifier.layout { measurable, constraints ->
                measurable.measure(constraints).run {
                    layout(width, height) { /* Do not place/draw. */ }
                }
        .drawWithContent {
            graphicsLayer.record { this@drawWithContent.drawContent() }

            if (drawContent) {
                drawLayer(graphicsLayer)
            }
        }
}