Loading src/com/android/customization/module/DefaultCustomizationSections.java +1 −0 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ public final class DefaultCustomizationSections implements CustomizationSections activity, mColorPickerViewModelFactory) .get(ColorPickerViewModel.class), wallpaperColorsViewModel, lifecycleOwner), // Wallpaper quick switch section. new WallpaperQuickSwitchSectionController( Loading src/com/android/customization/module/ThemePickerInjector.kt +2 −1 Original line number Diff line number Diff line Loading @@ -439,7 +439,8 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject repository = ColorPickerRepositoryImpl( wallpaperColorsViewModel, getColorCustomizationManager(appContext) getColorCustomizationManager(appContext), WallpaperManager.getInstance(appContext), ), snapshotRestorer = { getColorPickerSnapshotRestorer(appContext, wallpaperColorsViewModel) Loading src/com/android/customization/picker/color/data/repository/ColorPickerRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,7 @@ interface ColorPickerRepository { /** Returns the current selected color source based on system settings */ fun getCurrentColorSource(): String? /** Retrieves and stores the wallpaper colors for generating wallpaper color options */ suspend fun loadInitialColors() } src/com/android/customization/picker/color/data/repository/ColorPickerRepositoryImpl.kt +16 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ */ package com.android.customization.picker.color.data.repository import android.app.WallpaperManager import android.util.Log import com.android.customization.model.CustomizationManager import com.android.customization.model.color.ColorCustomizationManager Loading @@ -26,17 +27,20 @@ import com.android.customization.picker.color.shared.model.ColorType import com.android.systemui.monet.Style import com.android.wallpaper.model.WallpaperColorsModel import com.android.wallpaper.model.WallpaperColorsViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.withContext // TODO (b/262924623): refactor to remove dependency on ColorCustomizationManager & ColorOption // TODO (b/268203200): Create test for ColorPickerRepositoryImpl class ColorPickerRepositoryImpl( wallpaperColorsViewModel: WallpaperColorsViewModel, private val wallpaperColorsViewModel: WallpaperColorsViewModel, private val colorManager: ColorCustomizationManager, private val wallpaperManager: WallpaperManager, ) : ColorPickerRepository { private val homeWallpaperColors: StateFlow<WallpaperColorsModel?> = Loading Loading @@ -151,6 +155,17 @@ class ColorPickerRepositoryImpl( return colorManager.currentColorSource } override suspend fun loadInitialColors() { withContext(Dispatchers.IO) { val lockColors = wallpaperManager.getWallpaperColors(WallpaperManager.FLAG_LOCK) val homeColors = wallpaperManager.getWallpaperColors(WallpaperManager.FLAG_SYSTEM) withContext(Dispatchers.Main) { wallpaperColorsViewModel.setLockWallpaperColors(lockColors) wallpaperColorsViewModel.setHomeWallpaperColors(homeColors) } } } private fun ColorOptionImpl.toModel(): ColorOptionModel { return ColorOptionModel( key = "${this.type}::${this.style}::${this.serializedPackages}", Loading src/com/android/customization/picker/color/data/repository/FakeColorPickerRepository.kt +2 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,8 @@ class FakeColorPickerRepository(private val context: Context) : ColorPickerRepos else -> null } override suspend fun loadInitialColors() {} private fun ColorOptionModel.testEquals(other: Any?): Boolean { if (other == null) { return false Loading Loading
src/com/android/customization/module/DefaultCustomizationSections.java +1 −0 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ public final class DefaultCustomizationSections implements CustomizationSections activity, mColorPickerViewModelFactory) .get(ColorPickerViewModel.class), wallpaperColorsViewModel, lifecycleOwner), // Wallpaper quick switch section. new WallpaperQuickSwitchSectionController( Loading
src/com/android/customization/module/ThemePickerInjector.kt +2 −1 Original line number Diff line number Diff line Loading @@ -439,7 +439,8 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject repository = ColorPickerRepositoryImpl( wallpaperColorsViewModel, getColorCustomizationManager(appContext) getColorCustomizationManager(appContext), WallpaperManager.getInstance(appContext), ), snapshotRestorer = { getColorPickerSnapshotRestorer(appContext, wallpaperColorsViewModel) Loading
src/com/android/customization/picker/color/data/repository/ColorPickerRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,7 @@ interface ColorPickerRepository { /** Returns the current selected color source based on system settings */ fun getCurrentColorSource(): String? /** Retrieves and stores the wallpaper colors for generating wallpaper color options */ suspend fun loadInitialColors() }
src/com/android/customization/picker/color/data/repository/ColorPickerRepositoryImpl.kt +16 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ */ package com.android.customization.picker.color.data.repository import android.app.WallpaperManager import android.util.Log import com.android.customization.model.CustomizationManager import com.android.customization.model.color.ColorCustomizationManager Loading @@ -26,17 +27,20 @@ import com.android.customization.picker.color.shared.model.ColorType import com.android.systemui.monet.Style import com.android.wallpaper.model.WallpaperColorsModel import com.android.wallpaper.model.WallpaperColorsViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.withContext // TODO (b/262924623): refactor to remove dependency on ColorCustomizationManager & ColorOption // TODO (b/268203200): Create test for ColorPickerRepositoryImpl class ColorPickerRepositoryImpl( wallpaperColorsViewModel: WallpaperColorsViewModel, private val wallpaperColorsViewModel: WallpaperColorsViewModel, private val colorManager: ColorCustomizationManager, private val wallpaperManager: WallpaperManager, ) : ColorPickerRepository { private val homeWallpaperColors: StateFlow<WallpaperColorsModel?> = Loading Loading @@ -151,6 +155,17 @@ class ColorPickerRepositoryImpl( return colorManager.currentColorSource } override suspend fun loadInitialColors() { withContext(Dispatchers.IO) { val lockColors = wallpaperManager.getWallpaperColors(WallpaperManager.FLAG_LOCK) val homeColors = wallpaperManager.getWallpaperColors(WallpaperManager.FLAG_SYSTEM) withContext(Dispatchers.Main) { wallpaperColorsViewModel.setLockWallpaperColors(lockColors) wallpaperColorsViewModel.setHomeWallpaperColors(homeColors) } } } private fun ColorOptionImpl.toModel(): ColorOptionModel { return ColorOptionModel( key = "${this.type}::${this.style}::${this.serializedPackages}", Loading
src/com/android/customization/picker/color/data/repository/FakeColorPickerRepository.kt +2 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,8 @@ class FakeColorPickerRepository(private val context: Context) : ColorPickerRepos else -> null } override suspend fun loadInitialColors() {} private fun ColorOptionModel.testEquals(other: Any?): Boolean { if (other == null) { return false Loading