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

Commit 575a5871 authored by Will Leshner's avatar Will Leshner
Browse files

Fix a crash that occurs when drag-reordering widgets.

The crash occurs because GridDragDropState adds a Responsive
CommunalContentSize to the end of the list of items to support dragging
to the end, but later code attempts to cast it to a FixedSize
CommunalContentSize. The fix conditionally creates the correct class
based on whether the communal_responsive_grid flag is enabled or not.

Fixes: 417999806
Test: manually by dragging with all combinations of
communal_responsive_grid and glanceable_hub_v2 either enabled or
disabled.
Flag: EXEMPT bugfix

Change-Id: I515e61055c43fd262672bddd67a949e53d5101f7
parent 7529413b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -208,7 +208,8 @@ private class GridDragDropStateV1(
) : GridDragDropStateInternal(gridState) {
    private val scrollChannel = Channel<Float>()

    private val spacer = CommunalContentModel.Spacer(CommunalContentSize.Responsive(1))
    private val spacer =
        CommunalContentModel.Spacer(CommunalContentSize.fixedThirdOrResponsiveSize())

    private var previousTargetItemKey: Any? = null

@@ -394,7 +395,8 @@ private class GridDragDropStateV2(
    // and no longer in the list of visible items).
    private var draggingItemWhileScrolling: LazyGridItemInfo? by mutableStateOf(null)

    private val spacer = CommunalContentModel.Spacer(CommunalContentSize.Responsive(1))
    private val spacer =
        CommunalContentModel.Spacer(CommunalContentSize.fixedThirdOrResponsiveSize())

    private var previousTargetItemKey: Any? = null

+2 −0
Original line number Diff line number Diff line
@@ -50,5 +50,7 @@ sealed interface CommunalContentSize {
                    ?: throw IllegalArgumentException("$span is not a valid span size")
            }
        }

        fun fixedThirdOrResponsiveSize() = toSize(FixedSize.THIRD.span)
    }
}