Loading src/com/android/customization/model/grid/ui/fragment/GridFragment2.kt +18 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,10 @@ import com.android.customization.model.grid.ui.viewmodel.GridScreenViewModel import com.android.customization.module.ThemePickerInjector import com.android.wallpaper.R import com.android.wallpaper.module.CurrentWallpaperInfoFactory import com.android.wallpaper.module.CustomizationSections import com.android.wallpaper.module.InjectorProvider import com.android.wallpaper.picker.AppbarFragment import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor import com.android.wallpaper.picker.customization.ui.binder.ScreenPreviewBinder import com.android.wallpaper.picker.customization.ui.viewmodel.ScreenPreviewViewModel import com.android.wallpaper.util.PreviewUtils Loading @@ -55,7 +57,12 @@ class GridFragment2 : AppbarFragment() { val injector = InjectorProvider.getInjector() as ThemePickerInjector val wallpaperInfoFactory = injector.getCurrentWallpaperInfoFactory(requireContext()) var screenPreviewBinding = bindScreenPreview(view, wallpaperInfoFactory) var screenPreviewBinding = bindScreenPreview( view, wallpaperInfoFactory, injector.getWallpaperInteractor(requireContext()) ) val viewModelFactory = injector.getGridScreenViewModelFactory(requireContext()) GridScreenBinder.bind( Loading @@ -69,7 +76,12 @@ class GridFragment2 : AppbarFragment() { backgroundDispatcher = Dispatchers.IO, onOptionsChanged = { screenPreviewBinding.destroy() screenPreviewBinding = bindScreenPreview(view, wallpaperInfoFactory) screenPreviewBinding = bindScreenPreview( view, wallpaperInfoFactory, injector.getWallpaperInteractor(requireContext()) ) } ) Loading @@ -83,6 +95,7 @@ class GridFragment2 : AppbarFragment() { private fun bindScreenPreview( view: View, wallpaperInfoFactory: CurrentWallpaperInfoFactory, wallpaperInteractor: WallpaperInteractor, ): ScreenPreviewBinder.Binding { return ScreenPreviewBinder.bind( activity = requireActivity(), Loading @@ -108,9 +121,12 @@ class GridFragment2 : AppbarFragment() { ) } }, wallpaperInteractor = wallpaperInteractor, ), lifecycleOwner = this, offsetToStart = false, screen = CustomizationSections.Screen.HOME_SCREEN, onPreviewDirty = { activity?.recreate() }, ) } } src/com/android/customization/module/DefaultCustomizationSections.java +7 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.wallpaper.model.WallpaperPreviewNavigator; import com.android.wallpaper.model.WallpaperSectionController; 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.ConnectedSectionController; import com.android.wallpaper.picker.customization.ui.section.ScreenPreviewSectionController; import com.android.wallpaper.picker.customization.ui.section.WallpaperQuickSwitchSectionController; Loading Loading @@ -97,7 +98,8 @@ public final class DefaultCustomizationSections implements CustomizationSections @Nullable Bundle savedInstanceState, CurrentWallpaperInfoFactory wallpaperInfoFactory, DisplayUtils displayUtils, WallpaperQuickSwitchViewModel wallpaperQuickSwitchViewModel) { WallpaperQuickSwitchViewModel wallpaperQuickSwitchViewModel, WallpaperInteractor wallpaperInteractor) { List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>(); // Wallpaper section. Loading @@ -112,7 +114,8 @@ public final class DefaultCustomizationSections implements CustomizationSections displayUtils, mClockCarouselViewModel, mClockViewFactory, sectionNavigationController) sectionNavigationController, wallpaperInteractor) : new ScreenPreviewSectionController( activity, lifecycleOwner, Loading @@ -120,7 +123,8 @@ public final class DefaultCustomizationSections implements CustomizationSections wallpaperInfoFactory, wallpaperColorsViewModel, displayUtils, sectionNavigationController)); sectionNavigationController, wallpaperInteractor)); sectionControllers.add( new ConnectedSectionController( Loading src/com/android/customization/module/ThemePickerInjector.kt +39 −1 Original line number Diff line number Diff line Loading @@ -21,10 +21,13 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.os.Bundle import android.text.TextUtils import androidx.activity.ComponentActivity import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import androidx.lifecycle.ViewModelProvider import com.android.customization.model.color.ColorCustomizationManager import com.android.customization.model.color.ColorOptionsProvider import com.android.customization.model.grid.GridOptionsManager import com.android.customization.model.grid.data.repository.GridRepositoryImpl import com.android.customization.model.grid.domain.interactor.GridInteractor Loading Loading @@ -72,6 +75,9 @@ import com.android.wallpaper.picker.CustomizationPickerActivity import com.android.wallpaper.picker.ImagePreviewFragment import com.android.wallpaper.picker.LivePreviewFragment import com.android.wallpaper.picker.PreviewFragment import com.android.wallpaper.picker.customization.data.content.WallpaperClientImpl import com.android.wallpaper.picker.customization.data.repository.WallpaperRepository import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers Loading @@ -82,6 +88,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject private var customizationSections: CustomizationSections? = null private var userEventLogger: UserEventLogger? = null private var prefs: WallpaperPreferences? = null private var wallpaperInteractor: WallpaperInteractor? = null private var keyguardQuickAffordancePickerInteractor: KeyguardQuickAffordancePickerInteractor? = null private var keyguardQuickAffordancePickerViewModelFactory: Loading @@ -102,6 +109,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject private var colorPickerInteractor: ColorPickerInteractor? = null private var colorPickerViewModelFactory: ColorPickerViewModel.Factory? = null private var colorPickerSnapshotRestorer: ColorPickerSnapshotRestorer? = null private var colorCustomizationManager: ColorCustomizationManager? = null private var darkModeSnapshotRestorer: DarkModeSnapshotRestorer? = null private var themedIconSnapshotRestorer: ThemedIconSnapshotRestorer? = null private var themedIconInteractor: ThemedIconInteractor? = null Loading Loading @@ -209,6 +217,25 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject return ThemeManager(provider, activity, overlayManagerCompat, logger) } override fun getWallpaperInteractor(context: Context): WallpaperInteractor { return wallpaperInteractor ?: WallpaperInteractor( repository = WallpaperRepository( scope = GlobalScope, client = WallpaperClientImpl(context = context), backgroundDispatcher = Dispatchers.IO, ), shouldHandleReload = { TextUtils.equals( getColorCustomizationManager(context).currentColorSource, ColorOptionsProvider.COLOR_SOURCE_PRESET ) } ) .also { wallpaperInteractor = it } } override fun getKeyguardQuickAffordancePickerInteractor( context: Context ): KeyguardQuickAffordancePickerInteractor { Loading Loading @@ -352,7 +379,11 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject ): ColorPickerInteractor { return colorPickerInteractor ?: ColorPickerInteractor( repository = ColorPickerRepositoryImpl(context, wallpaperColorsViewModel), repository = ColorPickerRepositoryImpl( wallpaperColorsViewModel, getColorCustomizationManager(context) ), snapshotRestorer = { getColorPickerSnapshotRestorer(context, wallpaperColorsViewModel) } Loading Loading @@ -383,6 +414,13 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject .also { colorPickerSnapshotRestorer = it } } private fun getColorCustomizationManager(context: Context): ColorCustomizationManager { return colorCustomizationManager ?: ColorCustomizationManager.getInstance(context, OverlayManagerCompat(context)).also { colorCustomizationManager = it } } fun getDarkModeSnapshotRestorer( context: Context, ): DarkModeSnapshotRestorer { Loading src/com/android/customization/picker/color/data/repository/ColorPickerRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -34,4 +34,7 @@ interface ColorPickerRepository { /** Returns the current selected color option based on system settings */ fun getCurrentColorOption(): ColorOptionModel /** Returns the current selected color source based on system settings */ fun getCurrentColorSource(): String? } src/com/android/customization/picker/color/data/repository/ColorPickerRepositoryImpl.kt +5 −5 Original line number Diff line number Diff line Loading @@ -17,14 +17,12 @@ package com.android.customization.picker.color.data.repository import android.app.WallpaperColors import android.content.Context import android.util.Log import com.android.customization.model.CustomizationManager import com.android.customization.model.color.ColorBundle import com.android.customization.model.color.ColorCustomizationManager import com.android.customization.model.color.ColorOption import com.android.customization.model.color.ColorSeedOption import com.android.customization.model.theme.OverlayManagerCompat import com.android.customization.picker.color.shared.model.ColorOptionModel import com.android.customization.picker.color.shared.model.ColorType import com.android.systemui.monet.Style Loading @@ -38,16 +36,14 @@ import kotlinx.coroutines.suspendCancellableCoroutine // TODO (b/262924623): refactor to remove dependency on ColorCustomizationManager & ColorOption // TODO (b/268203200): Create test for ColorPickerRepositoryImpl class ColorPickerRepositoryImpl( context: Context, wallpaperColorsViewModel: WallpaperColorsViewModel, private val colorManager: ColorCustomizationManager, ) : ColorPickerRepository { private val homeWallpaperColors: StateFlow<WallpaperColors?> = wallpaperColorsViewModel.homeWallpaperColors private val lockWallpaperColors: StateFlow<WallpaperColors?> = wallpaperColorsViewModel.lockWallpaperColors private val colorManager: ColorCustomizationManager = ColorCustomizationManager.getInstance(context, OverlayManagerCompat(context)) override val colorOptions: Flow<Map<ColorType, List<ColorOptionModel>>> = combine(homeWallpaperColors, lockWallpaperColors) { homeColors, lockColors -> Loading Loading @@ -132,6 +128,10 @@ class ColorPickerRepositoryImpl( ) } override fun getCurrentColorSource(): String? { return colorManager.currentColorSource } private fun ColorOption.toModel(): ColorOptionModel { return ColorOptionModel( key = "${this.style}::${this.serializedPackages}", Loading Loading
src/com/android/customization/model/grid/ui/fragment/GridFragment2.kt +18 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,10 @@ import com.android.customization.model.grid.ui.viewmodel.GridScreenViewModel import com.android.customization.module.ThemePickerInjector import com.android.wallpaper.R import com.android.wallpaper.module.CurrentWallpaperInfoFactory import com.android.wallpaper.module.CustomizationSections import com.android.wallpaper.module.InjectorProvider import com.android.wallpaper.picker.AppbarFragment import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor import com.android.wallpaper.picker.customization.ui.binder.ScreenPreviewBinder import com.android.wallpaper.picker.customization.ui.viewmodel.ScreenPreviewViewModel import com.android.wallpaper.util.PreviewUtils Loading @@ -55,7 +57,12 @@ class GridFragment2 : AppbarFragment() { val injector = InjectorProvider.getInjector() as ThemePickerInjector val wallpaperInfoFactory = injector.getCurrentWallpaperInfoFactory(requireContext()) var screenPreviewBinding = bindScreenPreview(view, wallpaperInfoFactory) var screenPreviewBinding = bindScreenPreview( view, wallpaperInfoFactory, injector.getWallpaperInteractor(requireContext()) ) val viewModelFactory = injector.getGridScreenViewModelFactory(requireContext()) GridScreenBinder.bind( Loading @@ -69,7 +76,12 @@ class GridFragment2 : AppbarFragment() { backgroundDispatcher = Dispatchers.IO, onOptionsChanged = { screenPreviewBinding.destroy() screenPreviewBinding = bindScreenPreview(view, wallpaperInfoFactory) screenPreviewBinding = bindScreenPreview( view, wallpaperInfoFactory, injector.getWallpaperInteractor(requireContext()) ) } ) Loading @@ -83,6 +95,7 @@ class GridFragment2 : AppbarFragment() { private fun bindScreenPreview( view: View, wallpaperInfoFactory: CurrentWallpaperInfoFactory, wallpaperInteractor: WallpaperInteractor, ): ScreenPreviewBinder.Binding { return ScreenPreviewBinder.bind( activity = requireActivity(), Loading @@ -108,9 +121,12 @@ class GridFragment2 : AppbarFragment() { ) } }, wallpaperInteractor = wallpaperInteractor, ), lifecycleOwner = this, offsetToStart = false, screen = CustomizationSections.Screen.HOME_SCREEN, onPreviewDirty = { activity?.recreate() }, ) } }
src/com/android/customization/module/DefaultCustomizationSections.java +7 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.wallpaper.model.WallpaperPreviewNavigator; import com.android.wallpaper.model.WallpaperSectionController; 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.ConnectedSectionController; import com.android.wallpaper.picker.customization.ui.section.ScreenPreviewSectionController; import com.android.wallpaper.picker.customization.ui.section.WallpaperQuickSwitchSectionController; Loading Loading @@ -97,7 +98,8 @@ public final class DefaultCustomizationSections implements CustomizationSections @Nullable Bundle savedInstanceState, CurrentWallpaperInfoFactory wallpaperInfoFactory, DisplayUtils displayUtils, WallpaperQuickSwitchViewModel wallpaperQuickSwitchViewModel) { WallpaperQuickSwitchViewModel wallpaperQuickSwitchViewModel, WallpaperInteractor wallpaperInteractor) { List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>(); // Wallpaper section. Loading @@ -112,7 +114,8 @@ public final class DefaultCustomizationSections implements CustomizationSections displayUtils, mClockCarouselViewModel, mClockViewFactory, sectionNavigationController) sectionNavigationController, wallpaperInteractor) : new ScreenPreviewSectionController( activity, lifecycleOwner, Loading @@ -120,7 +123,8 @@ public final class DefaultCustomizationSections implements CustomizationSections wallpaperInfoFactory, wallpaperColorsViewModel, displayUtils, sectionNavigationController)); sectionNavigationController, wallpaperInteractor)); sectionControllers.add( new ConnectedSectionController( Loading
src/com/android/customization/module/ThemePickerInjector.kt +39 −1 Original line number Diff line number Diff line Loading @@ -21,10 +21,13 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.os.Bundle import android.text.TextUtils import androidx.activity.ComponentActivity import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import androidx.lifecycle.ViewModelProvider import com.android.customization.model.color.ColorCustomizationManager import com.android.customization.model.color.ColorOptionsProvider import com.android.customization.model.grid.GridOptionsManager import com.android.customization.model.grid.data.repository.GridRepositoryImpl import com.android.customization.model.grid.domain.interactor.GridInteractor Loading Loading @@ -72,6 +75,9 @@ import com.android.wallpaper.picker.CustomizationPickerActivity import com.android.wallpaper.picker.ImagePreviewFragment import com.android.wallpaper.picker.LivePreviewFragment import com.android.wallpaper.picker.PreviewFragment import com.android.wallpaper.picker.customization.data.content.WallpaperClientImpl import com.android.wallpaper.picker.customization.data.repository.WallpaperRepository import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor import com.android.wallpaper.picker.undo.domain.interactor.SnapshotRestorer import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers Loading @@ -82,6 +88,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject private var customizationSections: CustomizationSections? = null private var userEventLogger: UserEventLogger? = null private var prefs: WallpaperPreferences? = null private var wallpaperInteractor: WallpaperInteractor? = null private var keyguardQuickAffordancePickerInteractor: KeyguardQuickAffordancePickerInteractor? = null private var keyguardQuickAffordancePickerViewModelFactory: Loading @@ -102,6 +109,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject private var colorPickerInteractor: ColorPickerInteractor? = null private var colorPickerViewModelFactory: ColorPickerViewModel.Factory? = null private var colorPickerSnapshotRestorer: ColorPickerSnapshotRestorer? = null private var colorCustomizationManager: ColorCustomizationManager? = null private var darkModeSnapshotRestorer: DarkModeSnapshotRestorer? = null private var themedIconSnapshotRestorer: ThemedIconSnapshotRestorer? = null private var themedIconInteractor: ThemedIconInteractor? = null Loading Loading @@ -209,6 +217,25 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject return ThemeManager(provider, activity, overlayManagerCompat, logger) } override fun getWallpaperInteractor(context: Context): WallpaperInteractor { return wallpaperInteractor ?: WallpaperInteractor( repository = WallpaperRepository( scope = GlobalScope, client = WallpaperClientImpl(context = context), backgroundDispatcher = Dispatchers.IO, ), shouldHandleReload = { TextUtils.equals( getColorCustomizationManager(context).currentColorSource, ColorOptionsProvider.COLOR_SOURCE_PRESET ) } ) .also { wallpaperInteractor = it } } override fun getKeyguardQuickAffordancePickerInteractor( context: Context ): KeyguardQuickAffordancePickerInteractor { Loading Loading @@ -352,7 +379,11 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject ): ColorPickerInteractor { return colorPickerInteractor ?: ColorPickerInteractor( repository = ColorPickerRepositoryImpl(context, wallpaperColorsViewModel), repository = ColorPickerRepositoryImpl( wallpaperColorsViewModel, getColorCustomizationManager(context) ), snapshotRestorer = { getColorPickerSnapshotRestorer(context, wallpaperColorsViewModel) } Loading Loading @@ -383,6 +414,13 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject .also { colorPickerSnapshotRestorer = it } } private fun getColorCustomizationManager(context: Context): ColorCustomizationManager { return colorCustomizationManager ?: ColorCustomizationManager.getInstance(context, OverlayManagerCompat(context)).also { colorCustomizationManager = it } } fun getDarkModeSnapshotRestorer( context: Context, ): DarkModeSnapshotRestorer { Loading
src/com/android/customization/picker/color/data/repository/ColorPickerRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -34,4 +34,7 @@ interface ColorPickerRepository { /** Returns the current selected color option based on system settings */ fun getCurrentColorOption(): ColorOptionModel /** Returns the current selected color source based on system settings */ fun getCurrentColorSource(): String? }
src/com/android/customization/picker/color/data/repository/ColorPickerRepositoryImpl.kt +5 −5 Original line number Diff line number Diff line Loading @@ -17,14 +17,12 @@ package com.android.customization.picker.color.data.repository import android.app.WallpaperColors import android.content.Context import android.util.Log import com.android.customization.model.CustomizationManager import com.android.customization.model.color.ColorBundle import com.android.customization.model.color.ColorCustomizationManager import com.android.customization.model.color.ColorOption import com.android.customization.model.color.ColorSeedOption import com.android.customization.model.theme.OverlayManagerCompat import com.android.customization.picker.color.shared.model.ColorOptionModel import com.android.customization.picker.color.shared.model.ColorType import com.android.systemui.monet.Style Loading @@ -38,16 +36,14 @@ import kotlinx.coroutines.suspendCancellableCoroutine // TODO (b/262924623): refactor to remove dependency on ColorCustomizationManager & ColorOption // TODO (b/268203200): Create test for ColorPickerRepositoryImpl class ColorPickerRepositoryImpl( context: Context, wallpaperColorsViewModel: WallpaperColorsViewModel, private val colorManager: ColorCustomizationManager, ) : ColorPickerRepository { private val homeWallpaperColors: StateFlow<WallpaperColors?> = wallpaperColorsViewModel.homeWallpaperColors private val lockWallpaperColors: StateFlow<WallpaperColors?> = wallpaperColorsViewModel.lockWallpaperColors private val colorManager: ColorCustomizationManager = ColorCustomizationManager.getInstance(context, OverlayManagerCompat(context)) override val colorOptions: Flow<Map<ColorType, List<ColorOptionModel>>> = combine(homeWallpaperColors, lockWallpaperColors) { homeColors, lockColors -> Loading Loading @@ -132,6 +128,10 @@ class ColorPickerRepositoryImpl( ) } override fun getCurrentColorSource(): String? { return colorManager.currentColorSource } private fun ColorOption.toModel(): ColorOptionModel { return ColorOptionModel( key = "${this.style}::${this.serializedPackages}", Loading