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

Commit fb317fbe authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Animate the transition between the tile's badge and the resizing dot" into main

parents e5604e51 fc9350da
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -31,21 +31,18 @@ class MutableSelectionStateTest : SysuiTestCase() {

    @Test
    fun selectTile_isCorrectlySelected() {
        assertThat(underTest.selection?.tileSpec).isNotEqualTo(TEST_SPEC)
        assertThat(underTest.selection).isNotEqualTo(TEST_SPEC)

        underTest.select(TEST_SPEC, manual = true)
        assertThat(underTest.selection?.tileSpec).isEqualTo(TEST_SPEC)
        assertThat(underTest.selection?.manual).isTrue()
        underTest.select(TEST_SPEC)
        assertThat(underTest.selection).isEqualTo(TEST_SPEC)

        underTest.unSelect()
        assertThat(underTest.selection).isNull()

        val newSpec = TileSpec.create("newSpec")
        underTest.select(TEST_SPEC, manual = true)
        underTest.select(newSpec, manual = false)
        assertThat(underTest.selection?.tileSpec).isNotEqualTo(TEST_SPEC)
        assertThat(underTest.selection?.tileSpec).isEqualTo(newSpec)
        assertThat(underTest.selection?.manual).isFalse()
        underTest.select(TEST_SPEC)
        underTest.select(newSpec)
        assertThat(underTest.selection).isEqualTo(newSpec)
    }

    companion object {
+3 −0
Original line number Diff line number Diff line
@@ -2560,6 +2560,9 @@
    <!-- SysUI Tuner: Other section -->
    <string name="other">Other</string>

    <!-- Accessibility description of action to toggle QS tile size on click. It will read as "Double-tap to toggle the tile's size" in screen readers [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_toggle_tile_size_action">toggle the tile\'s size</string>

    <!-- Accessibility description of action to remove QS tile on click. It will read as "Double-tap to remove tile" in screen readers [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_remove_tile_action">remove tile</string>

+0 −14
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package com.android.systemui.qs.panels.ui.compose
import androidx.compose.runtime.Stable
import com.android.compose.animation.Bounceable
import com.android.systemui.qs.panels.shared.model.SizedTile
import com.android.systemui.qs.panels.ui.model.GridCell
import com.android.systemui.qs.panels.ui.model.TileGridCell
import com.android.systemui.qs.panels.ui.viewmodel.BounceableTileViewModel
import com.android.systemui.qs.panels.ui.viewmodel.TileViewModel

@@ -32,18 +30,6 @@ data class BounceableInfo(
    val bounceEnd: Boolean,
)

fun List<Pair<GridCell, BounceableTileViewModel>>.bounceableInfo(
    index: Int,
    columns: Int,
): BounceableInfo {
    val cell = this[index].first as TileGridCell
    // Only look for neighbor bounceables if they are on the same row
    val onLastColumn = cell.onLastColumn(cell.column, columns)
    val previousTile = getOrNull(index - 1)?.takeIf { cell.column != 0 }
    val nextTile = getOrNull(index + 1)?.takeIf { !onLastColumn }
    return BounceableInfo(this[index].second, previousTile?.second, nextTile?.second, !onLastColumn)
}

fun List<BounceableTileViewModel>.bounceableInfo(
    sizedTile: SizedTile<TileViewModel>,
    index: Int,
+78 −148

File changed.

Preview size limit exceeded, changes collapsed.

+6 −12
Original line number Diff line number Diff line
@@ -32,23 +32,17 @@ fun rememberSelectionState(): MutableSelectionState {
    return remember { MutableSelectionState() }
}

/**
 * Holds the selected [TileSpec] and whether the selection was manual, i.e. caused by a tap from the
 * user.
 */
data class Selection(val tileSpec: TileSpec, val manual: Boolean)

/** Holds the state of the current selection. */
class MutableSelectionState {
    /** The [Selection] if a tile is selected, null if not. */
    var selection by mutableStateOf<Selection?>(null)
    /** The [TileSpec] of a tile is selected, null if not. */
    var selection by mutableStateOf<TileSpec?>(null)
        private set

    val selected: Boolean
        get() = selection != null

    fun select(tileSpec: TileSpec, manual: Boolean) {
        selection = Selection(tileSpec, manual)
    fun select(tileSpec: TileSpec) {
        selection = tileSpec
    }

    fun unSelect() {
@@ -68,10 +62,10 @@ fun Modifier.selectableTile(
    return pointerInput(Unit) {
        detectTapGestures(
            onTap = {
                if (selectionState.selection?.tileSpec == tileSpec) {
                if (selectionState.selection == tileSpec) {
                    selectionState.unSelect()
                } else {
                    selectionState.select(tileSpec, manual = true)
                    selectionState.select(tileSpec)
                }
                onClick()
            }
Loading