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

Commit b729b81d authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

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
parent 536751e4
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -25,16 +25,14 @@ 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.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 @@ public final class DefaultCustomizationSections implements CustomizationSections
            @Nullable Bundle savedInstanceState,
            CurrentWallpaperInfoFactory wallpaperInfoFactory,
            DisplayUtils displayUtils,
            WallpaperInteractor wallpaperInteractor) {
            WallpaperQuickSwitchViewModel wallpaperQuickSwitchViewModel) {
        List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>();

        // Wallpaper section.
@@ -84,10 +82,8 @@ public final class DefaultCustomizationSections implements CustomizationSections
        // Wallpaper quick switch section.
        sectionControllers.add(
                new WallpaperQuickSwitchSectionController(
                        wallpaperInteractor,
                        lifecycleOwner,
                        GlobalScope.INSTANCE,
                        sectionNavigationController));
                        wallpaperQuickSwitchViewModel,
                        lifecycleOwner));

        switch (screen) {
            case LOCK_SCREEN: