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

Commit c44abebf authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[3/n] Move new picker logic to AOSP" into sc-dev

parents d9ee34df 1473ab0f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.wallpaper.model.CategoryProvider;
import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.module.BaseWallpaperInjector;
import com.android.wallpaper.module.DefaultCategoryProvider;
import com.android.wallpaper.module.HubSections;
import com.android.wallpaper.module.LoggingOptInStatusProvider;
import com.android.wallpaper.module.WallpaperPreferences;
import com.android.wallpaper.module.WallpaperRotationRefresher;
@@ -46,6 +47,7 @@ public class DefaultCustomizationInjector extends BaseWallpaperInjector
    private WallpaperRotationRefresher mWallpaperRotationRefresher;
    private PerformanceMonitor mPerformanceMonitor;
    private WallpaperPreferences mPrefs;
    private HubSections mHubSections;

    @Override
    public synchronized WallpaperPreferences getPreferences(Context context) {
@@ -139,4 +141,11 @@ public class DefaultCustomizationInjector extends BaseWallpaperInjector
        return new ThemeManager(provider, activity, overlayManagerCompat, logger);
    }

    @Override
    public HubSections getHubSections() {
        if (mHubSections == null) {
            mHubSections = new DefaultCustomizationSections();
        }
        return mHubSections;
    }
}
+60 −0
Original line number Diff line number Diff line
package com.android.customization.module;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.lifecycle.LifecycleOwner;

import com.android.customization.model.grid.GridOptionsManager;
import com.android.customization.model.grid.GridSectionController;
import com.android.customization.model.mode.ModeSection;
import com.android.customization.model.themedicon.ThemedIconSectionController;
import com.android.customization.model.themedicon.ThemedIconSwitchProvider;
import com.android.customization.model.themedicon.ThemedIconUtils;
import com.android.wallpaper.R;
import com.android.wallpaper.model.HubSectionController;
import com.android.wallpaper.model.PermissionRequester;
import com.android.wallpaper.model.WallpaperColorsViewModel;
import com.android.wallpaper.model.WallpaperPreviewNavigator;
import com.android.wallpaper.model.WallpaperSectionController;
import com.android.wallpaper.model.WorkspaceViewModel;
import com.android.wallpaper.module.HubSections;

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

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

    @Override
    public List<HubSectionController<?>> getAllSectionControllers(Activity activity,
            LifecycleOwner lifecycleOwner, WallpaperColorsViewModel wallpaperColorsViewModel,
            WorkspaceViewModel workspaceViewModel, PermissionRequester permissionRequester,
            WallpaperPreviewNavigator wallpaperPreviewNavigator,
            HubSectionController.HubSectionNavigationController hubSectionNavigationController,
            @Nullable Bundle savedInstanceState) {
        List<HubSectionController<?>> sectionControllers = new ArrayList<>();

        // Wallpaper section.
        sectionControllers.add(new WallpaperSectionController(
                activity, lifecycleOwner, permissionRequester, wallpaperColorsViewModel,
                workspaceViewModel, hubSectionNavigationController, wallpaperPreviewNavigator,
                savedInstanceState));

        // Dark/Light theme section.
        sectionControllers.add(new ModeSection(activity, lifecycleOwner.getLifecycle()));

        // Themed app icon section.
        sectionControllers.add(new ThemedIconSectionController(
                new ThemedIconSwitchProvider(activity, new ThemedIconUtils(activity,
                        activity.getString(R.string.themed_icon_metadata_key))),
                workspaceViewModel));

        // App grid section.
        sectionControllers.add(new GridSectionController(
                GridOptionsManager.get(activity), hubSectionNavigationController));

        return sectionControllers;
    }
}