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
diff --git a/src/com/android/customization/module/DefaultCustomizationSections.java b/src/com/android/customization/module/DefaultCustomizationSections.java
index c47a6e6..ea071ea 100644
--- a/src/com/android/customization/module/DefaultCustomizationSections.java
+++ b/src/com/android/customization/module/DefaultCustomizationSections.java
@@ -25,12 +25,16 @@
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 @@
CustomizationSectionNavigationController sectionNavigationController,
@Nullable Bundle savedInstanceState,
CurrentWallpaperInfoFactory wallpaperInfoFactory,
- DisplayUtils displayUtils) {
+ DisplayUtils displayUtils,
+ WallpaperInteractor wallpaperInteractor) {
List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>();
// Wallpaper section.
@@ -76,6 +81,14 @@
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.
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index b3f95d5..ab6b673 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -122,6 +122,7 @@
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 @@
}
}
- protected fun getKeyguardQuickAffordanceSnapshotRestorer(
+ private fun getKeyguardQuickAffordanceSnapshotRestorer(
context: Context
): KeyguardQuickAffordanceSnapshotRestorer {
return keyguardQuickAffordanceSnapshotRestorer
@@ -194,12 +195,13 @@
@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
}
}