Loading src/com/android/customization/model/grid/DefaultShapeGridManager.kt +2 −2 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ constructor( override fun applyGridOption(gridKey: String) { context.contentResolver.update( previewUtils.getUri(SHAPE_GRID), previewUtils.getUri(SET_GRID), ContentValues().apply { put(COL_GRID_KEY, gridKey) }, null, null, Loading Loading @@ -189,7 +189,7 @@ constructor( const val TAG = "DefaultShapeGridManager" const val SHAPE_OPTIONS: String = "shape_options" const val GRID_OPTIONS: String = "list_options" const val SHAPE_GRID: String = "default_grid" const val SET_GRID: String = "default_grid" const val SET_SHAPE: String = "shape" const val COL_SHAPE_KEY: String = "shape_key" const val COL_GRID_KEY: String = "name" Loading src/com/android/customization/picker/grid/data/repository/GridRepository2.kt +1 −1 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ constructor( val isGridCustomizationAvailable = gridOptions.filterNotNull().map { it.size > 1 }.distinctUntilChanged() suspend fun applySelectedOption(gridKey: String) = suspend fun applyGridOption(gridKey: String) = withContext(bgDispatcher) { manager.applyGridOption(gridKey) // After applying, we should query and update shape and grid options again. Loading src/com/android/customization/picker/grid/domain/interactor/GridInteractor2.kt +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ class GridInteractor2 @Inject constructor(private val repository: GridRepository val selectedGridOption = repository.selectedGridOption suspend fun applySelectedOption(gridKey: String) = repository.applySelectedOption(gridKey) suspend fun applyGridOption(gridKey: String) = repository.applyGridOption(gridKey) fun getGridOptionDrawable(iconId: Int): Drawable? = repository.getGridOptionDrawable(iconId) } src/com/android/wallpaper/customization/ui/viewmodel/GridPickerViewModel.kt +5 −8 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ constructor( -> overridingGridOptionKey ?: selectedGridOption.key.value } .shareIn(scope = viewModelScope, started = SharingStarted.Lazily, replay = 1) val gridOptions: Flow<List<OptionItemViewModel2<Drawable>>> = interactor.gridOptions Loading @@ -72,11 +73,7 @@ constructor( val onApply: Flow<(suspend () -> Unit)?> = combine(overridingGridKey, selectedGridOption) { overridingGridKey, selectedGridOption -> if (overridingGridKey != null && overridingGridKey != selectedGridOption.key.value) { { interactor.applySelectedOption( overridingGridKey ?: selectedGridOption.key.value ) } { interactor.applyGridOption(overridingGridKey) } } else { null } Loading tests/robotests/src/com/android/customization/picker/grid/data/repository/GridRepository2Test.kt +2 −2 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ class GridRepository2Test { ) val gridOptions = collectLastValue(underTest.gridOptions) underTest.applySelectedOption("practical") underTest.applyGridOption("practical") assertThat(gridOptions()) .isEqualTo( Loading Loading @@ -123,7 +123,7 @@ class GridRepository2Test { ) val selectedGridOption = collectLastValue(underTest.selectedGridOption) underTest.applySelectedOption("practical") underTest.applyGridOption("practical") assertThat(selectedGridOption()) .isEqualTo(FakeShapeGridManager.DEFAULT_GRID_OPTION_LIST[1].copy(isCurrent = true)) Loading Loading
src/com/android/customization/model/grid/DefaultShapeGridManager.kt +2 −2 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ constructor( override fun applyGridOption(gridKey: String) { context.contentResolver.update( previewUtils.getUri(SHAPE_GRID), previewUtils.getUri(SET_GRID), ContentValues().apply { put(COL_GRID_KEY, gridKey) }, null, null, Loading Loading @@ -189,7 +189,7 @@ constructor( const val TAG = "DefaultShapeGridManager" const val SHAPE_OPTIONS: String = "shape_options" const val GRID_OPTIONS: String = "list_options" const val SHAPE_GRID: String = "default_grid" const val SET_GRID: String = "default_grid" const val SET_SHAPE: String = "shape" const val COL_SHAPE_KEY: String = "shape_key" const val COL_GRID_KEY: String = "name" Loading
src/com/android/customization/picker/grid/data/repository/GridRepository2.kt +1 −1 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ constructor( val isGridCustomizationAvailable = gridOptions.filterNotNull().map { it.size > 1 }.distinctUntilChanged() suspend fun applySelectedOption(gridKey: String) = suspend fun applyGridOption(gridKey: String) = withContext(bgDispatcher) { manager.applyGridOption(gridKey) // After applying, we should query and update shape and grid options again. Loading
src/com/android/customization/picker/grid/domain/interactor/GridInteractor2.kt +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ class GridInteractor2 @Inject constructor(private val repository: GridRepository val selectedGridOption = repository.selectedGridOption suspend fun applySelectedOption(gridKey: String) = repository.applySelectedOption(gridKey) suspend fun applyGridOption(gridKey: String) = repository.applyGridOption(gridKey) fun getGridOptionDrawable(iconId: Int): Drawable? = repository.getGridOptionDrawable(iconId) }
src/com/android/wallpaper/customization/ui/viewmodel/GridPickerViewModel.kt +5 −8 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ constructor( -> overridingGridOptionKey ?: selectedGridOption.key.value } .shareIn(scope = viewModelScope, started = SharingStarted.Lazily, replay = 1) val gridOptions: Flow<List<OptionItemViewModel2<Drawable>>> = interactor.gridOptions Loading @@ -72,11 +73,7 @@ constructor( val onApply: Flow<(suspend () -> Unit)?> = combine(overridingGridKey, selectedGridOption) { overridingGridKey, selectedGridOption -> if (overridingGridKey != null && overridingGridKey != selectedGridOption.key.value) { { interactor.applySelectedOption( overridingGridKey ?: selectedGridOption.key.value ) } { interactor.applyGridOption(overridingGridKey) } } else { null } Loading
tests/robotests/src/com/android/customization/picker/grid/data/repository/GridRepository2Test.kt +2 −2 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ class GridRepository2Test { ) val gridOptions = collectLastValue(underTest.gridOptions) underTest.applySelectedOption("practical") underTest.applyGridOption("practical") assertThat(gridOptions()) .isEqualTo( Loading Loading @@ -123,7 +123,7 @@ class GridRepository2Test { ) val selectedGridOption = collectLastValue(underTest.selectedGridOption) underTest.applySelectedOption("practical") underTest.applyGridOption("practical") assertThat(selectedGridOption()) .isEqualTo(FakeShapeGridManager.DEFAULT_GRID_OPTION_LIST[1].copy(isCurrent = true)) Loading