Loading src/com/android/customization/module/DefaultCustomizationSections.java +7 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import com.android.customization.model.themedicon.domain.interactor.ThemedIconIn import com.android.customization.model.themedicon.domain.interactor.ThemedIconSnapshotRestorer; import com.android.customization.picker.clock.ui.view.ClockViewFactory; import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselViewModel; import com.android.customization.picker.color.domain.interactor.ColorPickerInteractor; import com.android.customization.picker.color.ui.section.ColorSectionController2; import com.android.customization.picker.color.ui.viewmodel.ColorPickerViewModel; import com.android.customization.picker.notifications.ui.section.NotificationSectionController; Loading Loading @@ -61,6 +62,7 @@ public final class DefaultCustomizationSections implements CustomizationSections private final DarkModeSnapshotRestorer mDarkModeSnapshotRestorer; private final ThemedIconSnapshotRestorer mThemedIconSnapshotRestorer; private final ThemedIconInteractor mThemedIconInteractor; private final ColorPickerInteractor mColorPickerInteractor; public DefaultCustomizationSections( ColorPickerViewModel.Factory colorPickerViewModelFactory, Loading @@ -73,7 +75,8 @@ public final class DefaultCustomizationSections implements CustomizationSections ClockViewFactory clockViewFactory, DarkModeSnapshotRestorer darkModeSnapshotRestorer, ThemedIconSnapshotRestorer themedIconSnapshotRestorer, ThemedIconInteractor themedIconInteractor) { ThemedIconInteractor themedIconInteractor, ColorPickerInteractor colorPickerInteractor) { mColorPickerViewModelFactory = colorPickerViewModelFactory; mKeyguardQuickAffordancePickerInteractor = keyguardQuickAffordancePickerInteractor; mKeyguardQuickAffordancePickerViewModelFactory = Loading @@ -85,6 +88,7 @@ public final class DefaultCustomizationSections implements CustomizationSections mDarkModeSnapshotRestorer = darkModeSnapshotRestorer; mThemedIconSnapshotRestorer = themedIconSnapshotRestorer; mThemedIconInteractor = themedIconInteractor; mColorPickerInteractor = colorPickerInteractor; } @Override Loading Loading @@ -121,6 +125,7 @@ public final class DefaultCustomizationSections implements CustomizationSections sectionNavigationController, wallpaperInteractor, mThemedIconInteractor, mColorPickerInteractor, wallpaperManager, isTwoPaneAndSmallWidth, customizationPickerViewModel) Loading @@ -134,6 +139,7 @@ public final class DefaultCustomizationSections implements CustomizationSections wallpaperPreviewNavigator, wallpaperInteractor, mThemedIconInteractor, mColorPickerInteractor, wallpaperManager, isTwoPaneAndSmallWidth, customizationPickerViewModel)); Loading src/com/android/customization/module/ThemePickerInjector.kt +1 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,7 @@ internal constructor( getDarkModeSnapshotRestorer(activity), getThemedIconSnapshotRestorer(activity), getThemedIconInteractor(), getColorPickerInteractor(activity, getWallpaperColorsViewModel()), ) .also { customizationSections = it } } Loading src/com/android/customization/picker/color/data/repository/ColorPickerRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -19,12 +19,15 @@ package com.android.customization.picker.color.data.repository import com.android.customization.picker.color.shared.model.ColorOptionModel import com.android.customization.picker.color.shared.model.ColorType import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow /** * Abstracts access to application state related to functionality for selecting, picking, or setting * system color. */ interface ColorPickerRepository { /** Whether the system color is in the process of being updated */ val isApplyingSystemColor: StateFlow<Boolean> /** List of wallpaper and preset color options on the device, categorized by Color Type */ val colorOptions: Flow<Map<ColorType, List<ColorOptionModel>>> Loading src/com/android/customization/picker/color/data/repository/ColorPickerRepositoryImpl.kt +17 −2 Original line number Diff line number Diff line Loading @@ -27,7 +27,9 @@ import com.android.systemui.monet.Style import com.android.wallpaper.model.WallpaperColorsModel import com.android.wallpaper.model.WallpaperColorsViewModel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map import kotlinx.coroutines.suspendCancellableCoroutine Loading @@ -43,9 +45,17 @@ class ColorPickerRepositoryImpl( wallpaperColorsViewModel.homeWallpaperColors private val lockWallpaperColors: StateFlow<WallpaperColorsModel?> = wallpaperColorsViewModel.lockWallpaperColors private var selectedColorOption: MutableStateFlow<ColorOptionModel> = MutableStateFlow(getCurrentColorOption()) private val _isApplyingSystemColor = MutableStateFlow(false) override val isApplyingSystemColor = _isApplyingSystemColor.asStateFlow() override val colorOptions: Flow<Map<ColorType, List<ColorOptionModel>>> = combine(homeWallpaperColors, lockWallpaperColors) { homeColors, lockColors -> combine(homeWallpaperColors, lockWallpaperColors, selectedColorOption) { homeColors, lockColors, _ -> homeColors to lockColors } .map { (homeColors, lockColors) -> Loading Loading @@ -109,17 +119,21 @@ class ColorPickerRepositoryImpl( } } override suspend fun select(colorOptionModel: ColorOptionModel) = override suspend fun select(colorOptionModel: ColorOptionModel) { _isApplyingSystemColor.value = true suspendCancellableCoroutine { continuation -> colorManager.apply( colorOptionModel.colorOption, object : CustomizationManager.Callback { override fun onSuccess() { _isApplyingSystemColor.value = false selectedColorOption.value = colorOptionModel continuation.resumeWith(Result.success(Unit)) } override fun onError(throwable: Throwable?) { Log.w(TAG, "Apply theme with error", throwable) _isApplyingSystemColor.value = false continuation.resumeWith( Result.failure(throwable ?: Throwable("Error loading theme bundles")) ) Loading @@ -127,6 +141,7 @@ class ColorPickerRepositoryImpl( } ) } } override fun getCurrentColorOption(): ColorOptionModel { val overlays = colorManager.currentOverlays Loading src/com/android/customization/picker/color/data/repository/FakeColorPickerRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,9 @@ import kotlinx.coroutines.flow.asStateFlow class FakeColorPickerRepository(private val context: Context) : ColorPickerRepository { private val _isApplyingSystemColor = MutableStateFlow(false) override val isApplyingSystemColor = _isApplyingSystemColor.asStateFlow() private lateinit var selectedColorOption: ColorOptionModel private val _colorOptions = Loading Loading
src/com/android/customization/module/DefaultCustomizationSections.java +7 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import com.android.customization.model.themedicon.domain.interactor.ThemedIconIn import com.android.customization.model.themedicon.domain.interactor.ThemedIconSnapshotRestorer; import com.android.customization.picker.clock.ui.view.ClockViewFactory; import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselViewModel; import com.android.customization.picker.color.domain.interactor.ColorPickerInteractor; import com.android.customization.picker.color.ui.section.ColorSectionController2; import com.android.customization.picker.color.ui.viewmodel.ColorPickerViewModel; import com.android.customization.picker.notifications.ui.section.NotificationSectionController; Loading Loading @@ -61,6 +62,7 @@ public final class DefaultCustomizationSections implements CustomizationSections private final DarkModeSnapshotRestorer mDarkModeSnapshotRestorer; private final ThemedIconSnapshotRestorer mThemedIconSnapshotRestorer; private final ThemedIconInteractor mThemedIconInteractor; private final ColorPickerInteractor mColorPickerInteractor; public DefaultCustomizationSections( ColorPickerViewModel.Factory colorPickerViewModelFactory, Loading @@ -73,7 +75,8 @@ public final class DefaultCustomizationSections implements CustomizationSections ClockViewFactory clockViewFactory, DarkModeSnapshotRestorer darkModeSnapshotRestorer, ThemedIconSnapshotRestorer themedIconSnapshotRestorer, ThemedIconInteractor themedIconInteractor) { ThemedIconInteractor themedIconInteractor, ColorPickerInteractor colorPickerInteractor) { mColorPickerViewModelFactory = colorPickerViewModelFactory; mKeyguardQuickAffordancePickerInteractor = keyguardQuickAffordancePickerInteractor; mKeyguardQuickAffordancePickerViewModelFactory = Loading @@ -85,6 +88,7 @@ public final class DefaultCustomizationSections implements CustomizationSections mDarkModeSnapshotRestorer = darkModeSnapshotRestorer; mThemedIconSnapshotRestorer = themedIconSnapshotRestorer; mThemedIconInteractor = themedIconInteractor; mColorPickerInteractor = colorPickerInteractor; } @Override Loading Loading @@ -121,6 +125,7 @@ public final class DefaultCustomizationSections implements CustomizationSections sectionNavigationController, wallpaperInteractor, mThemedIconInteractor, mColorPickerInteractor, wallpaperManager, isTwoPaneAndSmallWidth, customizationPickerViewModel) Loading @@ -134,6 +139,7 @@ public final class DefaultCustomizationSections implements CustomizationSections wallpaperPreviewNavigator, wallpaperInteractor, mThemedIconInteractor, mColorPickerInteractor, wallpaperManager, isTwoPaneAndSmallWidth, customizationPickerViewModel)); Loading
src/com/android/customization/module/ThemePickerInjector.kt +1 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,7 @@ internal constructor( getDarkModeSnapshotRestorer(activity), getThemedIconSnapshotRestorer(activity), getThemedIconInteractor(), getColorPickerInteractor(activity, getWallpaperColorsViewModel()), ) .also { customizationSections = it } } Loading
src/com/android/customization/picker/color/data/repository/ColorPickerRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -19,12 +19,15 @@ package com.android.customization.picker.color.data.repository import com.android.customization.picker.color.shared.model.ColorOptionModel import com.android.customization.picker.color.shared.model.ColorType import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow /** * Abstracts access to application state related to functionality for selecting, picking, or setting * system color. */ interface ColorPickerRepository { /** Whether the system color is in the process of being updated */ val isApplyingSystemColor: StateFlow<Boolean> /** List of wallpaper and preset color options on the device, categorized by Color Type */ val colorOptions: Flow<Map<ColorType, List<ColorOptionModel>>> Loading
src/com/android/customization/picker/color/data/repository/ColorPickerRepositoryImpl.kt +17 −2 Original line number Diff line number Diff line Loading @@ -27,7 +27,9 @@ import com.android.systemui.monet.Style import com.android.wallpaper.model.WallpaperColorsModel import com.android.wallpaper.model.WallpaperColorsViewModel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map import kotlinx.coroutines.suspendCancellableCoroutine Loading @@ -43,9 +45,17 @@ class ColorPickerRepositoryImpl( wallpaperColorsViewModel.homeWallpaperColors private val lockWallpaperColors: StateFlow<WallpaperColorsModel?> = wallpaperColorsViewModel.lockWallpaperColors private var selectedColorOption: MutableStateFlow<ColorOptionModel> = MutableStateFlow(getCurrentColorOption()) private val _isApplyingSystemColor = MutableStateFlow(false) override val isApplyingSystemColor = _isApplyingSystemColor.asStateFlow() override val colorOptions: Flow<Map<ColorType, List<ColorOptionModel>>> = combine(homeWallpaperColors, lockWallpaperColors) { homeColors, lockColors -> combine(homeWallpaperColors, lockWallpaperColors, selectedColorOption) { homeColors, lockColors, _ -> homeColors to lockColors } .map { (homeColors, lockColors) -> Loading Loading @@ -109,17 +119,21 @@ class ColorPickerRepositoryImpl( } } override suspend fun select(colorOptionModel: ColorOptionModel) = override suspend fun select(colorOptionModel: ColorOptionModel) { _isApplyingSystemColor.value = true suspendCancellableCoroutine { continuation -> colorManager.apply( colorOptionModel.colorOption, object : CustomizationManager.Callback { override fun onSuccess() { _isApplyingSystemColor.value = false selectedColorOption.value = colorOptionModel continuation.resumeWith(Result.success(Unit)) } override fun onError(throwable: Throwable?) { Log.w(TAG, "Apply theme with error", throwable) _isApplyingSystemColor.value = false continuation.resumeWith( Result.failure(throwable ?: Throwable("Error loading theme bundles")) ) Loading @@ -127,6 +141,7 @@ class ColorPickerRepositoryImpl( } ) } } override fun getCurrentColorOption(): ColorOptionModel { val overlays = colorManager.currentOverlays Loading
src/com/android/customization/picker/color/data/repository/FakeColorPickerRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,9 @@ import kotlinx.coroutines.flow.asStateFlow class FakeColorPickerRepository(private val context: Context) : ColorPickerRepository { private val _isApplyingSystemColor = MutableStateFlow(false) override val isApplyingSystemColor = _isApplyingSystemColor.asStateFlow() private lateinit var selectedColorOption: ColorOptionModel private val _colorOptions = Loading