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

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

Remove the dragged tile when existing the current tiles grid

The removal zone would received the "onEntered" callback when the drag
is started, regardless of position. As a result the tile was removed for
a frame. Moving this to the "onExited" callback from the tiles grid
fixes this

Also cleans up the unsused `EditTileListState#updateLargeWidth` method

Test: manually
Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Fixes: 406684456
Fixes: 406418313
Change-Id: I1bd2e72e9dda9843b9f51468d04694e100e886f9
parent 30f73993
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -92,12 +92,6 @@ fun Modifier.dragAndDropRemoveZone(
                        true
                    } ?: false
                }

                override fun onEntered(event: DragAndDropEvent) {
                    if (!dragAndDropState.isDraggedCellRemovable) return

                    dragAndDropState.movedOutOfBounds()
                }
            }
        }
    return dragAndDropTarget(
@@ -131,6 +125,11 @@ fun Modifier.dragAndDropTileList(
                    dragAndDropState.onDrop()
                }

                override fun onExited(event: DragAndDropEvent) {
                    if (!dragAndDropState.isDraggedCellRemovable) return
                    dragAndDropState.movedOutOfBounds()
                }

                override fun onMoved(event: DragAndDropEvent) {
                    val offset = event.toOffset()
                    dragAndDropState.onMoved(offset)
+0 −11
Original line number Diff line number Diff line
@@ -186,17 +186,6 @@ class EditTileListState(
        }
    }

    private fun List<TileGridCell>.updateLargeWidth(
        previousWidth: Int,
        newWidth: Int,
    ): List<TileGridCell> {
        return if (previousWidth != newWidth) {
            map { if (!it.isIcon) it.copy(width = newWidth) else it }
        } else {
            this
        }
    }

    private fun List<EditTileViewModel>.toGridCells(largeTiles: Set<TileSpec>): List<GridCell> {
        return map {
                SizedTileImpl(it, if (largeTiles.contains(it.tileSpec)) largeTilesSpan else 1)