Add clock edit entry point to clock list
Bug: 364675294
Test: Manual, presubmits
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: I46c2e20585ca6f3ba6b4b051d8859da634b4b79a
diff --git a/res/drawable/edit_icon.xml b/res/drawable/edit_icon.xml
new file mode 100644
index 0000000..9690d17
--- /dev/null
+++ b/res/drawable/edit_icon.xml
@@ -0,0 +1,20 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48">
+ <group>
+ <clip-path
+ android:pathData="M8,24C8,15.163 15.163,8 24,8C32.837,8 40,15.163 40,24C40,32.837 32.837,40 24,40C15.163,40 8,32.837 8,24Z"/>
+ <path
+ android:pathData="M8,24C8,15.163 15.163,8 24,8C32.837,8 40,15.163 40,24C40,32.837 32.837,40 24,40C15.163,40 8,32.837 8,24Z"
+ android:fillColor="@color/system_on_primary_fixed_variant"/>
+ <group>
+ <clip-path
+ android:pathData="M14,14h20v20h-20z"/>
+ <path
+ android:pathData="M17,31V27.813L27.375,17.438C27.528,17.285 27.694,17.174 27.875,17.104C28.056,17.035 28.243,17 28.438,17C28.632,17 28.819,17.035 29,17.104C29.181,17.174 29.347,17.285 29.5,17.438L30.563,18.5C30.715,18.653 30.826,18.819 30.896,19C30.965,19.181 31,19.368 31,19.563C31,19.757 30.965,19.944 30.896,20.125C30.826,20.306 30.715,20.472 30.563,20.625L20.188,31H17ZM28.438,20.625L29.5,19.563L28.438,18.5L27.375,19.563L28.438,20.625Z"
+ android:fillColor="#ffffff"/>
+ </group>
+ </group>
+</vector>
diff --git a/res/layout/clock_style_option.xml b/res/layout/clock_style_option.xml
index fd72e85..27fe597 100644
--- a/res/layout/clock_style_option.xml
+++ b/res/layout/clock_style_option.xml
@@ -17,7 +17,8 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/floating_sheet_clock_style_option_size"
- android:layout_height="@dimen/floating_sheet_clock_style_option_size">
+ android:layout_height="@dimen/floating_sheet_clock_style_option_size"
+ android:clipChildren="false">
<ImageView
android:id="@id/selection_border"
@@ -34,10 +35,26 @@
android:background="@drawable/option_item_background"
android:importantForAccessibility="no" />
- <ImageView
+ <FrameLayout
android:id="@+id/foreground"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_margin="@dimen/floating_sheet_clock_style_thumbnail_margin" />
+ android:layout_height="match_parent">
+
+ <ImageView
+ android:id="@+id/clock_icon"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_margin="@dimen/floating_sheet_clock_style_thumbnail_margin"
+ android:src="@drawable/ic_clock_24px" />
+
+ <ImageView
+ android:id="@+id/edit_icon"
+ android:layout_width="@dimen/floating_sheet_clock_edit_icon_size"
+ android:layout_height="@dimen/floating_sheet_clock_edit_icon_size"
+ android:layout_marginTop="-16dp"
+ android:layout_marginLeft="50dp"
+ android:src="@drawable/edit_icon"/>
+
+ </FrameLayout>
</FrameLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 36743db..fe06735 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -188,6 +188,7 @@
<dimen name="floating_sheet_list_item_horizontal_space">4dp</dimen>
<dimen name="floating_sheet_list_item_vertical_space">4dp</dimen>
<dimen name="floating_sheet_clock_style_option_size">82dp</dimen>
+ <dimen name="floating_sheet_clock_edit_icon_size">48dp</dimen>
<dimen name="floating_sheet_clock_style_thumbnail_margin">12dp</dimen>
<dimen name="floating_sheet_clock_style_clock_size_text_margin_end">16dp</dimen>
<dimen name="customization_option_entry_shortcut_icon_size">20dp</dimen>
diff --git a/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt b/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
index c0a1446..f3a2301 100644
--- a/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
+++ b/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
@@ -70,6 +70,7 @@
description = clockConfig.description,
thumbnail = clockConfig.thumbnail,
isReactiveToTone = clockConfig.isReactiveToTone,
+ hasReactiveAxes = !clockConfig.axes.isEmpty(),
)
} else {
null
@@ -115,6 +116,7 @@
description = it.description,
thumbnail = it.thumbnail,
isReactiveToTone = it.isReactiveToTone,
+ hasReactiveAxes = !it.axes.isEmpty(),
selectedColorId = metadata?.getSelectedColorId(),
colorTone =
metadata?.getColorTone()
@@ -174,11 +176,7 @@
.map { setting -> setting == 1 }
.map { isDynamic -> if (isDynamic) ClockSize.DYNAMIC else ClockSize.SMALL }
.distinctUntilChanged()
- .shareIn(
- scope = mainScope,
- started = SharingStarted.Eagerly,
- replay = 1,
- )
+ .shareIn(scope = mainScope, started = SharingStarted.Eagerly, replay = 1)
override suspend fun setClockSize(size: ClockSize) {
secureSettingsRepository.setInt(
@@ -198,7 +196,7 @@
private fun JSONObject.getColorTone(): Int {
return this.optInt(
KEY_METADATA_COLOR_TONE_PROGRESS,
- ClockMetadataModel.DEFAULT_COLOR_TONE_PROGRESS
+ ClockMetadataModel.DEFAULT_COLOR_TONE_PROGRESS,
)
}
@@ -208,6 +206,7 @@
description: String,
thumbnail: Drawable,
isReactiveToTone: Boolean,
+ hasReactiveAxes: Boolean,
selectedColorId: String? = null,
@IntRange(from = 0, to = 100) colorTone: Int = 0,
@ColorInt seedColor: Int? = null,
@@ -218,6 +217,7 @@
description = description,
thumbnail = thumbnail,
isReactiveToTone = isReactiveToTone,
+ hasReactiveAxes = hasReactiveAxes,
selectedColorId = selectedColorId,
colorToneProgress = colorTone,
seedColor = seedColor,
diff --git a/src/com/android/customization/picker/clock/shared/model/ClockMetadataModel.kt b/src/com/android/customization/picker/clock/shared/model/ClockMetadataModel.kt
index 3c8e725..ff8d85f 100644
--- a/src/com/android/customization/picker/clock/shared/model/ClockMetadataModel.kt
+++ b/src/com/android/customization/picker/clock/shared/model/ClockMetadataModel.kt
@@ -28,6 +28,7 @@
val description: String,
val thumbnail: Drawable,
val isReactiveToTone: Boolean,
+ val hasReactiveAxes: Boolean,
val selectedColorId: String?,
@IntRange(from = 0, to = 100) val colorToneProgress: Int,
@ColorInt val seedColor: Int?,
diff --git a/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
index 50b03ac..983b897 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
@@ -19,7 +19,6 @@
import android.animation.ValueAnimator
import android.content.Context
import android.content.res.Configuration
-import android.graphics.drawable.Drawable
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
@@ -41,6 +40,7 @@
import com.android.themepicker.R
import com.android.wallpaper.customization.ui.util.ThemePickerCustomizationOptionUtil.ThemePickerLockCustomizationOption.CLOCK
import com.android.wallpaper.customization.ui.viewmodel.ClockFloatingSheetHeightsViewModel
+import com.android.wallpaper.customization.ui.viewmodel.ClockPickerViewModel.ClockStyleModel
import com.android.wallpaper.customization.ui.viewmodel.ClockPickerViewModel.Tab.COLOR
import com.android.wallpaper.customization.ui.viewmodel.ClockPickerViewModel.Tab.STYLE
import com.android.wallpaper.customization.ui.viewmodel.ThemePickerCustomizationOptionsViewModel
@@ -223,30 +223,34 @@
private fun createClockStyleOptionItemAdapter(
lifecycleOwner: LifecycleOwner
- ): OptionItemAdapter<Drawable> =
+ ): OptionItemAdapter<ClockStyleModel> =
OptionItemAdapter(
layoutResourceId = R.layout.clock_style_option,
lifecycleOwner = lifecycleOwner,
- bindIcon = { foregroundView: View, drawable: Drawable ->
- (foregroundView as ImageView).setImageDrawable(drawable)
+ bindIcon = { view: View, style: ClockStyleModel ->
+ (view.findViewById(R.id.clock_icon) as ImageView).setImageDrawable(style.thumbnail)
+ (view.findViewById(R.id.edit_icon) as ImageView).setVisibility(
+ if (style.isEditable) View.VISIBLE else View.GONE
+ )
},
)
- private fun RecyclerView.initStyleList(context: Context, adapter: OptionItemAdapter<Drawable>) {
- apply {
- this.adapter = adapter
- layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
- addItemDecoration(
- SingleRowListItemSpacing(
- context.resources.getDimensionPixelSize(
- R.dimen.floating_sheet_content_horizontal_padding
- ),
- context.resources.getDimensionPixelSize(
- R.dimen.floating_sheet_list_item_horizontal_space
- ),
- )
+ private fun RecyclerView.initStyleList(
+ context: Context,
+ adapter: OptionItemAdapter<ClockStyleModel>,
+ ) {
+ this.adapter = adapter
+ layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
+ addItemDecoration(
+ SingleRowListItemSpacing(
+ context.resources.getDimensionPixelSize(
+ R.dimen.floating_sheet_content_horizontal_padding
+ ),
+ context.resources.getDimensionPixelSize(
+ R.dimen.floating_sheet_list_item_horizontal_space
+ ),
)
- }
+ )
}
private fun createClockColorOptionItemAdapter(
diff --git a/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModel.kt b/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModel.kt
index cf45678..504b766 100644
--- a/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModel.kt
+++ b/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModel.kt
@@ -114,8 +114,10 @@
overridingClock ?: selectedClock
}
+ data class ClockStyleModel(val thumbnail: Drawable, val isEditable: Boolean)
+
@OptIn(ExperimentalCoroutinesApi::class)
- val clockStyleOptions: StateFlow<List<OptionItemViewModel<Drawable>>> =
+ val clockStyleOptions: StateFlow<List<OptionItemViewModel<ClockStyleModel>>> =
clockPickerInteractor.allClocks
.mapLatest { allClocks ->
// Delay to avoid the case that the full list of clocks is not initiated.
@@ -130,9 +132,13 @@
R.string.select_clock_action_description,
clockModel.description,
)
- OptionItemViewModel<Drawable>(
+ OptionItemViewModel<ClockStyleModel>(
key = MutableStateFlow(clockModel.clockId) as StateFlow<String>,
- payload = clockModel.thumbnail,
+ payload =
+ ClockStyleModel(
+ clockModel.thumbnail,
+ isEditable = clockModel.hasReactiveAxes,
+ ),
text = Text.Loaded(contentDescription),
isTextUserVisible = false,
isSelected = isSelectedFlow,
diff --git a/tests/robotests/src/com/android/customization/picker/clock/data/repository/FakeClockPickerRepository.kt b/tests/robotests/src/com/android/customization/picker/clock/data/repository/FakeClockPickerRepository.kt
index f97feef..729241f 100644
--- a/tests/robotests/src/com/android/customization/picker/clock/data/repository/FakeClockPickerRepository.kt
+++ b/tests/robotests/src/com/android/customization/picker/clock/data/repository/FakeClockPickerRepository.kt
@@ -50,6 +50,7 @@
description = "description",
thumbnail = ColorDrawable(0),
isReactiveToTone = selectedClock.isReactiveToTone,
+ hasReactiveAxes = false,
selectedColorId = selectedColor,
colorToneProgress = colorTone,
seedColor = seedColor,
@@ -90,6 +91,7 @@
"description0",
ColorDrawable(0),
true,
+ false,
null,
50,
null,
@@ -100,6 +102,7 @@
"description1",
ColorDrawable(0),
true,
+ false,
null,
50,
null,
@@ -110,6 +113,7 @@
"description2",
ColorDrawable(0),
true,
+ false,
null,
50,
null,
@@ -120,6 +124,7 @@
"description3",
ColorDrawable(0),
false,
+ false,
null,
50,
null,
diff --git a/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt b/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
index be852ac..cf1cc55 100644
--- a/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/picker/clock/ui/viewmodel/ClockCarouselViewModelTest.kt
@@ -58,10 +58,11 @@
description = "description",
thumbnail = ColorDrawable(0),
isReactiveToTone = true,
+ hasReactiveAxes = false,
selectedColorId = null,
colorToneProgress = ClockMetadataModel.DEFAULT_COLOR_TONE_PROGRESS,
seedColor = null,
- ),
+ )
)
)
}