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

Commit 75ee8e89 authored by Catherine Liang's avatar Catherine Liang Committed by Android (Google) Code Review
Browse files

Merge "Revert^2 "Color Picker reset support (1/3)"" into tm-qpr-dev

parents 7e3dd8e0 cc5b01e2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ public class ColorCustomizationManager implements CustomizationManager<ColorOpti
     * or {@link ColorOptionsProvider#COLOR_SOURCE_PRESET}.
     */
    @ColorSource
    public String getCurrentColorSource() {
    public @Nullable String getCurrentColorSource() {
        if (mCurrentSource == null) {
            parseSettings(getStoredOverlays());
        }
@@ -221,7 +221,7 @@ public class ColorCustomizationManager implements CustomizationManager<ColorOpti
     * @return The style of the currently applied color. One of enum values in
     * {@link com.android.systemui.monet.Style}.
     */
    public String getCurrentStyle() {
    public @Nullable String getCurrentStyle() {
        if (mCurrentStyle == null) {
            parseSettings(getStoredOverlays());
        }
+3 −0
Original line number Diff line number Diff line
@@ -107,6 +107,9 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> {
        if (other == null) {
            return false;
        }
        if (mStyle != other.getStyle()) {
            return false;
        }
        if (mIsDefault) {
            return other.isDefault() || TextUtils.isEmpty(other.getSerializedPackages())
                    || EMPTY_JSON.equals(other.getSerializedPackages());
+25 −4
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.customization.picker.clock.ui.viewmodel.ClockSectionViewModel
import com.android.customization.picker.clock.ui.viewmodel.ClockSettingsViewModel
import com.android.customization.picker.color.data.repository.ColorPickerRepositoryImpl
import com.android.customization.picker.color.domain.interactor.ColorPickerInteractor
import com.android.customization.picker.color.domain.interactor.ColorPickerSnapshotRestorer
import com.android.customization.picker.color.ui.viewmodel.ColorPickerViewModel
import com.android.customization.picker.notifications.data.repository.NotificationsRepository
import com.android.customization.picker.notifications.domain.interactor.NotificationsInteractor
@@ -100,6 +101,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
    private var notificationSectionViewModelFactory: NotificationSectionViewModel.Factory? = null
    private var colorPickerInteractor: ColorPickerInteractor? = null
    private var colorPickerViewModelFactory: ColorPickerViewModel.Factory? = null
    private var colorPickerSnapshotRestorer: ColorPickerSnapshotRestorer? = null
    private var darkModeSnapshotRestorer: DarkModeSnapshotRestorer? = null
    private var themedIconSnapshotRestorer: ThemedIconSnapshotRestorer? = null
    private var themedIconInteractor: ThemedIconInteractor? = null
@@ -113,8 +115,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
            ?: DefaultCustomizationSections(
                    getColorPickerViewModelFactory(
                        context = activity,
                        wallpaperColorsViewModel =
                            ViewModelProvider(activity)[WallpaperColorsViewModel::class.java],
                        wallpaperColorsViewModel = getWallpaperColorsViewModel(),
                    ),
                    getKeyguardQuickAffordancePickerInteractor(activity),
                    getKeyguardQuickAffordancePickerViewModelFactory(activity),
@@ -190,6 +191,8 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
            this[KEY_DARK_MODE_SNAPSHOT_RESTORER] = getDarkModeSnapshotRestorer(context)
            this[KEY_THEMED_ICON_SNAPSHOT_RESTORER] = getThemedIconSnapshotRestorer(context)
            this[KEY_APP_GRID_SNAPSHOT_RESTORER] = getGridSnapshotRestorer(context)
            this[KEY_COLOR_PICKER_SNAPSHOT_RESTORER] =
                getColorPickerSnapshotRestorer(context, getWallpaperColorsViewModel())
        }
    }

@@ -346,7 +349,12 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
        wallpaperColorsViewModel: WallpaperColorsViewModel,
    ): ColorPickerInteractor {
        return colorPickerInteractor
            ?: ColorPickerInteractor(ColorPickerRepositoryImpl(context, wallpaperColorsViewModel))
            ?: ColorPickerInteractor(
                    repository = ColorPickerRepositoryImpl(context, wallpaperColorsViewModel),
                    snapshotRestorer = {
                        getColorPickerSnapshotRestorer(context, wallpaperColorsViewModel)
                    }
                )
                .also { colorPickerInteractor = it }
    }

@@ -362,6 +370,17 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
                .also { colorPickerViewModelFactory = it }
    }

    private fun getColorPickerSnapshotRestorer(
        context: Context,
        wallpaperColorsViewModel: WallpaperColorsViewModel,
    ): ColorPickerSnapshotRestorer {
        return colorPickerSnapshotRestorer
            ?: ColorPickerSnapshotRestorer(
                    getColorPickerInteractor(context, wallpaperColorsViewModel)
                )
                .also { colorPickerSnapshotRestorer = it }
    }

    fun getDarkModeSnapshotRestorer(
        context: Context,
    ): DarkModeSnapshotRestorer {
@@ -460,6 +479,8 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
        private val KEY_THEMED_ICON_SNAPSHOT_RESTORER = KEY_DARK_MODE_SNAPSHOT_RESTORER + 1
        @JvmStatic
        private val KEY_APP_GRID_SNAPSHOT_RESTORER = KEY_THEMED_ICON_SNAPSHOT_RESTORER + 1
        @JvmStatic
        private val KEY_COLOR_PICKER_SNAPSHOT_RESTORER = KEY_APP_GRID_SNAPSHOT_RESTORER + 1

        /**
         * When this injector is overridden, this is the minimal value that should be used by
@@ -467,6 +488,6 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
         *
         * It should always be greater than the biggest restorer key.
         */
        @JvmStatic protected val MIN_SNAPSHOT_RESTORER_KEY = KEY_APP_GRID_SNAPSHOT_RESTORER + 1
        @JvmStatic protected val MIN_SNAPSHOT_RESTORER_KEY = KEY_COLOR_PICKER_SNAPSHOT_RESTORER + 1
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import androidx.lifecycle.get
import com.android.customization.module.ThemePickerInjector
import com.android.customization.picker.clock.ui.binder.ClockSettingsBinder
import com.android.wallpaper.R
import com.android.wallpaper.model.WallpaperColorsViewModel
import com.android.wallpaper.module.InjectorProvider
import com.android.wallpaper.picker.AppbarFragment
import com.android.wallpaper.picker.customization.ui.binder.ScreenPreviewBinder
@@ -63,7 +62,7 @@ class ClockSettingsFragment : AppbarFragment() {
        val injector = InjectorProvider.getInjector() as ThemePickerInjector

        val lockScreenView: CardView = view.requireViewById(R.id.lock_preview)
        val colorViewModel = ViewModelProvider(activity)[WallpaperColorsViewModel::class.java]
        val colorViewModel = injector.getWallpaperColorsViewModel()
        val displayUtils = injector.getDisplayUtils(context)
        ScreenPreviewBinder.bind(
                activity = activity,
+4 −6
Original line number Diff line number Diff line
@@ -25,15 +25,13 @@ import kotlinx.coroutines.flow.Flow
 * system color.
 */
interface ColorPickerRepository {
    /**
     * The newly selected color option for overwriting the current active option during an
     * optimistic update, the value is null when no overwriting is needed
     */
    val activeColorOption: Flow<ColorOptionModel?>

    /** List of wallpaper and preset color options on the device, categorized by Color Type */
    val colorOptions: Flow<Map<ColorType, List<ColorOptionModel>>>

    /** Selects a color option with optimistic update */
    fun select(colorOptionModel: ColorOptionModel)
    suspend fun select(colorOptionModel: ColorOptionModel)

    /** Returns the current selected color option based on system settings */
    fun getCurrentColorOption(): ColorOptionModel
}
Loading