Return list of one default option when shape not enabled (2/2)
This is to return a list of one default option (circle) if the shape
cutstomization flag is not turned on.
It resolves the issue that the selected shape option never emits.
Test: Manually tested
Fixes: 388299893
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: I400717a300eca49d8e03904d83c51311493e3eea
diff --git a/src/com/android/wallpaper/customization/ui/viewmodel/ShapeGridPickerViewModel.kt b/src/com/android/wallpaper/customization/ui/viewmodel/ShapeGridPickerViewModel.kt
index 85422dd..60b5c35 100644
--- a/src/com/android/wallpaper/customization/ui/viewmodel/ShapeGridPickerViewModel.kt
+++ b/src/com/android/wallpaper/customization/ui/viewmodel/ShapeGridPickerViewModel.kt
@@ -133,18 +133,23 @@
.shareIn(scope = viewModelScope, started = SharingStarted.Lazily, replay = 1)
val onApply: Flow<(suspend () -> Unit)?> =
- combine(previewingGridKey, selectedGridOption, previewingShapeKey, selectedShapeKey) {
- previewingGridOptionKey,
+ combine(overridingGridKey, selectedGridOption, overridingShapeKey, selectedShapeKey) {
+ overridingGridKey,
selectedGridOption,
- previewingShapeKey,
+ overridingShapeKey,
selectedShapeKey ->
if (
- previewingGridOptionKey == selectedGridOption.key.value &&
- previewingShapeKey == selectedShapeKey
+ (overridingGridKey != null && overridingGridKey != selectedGridOption.key.value) ||
+ (overridingShapeKey != null && overridingShapeKey != selectedShapeKey)
) {
- null
+ {
+ interactor.applySelectedOption(
+ overridingShapeKey ?: selectedShapeKey,
+ overridingGridKey ?: selectedGridOption.key.value,
+ )
+ }
} else {
- { interactor.applySelectedOption(previewingShapeKey, previewingGridOptionKey) }
+ null
}
}