Merge "Navigate to more lock screen settings (2/2)" into main
diff --git a/res/layout/customization_option_entry_colors.xml b/res/layout/customization_option_entry_colors.xml
index 3046173..2709cf9 100644
--- a/res/layout/customization_option_entry_colors.xml
+++ b/res/layout/customization_option_entry_colors.xml
@@ -30,18 +30,25 @@
android:text="@string/color_picker_title"
android:layout_marginEnd="@dimen/customization_option_entry_text_margin_end"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toStartOf="@+id/option_entry_clock_icon"
+ app:layout_constraintEnd_toStartOf="@+id/option_entry_colors_icon_container"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<FrameLayout
- android:id="@+id/option_entry_clock_icon"
+ android:id="@+id/option_entry_colors_icon_container"
android:layout_width="@dimen/customization_option_entry_icon_size"
android:layout_height="@dimen/customization_option_entry_icon_size"
android:orientation="horizontal"
android:background="@drawable/customization_option_entry_icon_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintBottom_toBottomOf="parent" />
+ app:layout_constraintBottom_toBottomOf="parent">
+
+ <com.android.customization.picker.color.ui.view.ColorOptionIconView2
+ android:id="@+id/option_entry_colors_icon"
+ android:layout_width="@dimen/customization_option_entry_color_icon_size"
+ android:layout_height="@dimen/customization_option_entry_color_icon_size"
+ android:layout_gravity="center"/>
+ </FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 4f1062f..be1e071 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -205,6 +205,7 @@
<dimen name="floating_sheet_color_option_stroke_width">3dp</dimen>
<dimen name="customization_option_entry_shortcut_icon_size">20dp</dimen>
<dimen name="customization_option_entry_clock_icon_size">44dp</dimen>
+ <dimen name="customization_option_entry_color_icon_size">48dp</dimen>
<!-- Clock font control dimensions -->
<dimen name="clock_font_axis_name_width">64dp</dimen>
diff --git a/src/com/android/customization/picker/color/ui/viewmodel/ColorOptionIconViewModel.kt b/src/com/android/customization/picker/color/ui/viewmodel/ColorOptionIconViewModel.kt
index 8723c8c..6181c17 100644
--- a/src/com/android/customization/picker/color/ui/viewmodel/ColorOptionIconViewModel.kt
+++ b/src/com/android/customization/picker/color/ui/viewmodel/ColorOptionIconViewModel.kt
@@ -18,6 +18,7 @@
package com.android.customization.picker.color.ui.viewmodel
import android.annotation.ColorInt
+import com.android.customization.model.color.ColorOptionImpl
data class ColorOptionIconViewModel(
@ColorInt val lightThemeColor0: Int,
@@ -28,4 +29,21 @@
@ColorInt val darkThemeColor1: Int,
@ColorInt val darkThemeColor2: Int,
@ColorInt val darkThemeColor3: Int,
-)
+) {
+ companion object {
+ fun fromColorOption(colorOption: ColorOptionImpl): ColorOptionIconViewModel {
+ val lightThemeColors = colorOption.previewInfo.resolveColors(/* darkTheme= */ false)
+ val darkThemeColors = colorOption.previewInfo.resolveColors(/* darkTheme= */ true)
+ return ColorOptionIconViewModel(
+ lightThemeColor0 = lightThemeColors[0],
+ lightThemeColor1 = lightThemeColors[1],
+ lightThemeColor2 = lightThemeColors[2],
+ lightThemeColor3 = lightThemeColors[3],
+ darkThemeColor0 = darkThemeColors[0],
+ darkThemeColor1 = darkThemeColors[1],
+ darkThemeColor2 = darkThemeColors[2],
+ darkThemeColor3 = darkThemeColors[3],
+ )
+ }
+ }
+}
diff --git a/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt
index d1cc3cf..f62471d 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt
@@ -28,10 +28,14 @@
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
+import com.android.customization.model.color.ColorOptionImpl
import com.android.customization.picker.clock.shared.ClockSize
import com.android.customization.picker.clock.ui.view.ClockConstraintLayoutHostView
import com.android.customization.picker.clock.ui.view.ClockConstraintLayoutHostView.Companion.addClockViews
import com.android.customization.picker.clock.ui.view.ClockViewFactory
+import com.android.customization.picker.color.ui.binder.ColorOptionIconBinder2
+import com.android.customization.picker.color.ui.view.ColorOptionIconView2
+import com.android.customization.picker.color.ui.viewmodel.ColorOptionIconViewModel
import com.android.customization.picker.grid.ui.binder.GridIconViewBinder
import com.android.systemui.plugins.clocks.ClockFontAxisSetting
import com.android.systemui.plugins.clocks.ClockPreviewConfig
@@ -118,6 +122,8 @@
homeScreenCustomizationOptionEntries
.find { it.first == ThemePickerHomeCustomizationOption.COLORS }
?.second
+ val optionColorsIcon =
+ optionColors?.findViewById<ColorOptionIconView2>(R.id.option_entry_colors_icon)
val optionShapeGrid =
homeScreenCustomizationOptionEntries
@@ -202,6 +208,22 @@
}
}
}
+
+ launch {
+ optionsViewModel.colorPickerViewModel2.selectedColorOption.collect { colorOption
+ ->
+ (colorOption as? ColorOptionImpl)?.let {
+ optionColorsIcon?.let {
+ ColorOptionIconBinder2.bind(
+ view = it,
+ viewModel =
+ ColorOptionIconViewModel.fromColorOption(colorOption),
+ darkTheme = view.resources.configuration.isNightModeActive,
+ )
+ }
+ }
+ }
+ }
}
}
diff --git a/src/com/android/wallpaper/customization/ui/viewmodel/ColorPickerViewModel2.kt b/src/com/android/wallpaper/customization/ui/viewmodel/ColorPickerViewModel2.kt
index 02af6a6..1a68f4e 100644
--- a/src/com/android/wallpaper/customization/ui/viewmodel/ColorPickerViewModel2.kt
+++ b/src/com/android/wallpaper/customization/ui/viewmodel/ColorPickerViewModel2.kt
@@ -17,7 +17,6 @@
package com.android.wallpaper.customization.ui.viewmodel
import android.content.Context
-import androidx.lifecycle.viewModelScope
import com.android.customization.model.color.ColorOption
import com.android.customization.model.color.ColorOptionImpl
import com.android.customization.module.logging.ThemesUserEventLogger
@@ -56,6 +55,7 @@
private val logger: ThemesUserEventLogger,
@Assisted private val viewModelScope: CoroutineScope,
) {
+ val selectedColorOption = interactor.selectedColorOption
private val overridingColorOption = MutableStateFlow<ColorOption?>(null)
val previewingColorOption = overridingColorOption.asStateFlow()
@@ -120,12 +120,8 @@
colorOptionEntry.key to
colorOptionEntry.value.map { colorOption ->
colorOption as ColorOptionImpl
- val lightThemeColors =
- colorOption.previewInfo.resolveColors(/* darkTheme= */ false)
- val darkThemeColors =
- colorOption.previewInfo.resolveColors(/* darkTheme= */ true)
val isSelectedFlow: StateFlow<Boolean> =
- combine(previewingColorOption, interactor.selectedColorOption) {
+ combine(previewingColorOption, selectedColorOption) {
previewing,
selected ->
previewing?.isEquivalent(colorOption)
@@ -137,17 +133,7 @@
"${colorOption.type}::${colorOption.style}::${colorOption.serializedPackages}"
OptionItemViewModel2<ColorOptionIconViewModel>(
key = MutableStateFlow(key) as StateFlow<String>,
- payload =
- ColorOptionIconViewModel(
- lightThemeColor0 = lightThemeColors[0],
- lightThemeColor1 = lightThemeColors[1],
- lightThemeColor2 = lightThemeColors[2],
- lightThemeColor3 = lightThemeColors[3],
- darkThemeColor0 = darkThemeColors[0],
- darkThemeColor1 = darkThemeColors[1],
- darkThemeColor2 = darkThemeColors[2],
- darkThemeColor3 = darkThemeColors[3],
- ),
+ payload = ColorOptionIconViewModel.fromColorOption(colorOption),
text =
Text.Loaded(
colorOption.getContentDescription(context).toString()
@@ -177,7 +163,7 @@
* change updates, which are applied with a latency.
*/
val onApply: Flow<(suspend () -> Unit)?> =
- combine(previewingColorOption, interactor.selectedColorOption) { previewing, selected ->
+ combine(previewingColorOption, selectedColorOption) { previewing, selected ->
previewing?.let {
if (previewing.isEquivalent(selected)) {
null
diff --git a/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt b/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt
index a474212..3d52f86 100644
--- a/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt
+++ b/tests/common/src/com/android/customization/testing/TestCustomizationInjector.kt
@@ -22,7 +22,9 @@
import com.android.wallpaper.picker.category.wrapper.WallpaperCategoryWrapper
import com.android.wallpaper.picker.customization.data.repository.WallpaperColorsRepository
import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor
+import com.android.wallpaper.testing.FakeCurrentWallpaperInfoFactory
import com.android.wallpaper.testing.FakeWallpaperClient
+import com.android.wallpaper.testing.FakeWallpaperRefresher
import com.android.wallpaper.testing.TestInjector
import com.android.wallpaper.testing.TestPackageStatusNotifier
import com.android.wallpaper.util.DisplayUtils
@@ -43,7 +45,9 @@
injectedWallpaperInteractor: WallpaperInteractor,
prefs: WallpaperPreferences,
private val fakeWallpaperCategoryWrapper: WallpaperCategoryWrapper,
- private val testStatusNotifier: TestPackageStatusNotifier,
+ testStatusNotifier: TestPackageStatusNotifier,
+ currentWallpaperInfoFactory: FakeCurrentWallpaperInfoFactory,
+ wallpaperRefresher: FakeWallpaperRefresher,
) :
TestInjector(
themesUserEventLogger,
@@ -56,6 +60,8 @@
prefs,
fakeWallpaperCategoryWrapper,
testStatusNotifier,
+ currentWallpaperInfoFactory,
+ wallpaperRefresher,
),
CustomizationInjector {
/////////////////
diff --git a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
index 36a723c..da8ed5f 100644
--- a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
@@ -35,7 +35,6 @@
import com.android.wallpaper.module.InjectorProvider
import com.android.wallpaper.module.NetworkStatusNotifier
import com.android.wallpaper.module.PartnerProvider
-import com.android.wallpaper.module.WallpaperPreferences
import com.android.wallpaper.network.Requester
import com.android.wallpaper.picker.category.wrapper.WallpaperCategoryWrapper
import com.android.wallpaper.picker.common.icon.ui.viewmodel.Icon
@@ -43,8 +42,9 @@
import com.android.wallpaper.picker.customization.data.repository.WallpaperRepository
import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor
import com.android.wallpaper.picker.option.ui.viewmodel.OptionItemViewModel
+import com.android.wallpaper.testing.FakeCurrentWallpaperInfoFactory
import com.android.wallpaper.testing.FakeWallpaperClient
-import com.android.wallpaper.testing.TestCurrentWallpaperInfoFactory
+import com.android.wallpaper.testing.FakeWallpaperRefresher
import com.android.wallpaper.testing.TestInjector
import com.android.wallpaper.testing.TestPackageStatusNotifier
import com.android.wallpaper.testing.TestWallpaperPreferences
@@ -90,6 +90,9 @@
testScope = TestScope(testDispatcher)
Dispatchers.setMain(testDispatcher)
client = FakeCustomizationProviderClient()
+ val prefs = TestWallpaperPreferences()
+ val refresher = FakeWallpaperRefresher(prefs)
+ val wallpaperInfoFactory = FakeCurrentWallpaperInfoFactory(refresher)
quickAffordanceInteractor =
KeyguardQuickAffordancePickerInteractor(
@@ -107,7 +110,7 @@
WallpaperRepository(
scope = testScope.backgroundScope,
client = FakeWallpaperClient(),
- wallpaperPreferences = TestWallpaperPreferences(),
+ wallpaperPreferences = prefs,
backgroundDispatcher = testDispatcher,
)
)
@@ -121,9 +124,11 @@
mock(PartnerProvider::class.java),
FakeWallpaperClient(),
wallpaperInteractor,
- mock(WallpaperPreferences::class.java),
+ prefs,
mock(WallpaperCategoryWrapper::class.java),
testPackageStatusNotifier,
+ wallpaperInfoFactory,
+ refresher,
)
)
underTest =
@@ -131,7 +136,7 @@
context = context,
quickAffordanceInteractor = quickAffordanceInteractor,
wallpaperInteractor = wallpaperInteractor,
- wallpaperInfoFactory = TestCurrentWallpaperInfoFactory(context),
+ wallpaperInfoFactory = wallpaperInfoFactory,
logger = logger,
)
.create(KeyguardQuickAffordancePickerViewModel::class.java)