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

Commit cfe3d7fa authored by Olivier St-Onge's avatar Olivier St-Onge
Browse files

Move the system gesture exclusion after the badge layout

This reduces the accidental back gesture when trying to resize a tile

Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Fixes: 419287766
Test: manually - resizing tiles on the edge
Change-Id: I2283345d5c8312d76b8c4faf62ebb65e7f0ca4aa
parent 21c5f04f
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -121,6 +121,8 @@ fun InteractiveTileContainer(
    val badgeIconAlpha by transition.animateFloat { state -> if (state == Removable) 1f else 0f }
    val selectionBorderAlpha by
        transition.animateFloat { state -> if (state == Selected) 1f else 0f }
    val isIdle = transition.currentState == transition.targetState
    val isDraggable = tileState == Selected

    Box(
        modifier.resizable(tileState == Selected, resizingState).selectionBorder(
@@ -135,6 +137,7 @@ fun InteractiveTileContainer(
        MinimumInteractiveSizeComponent(
            angle = { decorationAngle },
            offset = { decorationOffset },
            excludeSystemGesture = isIdle && isDraggable,
        ) {
            Box(
                Modifier.fillMaxSize()
@@ -148,7 +151,7 @@ fun InteractiveTileContainer(
                    }
                    .graphicsLayer { this.alpha = decorationAlpha }
                    .anchoredDraggable(
                        enabled = tileState == Selected,
                        enabled = isDraggable,
                        state = resizingState.anchoredDraggableState,
                        orientation = Orientation.Horizontal,
                    )
@@ -236,6 +239,7 @@ private fun MinimumInteractiveSizeComponent(
    angle: () -> Float,
    offset: () -> Offset,
    modifier: Modifier = Modifier,
    excludeSystemGesture: Boolean = false,
    content: @Composable BoxScope.() -> Unit = {},
) {
    // Use a higher zIndex than the tile to draw over it, and manually create the touch target
@@ -246,7 +250,6 @@ private fun MinimumInteractiveSizeComponent(
        modifier =
            modifier
                .zIndex(2f)
                .systemGestureExclusion { Rect(Offset.Zero, it.size.toSize()) }
                .layout { measurable, constraints ->
                    val size = minTouchTargetSize.roundToPx()
                    val placeable = measurable.measure(Constraints.fixed(size, size))
@@ -259,6 +262,9 @@ private fun MinimumInteractiveSizeComponent(
                            position.y.roundToInt() - placeable.height / 2,
                        )
                    }
                }
                .thenIf(excludeSystemGesture) {
                    Modifier.systemGestureExclusion { Rect(Offset.Zero, it.size.toSize()) }
                },
        content = content,
    )