Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 132e1b2e authored by Catherine Liang's avatar Catherine Liang Committed by Automerger Merge Worker
Browse files

Merge "Revert "Clean up and refactor load initial colors (1/3)"" into udc-dev am: 64ba797c

parents 189b5d77 64ba797c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -145,7 +145,6 @@ public final class DefaultCustomizationSections implements CustomizationSections
                                        activity,
                                        mColorPickerViewModelFactory)
                                        .get(ColorPickerViewModel.class),
                                wallpaperColorsViewModel,
                                lifecycleOwner),
                        // Wallpaper quick switch section.
                        new WallpaperQuickSwitchSectionController(
+1 −2
Original line number Diff line number Diff line
@@ -439,8 +439,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
                    repository =
                        ColorPickerRepositoryImpl(
                            wallpaperColorsViewModel,
                            getColorCustomizationManager(appContext),
                            WallpaperManager.getInstance(appContext),
                            getColorCustomizationManager(appContext)
                        ),
                    snapshotRestorer = {
                        getColorPickerSnapshotRestorer(appContext, wallpaperColorsViewModel)
+0 −3
Original line number Diff line number Diff line
@@ -37,7 +37,4 @@ 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()
}
+1 −16
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
 */
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
@@ -27,20 +26,17 @@ 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(
    private val wallpaperColorsViewModel: WallpaperColorsViewModel,
    wallpaperColorsViewModel: WallpaperColorsViewModel,
    private val colorManager: ColorCustomizationManager,
    private val wallpaperManager: WallpaperManager,
) : ColorPickerRepository {

    private val homeWallpaperColors: StateFlow<WallpaperColorsModel?> =
@@ -155,17 +151,6 @@ 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}",
+0 −2
Original line number Diff line number Diff line
@@ -166,8 +166,6 @@ 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