Keep wallpaper quick switch order stable (2/3).
When switching wallpapers via the quick switcher, keep the order of the
options from changing. What's happening is that there is a silent
recreation of the activity (one that cannot be caught via
onConfigurationChanged) which is causing everything to be reloaded.
The CL changes the view-model to be a true Android ViewModel that can be
retained across activity instances.
Bug: 262924643
Test: manually verified that the wallpaper option remain stable
during/after wallpapers are switched and that the reset system still
works.
Change-Id: I8e63eb9e9534130a2b88f8749cf93d0c5057d149
diff --git a/src/com/android/customization/module/DefaultCustomizationSections.java b/src/com/android/customization/module/DefaultCustomizationSections.java
index ea071ea..2fb530a 100644
--- a/src/com/android/customization/module/DefaultCustomizationSections.java
+++ b/src/com/android/customization/module/DefaultCustomizationSections.java
@@ -25,16 +25,14 @@
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.picker.customization.ui.viewmodel.WallpaperQuickSwitchViewModel;
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 {
@@ -64,7 +62,7 @@
@Nullable Bundle savedInstanceState,
CurrentWallpaperInfoFactory wallpaperInfoFactory,
DisplayUtils displayUtils,
- WallpaperInteractor wallpaperInteractor) {
+ WallpaperQuickSwitchViewModel wallpaperQuickSwitchViewModel) {
List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>();
// Wallpaper section.
@@ -84,10 +82,8 @@
// Wallpaper quick switch section.
sectionControllers.add(
new WallpaperQuickSwitchSectionController(
- wallpaperInteractor,
- lifecycleOwner,
- GlobalScope.INSTANCE,
- sectionNavigationController));
+ wallpaperQuickSwitchViewModel,
+ lifecycleOwner));
switch (screen) {
case LOCK_SCREEN: