Merge "Clock style list content" into main
diff --git a/src/com/android/customization/module/DefaultCustomizationSections.java b/src/com/android/customization/module/DefaultCustomizationSections.java
index 33cb620..e9b7b2d 100644
--- a/src/com/android/customization/module/DefaultCustomizationSections.java
+++ b/src/com/android/customization/module/DefaultCustomizationSections.java
@@ -19,6 +19,7 @@
import com.android.customization.picker.color.domain.interactor.ColorPickerInteractor;
import com.android.customization.picker.color.ui.section.ColorSectionController;
import com.android.customization.picker.color.ui.viewmodel.ColorPickerViewModel;
+import com.android.customization.picker.grid.domain.interactor.GridInteractor;
import com.android.customization.picker.grid.ui.section.GridSectionController;
import com.android.customization.picker.notifications.ui.section.NotificationSectionController;
import com.android.customization.picker.notifications.ui.viewmodel.NotificationSectionViewModel;
@@ -61,6 +62,7 @@
private final ClockViewFactory mClockViewFactory;
private final ThemedIconSnapshotRestorer mThemedIconSnapshotRestorer;
private final ThemedIconInteractor mThemedIconInteractor;
+ private final GridInteractor mGridInteractor;
private final ColorPickerInteractor mColorPickerInteractor;
private final ThemesUserEventLogger mThemesUserEventLogger;
@@ -75,6 +77,7 @@
ClockViewFactory clockViewFactory,
ThemedIconSnapshotRestorer themedIconSnapshotRestorer,
ThemedIconInteractor themedIconInteractor,
+ GridInteractor gridInteractor,
ColorPickerInteractor colorPickerInteractor,
ThemesUserEventLogger themesUserEventLogger) {
mColorPickerViewModelFactory = colorPickerViewModelFactory;
@@ -86,6 +89,7 @@
mClockViewFactory = clockViewFactory;
mThemedIconSnapshotRestorer = themedIconSnapshotRestorer;
mThemedIconInteractor = themedIconInteractor;
+ mGridInteractor = gridInteractor;
mColorPickerInteractor = colorPickerInteractor;
mThemesUserEventLogger = themesUserEventLogger;
mColorContrastSectionViewModelFactory = colorContrastSectionViewModelFactory;
@@ -125,6 +129,7 @@
sectionNavigationController,
wallpaperInteractor,
mThemedIconInteractor,
+ mGridInteractor,
mColorPickerInteractor,
wallpaperManager,
isTwoPaneAndSmallWidth,
@@ -139,6 +144,7 @@
wallpaperPreviewNavigator,
wallpaperInteractor,
mThemedIconInteractor,
+ mGridInteractor,
mColorPickerInteractor,
wallpaperManager,
isTwoPaneAndSmallWidth,
@@ -210,8 +216,7 @@
new GridSectionController(
GridOptionsManager.getInstance(activity),
sectionNavigationController,
- lifecycleOwner,
- /* isRevampedUiEnabled= */ true));
+ lifecycleOwner));
break;
}
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index d26141b..4c0f216 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -142,6 +142,7 @@
clockViewFactory,
getThemedIconSnapshotRestorer(appContext),
getThemedIconInteractor(),
+ getGridInteractor(appContext),
colorPickerInteractor.get(),
getUserEventLogger(),
)
diff --git a/src/com/android/customization/picker/grid/data/repository/GridRepository.kt b/src/com/android/customization/picker/grid/data/repository/GridRepository.kt
index f384429..dc308db 100644
--- a/src/com/android/customization/picker/grid/data/repository/GridRepository.kt
+++ b/src/com/android/customization/picker/grid/data/repository/GridRepository.kt
@@ -30,6 +30,8 @@
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.suspendCancellableCoroutine
@@ -37,11 +39,17 @@
interface GridRepository {
suspend fun isAvailable(): Boolean
+
fun getOptionChanges(): Flow<Unit>
+
suspend fun getOptions(): GridOptionItemsModel
- fun getSelectedOption(): GridOption?
+
+ fun getSelectedOption(): StateFlow<GridOption?>
+
fun applySelectedOption(callback: Callback)
+
fun clearSelectedOption()
+
fun isSelectedOptionApplied(): Boolean
}
@@ -63,7 +71,7 @@
private var appliedOption: GridOption? = null
- override fun getSelectedOption() = selectedOption.value
+ override fun getSelectedOption() = selectedOption.asStateFlow()
override suspend fun getOptions(): GridOptionItemsModel {
return withContext(backgroundDispatcher) {
@@ -133,6 +141,7 @@
option,
object : CustomizationManager.Callback {
override fun onSuccess() {
+ selectedOption.value = option
continuation.resume(true)
}
@@ -147,7 +156,7 @@
}
override fun applySelectedOption(callback: Callback) {
- val option = getSelectedOption()
+ val option = getSelectedOption().value
manager.apply(
option,
if (isGridApplyButtonEnabled) {
diff --git a/src/com/android/customization/picker/grid/domain/interactor/GridInteractor.kt b/src/com/android/customization/picker/grid/domain/interactor/GridInteractor.kt
index 02e16dd..015bcdf 100644
--- a/src/com/android/customization/picker/grid/domain/interactor/GridInteractor.kt
+++ b/src/com/android/customization/picker/grid/domain/interactor/GridInteractor.kt
@@ -18,7 +18,6 @@
package com.android.customization.picker.grid.domain.interactor
import com.android.customization.model.CustomizationManager
-import com.android.customization.model.grid.GridOption
import com.android.customization.picker.grid.data.repository.GridRepository
import com.android.customization.picker.grid.shared.model.GridOptionItemModel
import com.android.customization.picker.grid.shared.model.GridOptionItemsModel
@@ -75,7 +74,7 @@
}
}
- fun getSelectOptionNonSuspend(): GridOption? = repository.getSelectedOption()
+ fun getSelectOptionStateFlow() = repository.getSelectedOption()
fun clearSelectedOption() = repository.clearSelectedOption()
diff --git a/src/com/android/customization/picker/grid/ui/fragment/GridFragment.kt b/src/com/android/customization/picker/grid/ui/fragment/GridFragment.kt
index b48f41a..7e2341c 100644
--- a/src/com/android/customization/picker/grid/ui/fragment/GridFragment.kt
+++ b/src/com/android/customization/picker/grid/ui/fragment/GridFragment.kt
@@ -115,7 +115,7 @@
context,
getString(
R.string.toast_of_changing_grid,
- gridInteractor.getSelectOptionNonSuspend()?.title
+ gridInteractor.getSelectOptionStateFlow().value?.title
),
Toast.LENGTH_SHORT
)
@@ -128,7 +128,7 @@
val errorMsg =
getString(
R.string.toast_of_failure_to_change_grid,
- gridInteractor.getSelectOptionNonSuspend()?.title
+ gridInteractor.getSelectOptionStateFlow().value?.title
)
Toast.makeText(context, errorMsg, Toast.LENGTH_SHORT).show()
Log.e(TAG, errorMsg, throwable)
@@ -178,7 +178,10 @@
),
initialExtrasProvider = {
val bundle = Bundle()
- bundle.putString("name", gridInteractor.getSelectOptionNonSuspend()?.name)
+ bundle.putString(
+ "name",
+ gridInteractor.getSelectOptionStateFlow().value?.name
+ )
bundle
},
wallpaperInfoProvider = {
diff --git a/src/com/android/customization/picker/grid/ui/section/GridSectionController.java b/src/com/android/customization/picker/grid/ui/section/GridSectionController.java
index 0e15609..bc66812 100644
--- a/src/com/android/customization/picker/grid/ui/section/GridSectionController.java
+++ b/src/com/android/customization/picker/grid/ui/section/GridSectionController.java
@@ -51,8 +51,7 @@
public GridSectionController(
GridOptionsManager gridOptionsManager,
CustomizationSectionNavigationController sectionNavigationController,
- LifecycleOwner lifecycleOwner,
- boolean isRevampedUiEnabled) {
+ LifecycleOwner lifecycleOwner) {
mGridOptionsManager = gridOptionsManager;
mSectionNavigationController = sectionNavigationController;
mLifecycleOwner = lifecycleOwner;
diff --git a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
index e1f8df2..db43f4b 100644
--- a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
+++ b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
@@ -39,6 +39,7 @@
import com.android.customization.picker.clock.ui.view.ClockViewFactory
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselViewModel
import com.android.customization.picker.color.domain.interactor.ColorPickerInteractor
+import com.android.customization.picker.grid.domain.interactor.GridInteractor
import com.android.themepicker.R
import com.android.wallpaper.model.CustomizationSectionController
import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController
@@ -72,6 +73,7 @@
private val navigationController: CustomizationSectionNavigationController,
wallpaperInteractor: WallpaperInteractor,
themedIconInteractor: ThemedIconInteractor,
+ gridInteractor: GridInteractor,
colorPickerInteractor: ColorPickerInteractor,
wallpaperManager: WallpaperManager,
private val isTwoPaneAndSmallWidth: Boolean,
@@ -87,6 +89,7 @@
wallpaperPreviewNavigator,
wallpaperInteractor,
themedIconInteractor,
+ gridInteractor,
colorPickerInteractor,
wallpaperManager,
isTwoPaneAndSmallWidth,
diff --git a/src/com/android/customization/picker/preview/ui/section/PreviewWithThemeSectionController.kt b/src/com/android/customization/picker/preview/ui/section/PreviewWithThemeSectionController.kt
index 78e3745..cd3e702 100644
--- a/src/com/android/customization/picker/preview/ui/section/PreviewWithThemeSectionController.kt
+++ b/src/com/android/customization/picker/preview/ui/section/PreviewWithThemeSectionController.kt
@@ -23,6 +23,7 @@
import androidx.lifecycle.LifecycleOwner
import com.android.customization.model.themedicon.domain.interactor.ThemedIconInteractor
import com.android.customization.picker.color.domain.interactor.ColorPickerInteractor
+import com.android.customization.picker.grid.domain.interactor.GridInteractor
import com.android.customization.picker.preview.ui.viewmodel.PreviewWithThemeViewModel
import com.android.wallpaper.R
import com.android.wallpaper.model.Screen
@@ -52,6 +53,7 @@
wallpaperPreviewNavigator: WallpaperPreviewNavigator,
private val wallpaperInteractor: WallpaperInteractor,
private val themedIconInteractor: ThemedIconInteractor,
+ private val gridInteractor: GridInteractor,
private val colorPickerInteractor: ColorPickerInteractor,
wallpaperManager: WallpaperManager,
isTwoPaneAndSmallWidth: Boolean,
@@ -121,6 +123,7 @@
initialExtrasProvider = { getInitialExtras(isOnLockScreen) },
wallpaperInteractor = wallpaperInteractor,
themedIconInteractor = themedIconInteractor,
+ gridInteractor = gridInteractor,
colorPickerInteractor = colorPickerInteractor,
screen = screen,
)
diff --git a/src/com/android/customization/picker/preview/ui/viewmodel/PreviewWithThemeViewModel.kt b/src/com/android/customization/picker/preview/ui/viewmodel/PreviewWithThemeViewModel.kt
index 7877f11..331ec2e 100644
--- a/src/com/android/customization/picker/preview/ui/viewmodel/PreviewWithThemeViewModel.kt
+++ b/src/com/android/customization/picker/preview/ui/viewmodel/PreviewWithThemeViewModel.kt
@@ -21,6 +21,7 @@
import android.os.Bundle
import com.android.customization.model.themedicon.domain.interactor.ThemedIconInteractor
import com.android.customization.picker.color.domain.interactor.ColorPickerInteractor
+import com.android.customization.picker.grid.domain.interactor.GridInteractor
import com.android.wallpaper.model.Screen
import com.android.wallpaper.model.WallpaperInfo
import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor
@@ -28,6 +29,8 @@
import com.android.wallpaper.util.PreviewUtils
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.merge
/** A ThemePicker version of the [ScreenPreviewViewModel] */
class PreviewWithThemeViewModel(
@@ -36,7 +39,8 @@
wallpaperInfoProvider: suspend (forceReload: Boolean) -> WallpaperInfo?,
onWallpaperColorChanged: (WallpaperColors?) -> Unit = {},
wallpaperInteractor: WallpaperInteractor,
- private val themedIconInteractor: ThemedIconInteractor? = null,
+ private val themedIconInteractor: ThemedIconInteractor,
+ private val gridInteractor: GridInteractor,
colorPickerInteractor: ColorPickerInteractor? = null,
screen: Screen,
) :
@@ -48,7 +52,11 @@
wallpaperInteractor,
screen,
) {
- override fun workspaceUpdateEvents(): Flow<Boolean>? = themedIconInteractor?.isActivated
+ override fun workspaceUpdateEvents(): Flow<Unit> =
+ merge(
+ themedIconInteractor.isActivated.map {},
+ gridInteractor.getSelectOptionStateFlow().map {}
+ )
private val wallpaperIsLoading = super.isLoading
diff --git a/tests/robotests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt b/tests/robotests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt
index de68bf0..391e270 100644
--- a/tests/robotests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt
+++ b/tests/robotests/src/com/android/customization/model/grid/data/repository/FakeGridRepository.kt
@@ -18,7 +18,6 @@
package com.android.customization.model.grid.data.repository
import com.android.customization.model.CustomizationManager
-import com.android.customization.model.grid.GridOption
import com.android.customization.picker.grid.data.repository.GridRepository
import com.android.customization.picker.grid.shared.model.GridOptionItemModel
import com.android.customization.picker.grid.shared.model.GridOptionItemsModel
@@ -54,7 +53,7 @@
return options
}
- override fun getSelectedOption(): GridOption? = null
+ override fun getSelectedOption() = MutableStateFlow(null)
override fun applySelectedOption(callback: CustomizationManager.Callback) {}