diff --git a/ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationInjector.kt b/ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationInjector.kt index 4c4f111..004c1d0 100644 --- a/ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationInjector.kt +++ b/ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationInjector.kt @@ -1,5 +1,18 @@ package com.google.android.customization.module +import com.android.wallpaper.module.CustomizationSections + import com.android.customization.module.DefaultCustomizationInjector -public class GoogleCustomizationInjector : DefaultCustomizationInjector() +public class GoogleCustomizationInjector : DefaultCustomizationInjector() { + + private var customizationSections: CustomizationSections? = null + + override fun getCustomizationSections(): CustomizationSections { + if (customizationSections == null) { + customizationSections = GoogleCustomizationSections() + } + return customizationSections!! + } + +} diff --git a/ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationSections.java b/ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationSections.java new file mode 100644 index 0000000..484ff96 --- /dev/null +++ b/ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationSections.java @@ -0,0 +1,59 @@ +package com.google.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.DarkModeSectionController; +import com.android.customization.model.themedicon.ThemedIconSectionController; +import com.android.customization.model.themedicon.ThemedIconSwitchProvider; +import com.android.wallpaper.model.CustomizationSectionController; +import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController; +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.CustomizationSections; + +import java.util.ArrayList; +import java.util.List; + +/** {@link CustomizationSections} for the customization picker. */ +public final class GoogleCustomizationSections implements CustomizationSections { + + @Override + public List> getAllSectionControllers(Activity activity, + LifecycleOwner lifecycleOwner, WallpaperColorsViewModel wallpaperColorsViewModel, + WorkspaceViewModel workspaceViewModel, PermissionRequester permissionRequester, + WallpaperPreviewNavigator wallpaperPreviewNavigator, + CustomizationSectionNavigationController sectionNavigationController, + @Nullable Bundle savedInstanceState) { + List> sectionControllers = new ArrayList<>(); + + // Wallpaper section. + sectionControllers.add(new WallpaperSectionController( + activity, lifecycleOwner, permissionRequester, wallpaperColorsViewModel, + workspaceViewModel, sectionNavigationController, wallpaperPreviewNavigator, + savedInstanceState)); + + // Dark/Light theme section. + sectionControllers.add(new DarkModeSectionController(activity, + lifecycleOwner.getLifecycle())); + + // Themed app icon section. + sectionControllers.add(new ThemedIconSectionController( + ThemedIconSwitchProvider.getInstance(activity), workspaceViewModel, + savedInstanceState)); + + // App grid section. + sectionControllers.add(new GridSectionController( + GridOptionsManager.getInstance(activity), sectionNavigationController)); + + return sectionControllers; + } +}