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

Commit 536751e4 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

Wallpaper quick switcher section (2/3).

Implements a section that can do wallpaper quick switching.

Bug: 262924643
Test: unit tests added
Test: manually tested that switching wallpapers updates the section with
correct animations and properly actually selects the real wallpaper

Change-Id: I74586ad5ea3c912d78635376eea66fc9c7752773
parent 3631a943
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -25,12 +25,16 @@ import com.android.wallpaper.model.WallpaperSectionController;
import com.android.wallpaper.model.WorkspaceViewModel;
import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
import com.android.wallpaper.module.CustomizationSections;
import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor;
import com.android.wallpaper.picker.customization.ui.section.ScreenPreviewSectionController;
import com.android.wallpaper.picker.customization.ui.section.WallpaperQuickSwitchSectionController;
import com.android.wallpaper.util.DisplayUtils;

import java.util.ArrayList;
import java.util.List;

import kotlinx.coroutines.GlobalScope;

/** {@link CustomizationSections} for the customization picker. */
public final class DefaultCustomizationSections implements CustomizationSections {

@@ -59,7 +63,8 @@ public final class DefaultCustomizationSections implements CustomizationSections
            CustomizationSectionNavigationController sectionNavigationController,
            @Nullable Bundle savedInstanceState,
            CurrentWallpaperInfoFactory wallpaperInfoFactory,
            DisplayUtils displayUtils) {
            DisplayUtils displayUtils,
            WallpaperInteractor wallpaperInteractor) {
        List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>();

        // Wallpaper section.
@@ -76,6 +81,14 @@ public final class DefaultCustomizationSections implements CustomizationSections
        sectionControllers.add(new ColorSectionController(
                activity, wallpaperColorsViewModel, lifecycleOwner, savedInstanceState));

        // Wallpaper quick switch section.
        sectionControllers.add(
                new WallpaperQuickSwitchSectionController(
                        wallpaperInteractor,
                        lifecycleOwner,
                        GlobalScope.INSTANCE,
                        sectionNavigationController));

        switch (screen) {
            case LOCK_SCREEN:
                // Lock screen quick affordances section.
+5 −3
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
        return super<WallpaperPicker2Injector>.getSnapshotRestorers(context).toMutableMap().apply {
            this[KEY_QUICK_AFFORDANCE_SNAPSHOT_RESTORER] =
                getKeyguardQuickAffordanceSnapshotRestorer(context)
            this[KEY_WALLPAPER_SNAPSHOT_RESTORER] = getWallpaperSnapshotRestorer(context)
        }
    }

@@ -179,7 +180,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
            }
    }

    protected fun getKeyguardQuickAffordanceSnapshotRestorer(
    private fun getKeyguardQuickAffordanceSnapshotRestorer(
        context: Context
    ): KeyguardQuickAffordanceSnapshotRestorer {
        return keyguardQuickAffordanceSnapshotRestorer
@@ -194,12 +195,13 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
        @JvmStatic
        private val KEY_QUICK_AFFORDANCE_SNAPSHOT_RESTORER =
            WallpaperPicker2Injector.MIN_SNAPSHOT_RESTORER_KEY
        @JvmStatic
        private val KEY_WALLPAPER_SNAPSHOT_RESTORER = KEY_QUICK_AFFORDANCE_SNAPSHOT_RESTORER + 1

        /**
         * When this injector is overridden, this is the minimal value that should be used by
         * restorers returns in [getSnapshotRestorers].
         */
        @JvmStatic
        protected val MIN_SNAPSHOT_RESTORER_KEY = KEY_QUICK_AFFORDANCE_SNAPSHOT_RESTORER + 1
        @JvmStatic protected val MIN_SNAPSHOT_RESTORER_KEY = KEY_WALLPAPER_SNAPSHOT_RESTORER + 1
    }
}