Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 1 | package com.android.customization.module; |
| 2 | |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 3 | import android.os.Bundle; |
| 4 | |
| 5 | import androidx.annotation.Nullable; |
Alejandro Nijamkin | abda67b | 2022-11-30 14:34:56 -0800 | [diff] [blame] | 6 | import androidx.fragment.app.FragmentActivity; |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 7 | import androidx.lifecycle.LifecycleOwner; |
Alejandro Nijamkin | 0eb2cc2 | 2022-12-19 10:55:57 -0800 | [diff] [blame] | 8 | import androidx.lifecycle.ViewModelProvider; |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 9 | |
Kunhung Li | 7b10d5b | 2022-07-06 16:19:47 +0800 | [diff] [blame] | 10 | import com.android.customization.model.color.ColorSectionController; |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 11 | import com.android.customization.model.grid.GridOptionsManager; |
| 12 | import com.android.customization.model.grid.GridSectionController; |
Chihhang Chuang | 8d14e8a | 2021-06-15 14:03:18 +0800 | [diff] [blame] | 13 | import com.android.customization.model.mode.DarkModeSectionController; |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 14 | import com.android.customization.model.themedicon.ThemedIconSectionController; |
| 15 | import com.android.customization.model.themedicon.ThemedIconSwitchProvider; |
Alejandro Nijamkin | 0eb2cc2 | 2022-12-19 10:55:57 -0800 | [diff] [blame] | 16 | import com.android.customization.picker.quickaffordance.domain.interactor.KeyguardQuickAffordancePickerInteractor; |
| 17 | import com.android.customization.picker.quickaffordance.ui.section.KeyguardQuickAffordanceSectionController; |
| 18 | import com.android.customization.picker.quickaffordance.ui.viewmodel.KeyguardQuickAffordancePickerViewModel; |
Chihhang Chuang | 8d14e8a | 2021-06-15 14:03:18 +0800 | [diff] [blame] | 19 | import com.android.wallpaper.model.CustomizationSectionController; |
| 20 | import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController; |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 21 | import com.android.wallpaper.model.PermissionRequester; |
| 22 | import com.android.wallpaper.model.WallpaperColorsViewModel; |
| 23 | import com.android.wallpaper.model.WallpaperPreviewNavigator; |
| 24 | import com.android.wallpaper.model.WallpaperSectionController; |
| 25 | import com.android.wallpaper.model.WorkspaceViewModel; |
Alejandro Nijamkin | 2fe5f2d | 2022-12-22 15:24:22 -0800 | [diff] [blame^] | 26 | import com.android.wallpaper.module.CurrentWallpaperInfoFactory; |
Chihhang Chuang | 8d14e8a | 2021-06-15 14:03:18 +0800 | [diff] [blame] | 27 | import com.android.wallpaper.module.CustomizationSections; |
Alejandro Nijamkin | 2fe5f2d | 2022-12-22 15:24:22 -0800 | [diff] [blame^] | 28 | import com.android.wallpaper.picker.customization.ui.section.ScreenPreviewSectionController; |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 29 | |
| 30 | import java.util.ArrayList; |
| 31 | import java.util.List; |
| 32 | |
Chihhang Chuang | 8d14e8a | 2021-06-15 14:03:18 +0800 | [diff] [blame] | 33 | /** {@link CustomizationSections} for the customization picker. */ |
| 34 | public final class DefaultCustomizationSections implements CustomizationSections { |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 35 | |
Alejandro Nijamkin | 0eb2cc2 | 2022-12-19 10:55:57 -0800 | [diff] [blame] | 36 | private final KeyguardQuickAffordancePickerInteractor mKeyguardQuickAffordancePickerInteractor; |
| 37 | private final KeyguardQuickAffordancePickerViewModel.Factory |
| 38 | mKeyguardQuickAffordancePickerViewModelFactory; |
| 39 | |
| 40 | public DefaultCustomizationSections( |
| 41 | KeyguardQuickAffordancePickerInteractor keyguardQuickAffordancePickerInteractor, |
| 42 | KeyguardQuickAffordancePickerViewModel.Factory |
| 43 | keyguardQuickAffordancePickerViewModelFactory) { |
| 44 | mKeyguardQuickAffordancePickerInteractor = keyguardQuickAffordancePickerInteractor; |
| 45 | mKeyguardQuickAffordancePickerViewModelFactory = |
| 46 | keyguardQuickAffordancePickerViewModelFactory; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public List<CustomizationSectionController<?>> getSectionControllersForScreen( |
| 51 | Screen screen, |
| 52 | FragmentActivity activity, |
| 53 | LifecycleOwner lifecycleOwner, |
| 54 | WallpaperColorsViewModel wallpaperColorsViewModel, |
| 55 | WorkspaceViewModel workspaceViewModel, |
| 56 | PermissionRequester permissionRequester, |
| 57 | WallpaperPreviewNavigator wallpaperPreviewNavigator, |
| 58 | CustomizationSectionNavigationController sectionNavigationController, |
Alejandro Nijamkin | 2fe5f2d | 2022-12-22 15:24:22 -0800 | [diff] [blame^] | 59 | @Nullable Bundle savedInstanceState, |
| 60 | CurrentWallpaperInfoFactory wallpaperInfoFactory) { |
Alejandro Nijamkin | 0eb2cc2 | 2022-12-19 10:55:57 -0800 | [diff] [blame] | 61 | List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>(); |
| 62 | |
| 63 | // Wallpaper section. |
Alejandro Nijamkin | 2fe5f2d | 2022-12-22 15:24:22 -0800 | [diff] [blame^] | 64 | sectionControllers.add( |
| 65 | new ScreenPreviewSectionController( |
| 66 | activity, |
| 67 | lifecycleOwner, |
| 68 | screen, |
| 69 | wallpaperInfoFactory, |
| 70 | wallpaperColorsViewModel)); |
Alejandro Nijamkin | 0eb2cc2 | 2022-12-19 10:55:57 -0800 | [diff] [blame] | 71 | |
| 72 | // Theme color section. |
| 73 | sectionControllers.add(new ColorSectionController( |
| 74 | activity, wallpaperColorsViewModel, lifecycleOwner, savedInstanceState)); |
| 75 | |
| 76 | switch (screen) { |
| 77 | case LOCK_SCREEN: |
| 78 | // Lock screen quick affordances section. |
| 79 | sectionControllers.add( |
| 80 | new KeyguardQuickAffordanceSectionController( |
| 81 | sectionNavigationController, |
| 82 | mKeyguardQuickAffordancePickerInteractor, |
| 83 | new ViewModelProvider( |
| 84 | activity, |
| 85 | mKeyguardQuickAffordancePickerViewModelFactory) |
| 86 | .get(KeyguardQuickAffordancePickerViewModel.class), |
| 87 | lifecycleOwner)); |
| 88 | break; |
| 89 | |
| 90 | case HOME_SCREEN: |
| 91 | // Dark/Light theme section. |
| 92 | sectionControllers.add(new DarkModeSectionController(activity, |
| 93 | lifecycleOwner.getLifecycle())); |
| 94 | |
| 95 | // Themed app icon section. |
| 96 | sectionControllers.add(new ThemedIconSectionController( |
| 97 | ThemedIconSwitchProvider.getInstance(activity), workspaceViewModel, |
| 98 | savedInstanceState)); |
| 99 | |
| 100 | // App grid section. |
| 101 | sectionControllers.add(new GridSectionController( |
| 102 | GridOptionsManager.getInstance(activity), sectionNavigationController)); |
| 103 | break; |
| 104 | } |
| 105 | |
| 106 | return sectionControllers; |
| 107 | } |
| 108 | |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 109 | @Override |
Alejandro Nijamkin | abda67b | 2022-11-30 14:34:56 -0800 | [diff] [blame] | 110 | public List<CustomizationSectionController<?>> getAllSectionControllers( |
| 111 | FragmentActivity activity, |
| 112 | LifecycleOwner lifecycleOwner, |
| 113 | WallpaperColorsViewModel wallpaperColorsViewModel, |
| 114 | WorkspaceViewModel workspaceViewModel, |
| 115 | PermissionRequester permissionRequester, |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 116 | WallpaperPreviewNavigator wallpaperPreviewNavigator, |
Chihhang Chuang | 8d14e8a | 2021-06-15 14:03:18 +0800 | [diff] [blame] | 117 | CustomizationSectionNavigationController sectionNavigationController, |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 118 | @Nullable Bundle savedInstanceState) { |
Chihhang Chuang | 8d14e8a | 2021-06-15 14:03:18 +0800 | [diff] [blame] | 119 | List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>(); |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 120 | |
| 121 | // Wallpaper section. |
| 122 | sectionControllers.add(new WallpaperSectionController( |
| 123 | activity, lifecycleOwner, permissionRequester, wallpaperColorsViewModel, |
Chihhang Chuang | 8d14e8a | 2021-06-15 14:03:18 +0800 | [diff] [blame] | 124 | workspaceViewModel, sectionNavigationController, wallpaperPreviewNavigator, |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 125 | savedInstanceState)); |
| 126 | |
Kunhung Li | 7b10d5b | 2022-07-06 16:19:47 +0800 | [diff] [blame] | 127 | // Theme color section. |
| 128 | sectionControllers.add(new ColorSectionController( |
| 129 | activity, wallpaperColorsViewModel, lifecycleOwner, savedInstanceState)); |
| 130 | |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 131 | // Dark/Light theme section. |
Chihhang Chuang | 8d14e8a | 2021-06-15 14:03:18 +0800 | [diff] [blame] | 132 | sectionControllers.add(new DarkModeSectionController(activity, |
| 133 | lifecycleOwner.getLifecycle())); |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 134 | |
| 135 | // Themed app icon section. |
| 136 | sectionControllers.add(new ThemedIconSectionController( |
Ching-Sung Li | 3f62f8a | 2021-06-30 15:37:48 +0800 | [diff] [blame] | 137 | ThemedIconSwitchProvider.getInstance(activity), workspaceViewModel, |
| 138 | savedInstanceState)); |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 139 | |
| 140 | // App grid section. |
| 141 | sectionControllers.add(new GridSectionController( |
Chihhang Chuang | 8d14e8a | 2021-06-15 14:03:18 +0800 | [diff] [blame] | 142 | GridOptionsManager.getInstance(activity), sectionNavigationController)); |
Chihhang Chuang | 1473ab0 | 2021-06-10 10:49:38 +0800 | [diff] [blame] | 143 | |
| 144 | return sectionControllers; |
| 145 | } |
| 146 | } |