summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/grid/ui/compose/SpannedGrids.kt28
-rw-r--r--packages/SystemUI/src/com/android/systemui/haptics/msdl/qs/TileHapticsViewModel.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/BounceableInfo.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/QuickQuickSettings.kt32
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/InfiniteGridLayout.kt29
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/TileSpec.kt3
6 files changed, 56 insertions, 42 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/grid/ui/compose/SpannedGrids.kt b/packages/SystemUI/src/com/android/systemui/grid/ui/compose/SpannedGrids.kt
index 62ab18bbb738..96ef03c996a9 100644
--- a/packages/SystemUI/src/com/android/systemui/grid/ui/compose/SpannedGrids.kt
+++ b/packages/SystemUI/src/com/android/systemui/grid/ui/compose/SpannedGrids.kt
@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
@@ -63,6 +64,7 @@ fun HorizontalSpannedGrid(
rowSpacing: Dp,
spans: List<Int>,
modifier: Modifier = Modifier,
+ keys: (spanIndex: Int) -> Any = { it },
composables: @Composable BoxScope.(spanIndex: Int) -> Unit,
) {
SpannedGrid(
@@ -72,6 +74,7 @@ fun HorizontalSpannedGrid(
spans = spans,
isVertical = false,
modifier = modifier,
+ keys = keys,
composables = composables,
)
}
@@ -103,6 +106,7 @@ fun VerticalSpannedGrid(
rowSpacing: Dp,
spans: List<Int>,
modifier: Modifier = Modifier,
+ keys: (spanIndex: Int) -> Any = { it },
composables: @Composable BoxScope.(spanIndex: Int) -> Unit,
) {
SpannedGrid(
@@ -112,6 +116,7 @@ fun VerticalSpannedGrid(
spans = spans,
isVertical = true,
modifier = modifier,
+ keys = keys,
composables = composables,
)
}
@@ -124,6 +129,7 @@ private fun SpannedGrid(
spans: List<Int>,
isVertical: Boolean,
modifier: Modifier = Modifier,
+ keys: (spanIndex: Int) -> Any = { it },
composables: @Composable BoxScope.(spanIndex: Int) -> Unit,
) {
val crossAxisArrangement = Arrangement.spacedBy(crossAxisSpacing)
@@ -167,17 +173,19 @@ private fun SpannedGrid(
Layout(
{
(0 until spans.size).map { spanIndex ->
- Box(
- Modifier.semantics {
- collectionItemInfo =
- if (isVertical) {
- CollectionItemInfo(spanIndex, 1, 0, 1)
- } else {
- CollectionItemInfo(0, 1, spanIndex, 1)
- }
+ key(keys(spanIndex)) {
+ Box(
+ Modifier.semantics {
+ collectionItemInfo =
+ if (isVertical) {
+ CollectionItemInfo(spanIndex, 1, 0, 1)
+ } else {
+ CollectionItemInfo(0, 1, spanIndex, 1)
+ }
+ }
+ ) {
+ composables(spanIndex)
}
- ) {
- composables(spanIndex)
}
}
},
diff --git a/packages/SystemUI/src/com/android/systemui/haptics/msdl/qs/TileHapticsViewModel.kt b/packages/SystemUI/src/com/android/systemui/haptics/msdl/qs/TileHapticsViewModel.kt
index 84c4bdf1621a..49625f8f9360 100644
--- a/packages/SystemUI/src/com/android/systemui/haptics/msdl/qs/TileHapticsViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/haptics/msdl/qs/TileHapticsViewModel.kt
@@ -17,6 +17,7 @@
package com.android.systemui.haptics.msdl.qs
import android.service.quicksettings.Tile
+import androidx.compose.runtime.Stable
import com.android.systemui.Flags
import com.android.systemui.animation.Expandable
import com.android.systemui.dagger.SysUISingleton
@@ -175,6 +176,7 @@ constructor(
}
@SysUISingleton
+@Stable
class TileHapticsViewModelFactoryProvider
@Inject
constructor(private val tileHapticsViewModelFactory: TileHapticsViewModel.Factory) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/BounceableInfo.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/BounceableInfo.kt
index c9d767e6d152..302242ca11dd 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/BounceableInfo.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/BounceableInfo.kt
@@ -16,7 +16,7 @@
package com.android.systemui.qs.panels.ui.compose
-import android.processor.immutability.Immutable
+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
@@ -24,7 +24,7 @@ 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
-@Immutable
+@Stable
data class BounceableInfo(
val bounceable: BounceableTileViewModel,
val previousTile: Bounceable?,
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/QuickQuickSettings.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/QuickQuickSettings.kt
index 5cb30b999e13..b084f79a5bba 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/QuickQuickSettings.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/QuickQuickSettings.kt
@@ -19,8 +19,8 @@ package com.android.systemui.qs.panels.ui.compose
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
+import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
-import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
@@ -49,6 +49,8 @@ fun ContentScope.QuickQuickSettings(
val squishiness by viewModel.squishinessViewModel.squishiness.collectAsStateWithLifecycle()
val scope = rememberCoroutineScope()
+ val spans by remember(sizedTiles) { derivedStateOf { sizedTiles.fastMap { it.width } } }
+
DisposableEffect(tiles) {
val token = Any()
tiles.forEach { it.startListening(token) }
@@ -62,26 +64,24 @@ fun ContentScope.QuickQuickSettings(
columns = columns,
columnSpacing = dimensionResource(R.dimen.qs_tile_margin_horizontal),
rowSpacing = dimensionResource(R.dimen.qs_tile_margin_vertical),
- spans = sizedTiles.fastMap { it.width },
+ spans = spans,
modifier = Modifier.sysuiResTag("qqs_tile_layout"),
+ keys = { sizedTiles[it].tile.spec },
) { spanIndex ->
val it = sizedTiles[spanIndex]
val column = cellIndex % columns
cellIndex += it.width
- key(it.tile.spec) {
- Tile(
- tile = it.tile,
- iconOnly = it.isIcon,
- modifier = Modifier.element(it.tile.spec.toElementKey(spanIndex)),
- squishiness = { squishiness },
- coroutineScope = scope,
- bounceableInfo = bounceables.bounceableInfo(it, spanIndex, column, columns),
- tileHapticsViewModelFactoryProvider =
- viewModel.tileHapticsViewModelFactoryProvider,
- // There should be no QuickQuickSettings when the details view is enabled.
- detailsViewModel = null,
- )
- }
+ Tile(
+ tile = it.tile,
+ iconOnly = it.isIcon,
+ modifier = Modifier.element(it.tile.spec.toElementKey(spanIndex)),
+ squishiness = { squishiness },
+ coroutineScope = scope,
+ bounceableInfo = bounceables.bounceableInfo(it, spanIndex, column, columns),
+ tileHapticsViewModelFactoryProvider = viewModel.tileHapticsViewModelFactoryProvider,
+ // There should be no QuickQuickSettings when the details view is enabled.
+ detailsViewModel = null,
+ )
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/InfiniteGridLayout.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/InfiniteGridLayout.kt
index 4432d336237f..cc4c3af1dc63 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/InfiniteGridLayout.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/InfiniteGridLayout.kt
@@ -18,8 +18,8 @@ package com.android.systemui.qs.panels.ui.compose.infinitegrid
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
+import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
-import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
@@ -86,27 +86,28 @@ constructor(
val scope = rememberCoroutineScope()
var cellIndex = 0
+ val spans by remember(sizedTiles) { derivedStateOf { sizedTiles.fastMap { it.width } } }
+
VerticalSpannedGrid(
columns = columns,
columnSpacing = dimensionResource(R.dimen.qs_tile_margin_horizontal),
rowSpacing = dimensionResource(R.dimen.qs_tile_margin_vertical),
- spans = sizedTiles.fastMap { it.width },
+ spans = spans,
+ keys = { sizedTiles[it].tile.spec },
) { spanIndex ->
val it = sizedTiles[spanIndex]
val column = cellIndex % columns
cellIndex += it.width
- key(it.tile.spec) {
- Tile(
- tile = it.tile,
- iconOnly = iconTilesViewModel.isIconTile(it.tile.spec),
- modifier = Modifier.element(it.tile.spec.toElementKey(spanIndex)),
- squishiness = { squishiness },
- tileHapticsViewModelFactoryProvider = tileHapticsViewModelFactoryProvider,
- coroutineScope = scope,
- bounceableInfo = bounceables.bounceableInfo(it, spanIndex, column, columns),
- detailsViewModel = detailsViewModel,
- )
- }
+ Tile(
+ tile = it.tile,
+ iconOnly = iconTilesViewModel.isIconTile(it.tile.spec),
+ modifier = Modifier.element(it.tile.spec.toElementKey(spanIndex)),
+ squishiness = { squishiness },
+ tileHapticsViewModelFactoryProvider = tileHapticsViewModelFactoryProvider,
+ coroutineScope = scope,
+ bounceableInfo = bounceables.bounceableInfo(it, spanIndex, column, columns),
+ detailsViewModel = detailsViewModel,
+ )
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/TileSpec.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/TileSpec.kt
index 16c27223a471..8a627c452081 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/TileSpec.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/TileSpec.kt
@@ -18,6 +18,7 @@ package com.android.systemui.qs.pipeline.shared
import android.content.ComponentName
import android.text.TextUtils
+import androidx.compose.runtime.Stable
import com.android.systemui.qs.external.CustomTile
/**
@@ -34,6 +35,7 @@ sealed class TileSpec private constructor(open val spec: String) {
data object Invalid : TileSpec("")
/** Container for the spec of a tile provided by SystemUI. */
+ @Stable
data class PlatformTileSpec internal constructor(override val spec: String) : TileSpec(spec) {
override fun toString(): String {
return "P($spec)"
@@ -45,6 +47,7 @@ sealed class TileSpec private constructor(open val spec: String) {
*
* [componentName] indicates the associated `TileService`.
*/
+ @Stable
data class CustomTileSpec
internal constructor(override val spec: String, val componentName: ComponentName) :
TileSpec(spec) {