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

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

Use the updated drag state in tiles that are not recomposed.

This fixes a bug where tiles that weren't recomposed due to being unchanged ended up using an outdated drag state.

Bug: 346991759
Flag: com.android.systemui.qs_ui_refactor
Test: manually with QSActivity
Change-Id: Ic3baafc99a5cb0a7c11931fcc668fcdcf368c817
parent 29700c4a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -158,18 +158,20 @@ private fun insertAfter(item: LazyGridItemInfo, offset: Offset): Boolean {
    return item.span != 1 && offset.x > itemCenter.x
}

@Composable
fun Modifier.dragAndDropTileSource(
    sizedTile: SizedTile<EditTileViewModel>,
    onTap: (TileSpec) -> Unit,
    onDoubleTap: (TileSpec) -> Unit,
    dragAndDropState: DragAndDropState
): Modifier {
    val state by rememberUpdatedState(dragAndDropState)
    return dragAndDropSource {
        detectTapGestures(
            onTap = { onTap(sizedTile.tile.tileSpec) },
            onDoubleTap = { onDoubleTap(sizedTile.tile.tileSpec) },
            onLongPress = {
                dragAndDropState.onStarted(sizedTile)
                state.onStarted(sizedTile)

                // The tilespec from the ClipData transferred isn't actually needed as we're moving
                // a tile within the same application. We're using a custom MIME type to limit the