Merge "Update custom clock string" into main
diff --git a/res/layout/customization_option_entry_color_contrast.xml b/res/layout/customization_option_entry_color_contrast.xml
new file mode 100644
index 0000000..4d005dc
--- /dev/null
+++ b/res/layout/customization_option_entry_color_contrast.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<androidx.constraintlayout.widget.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingHorizontal="@dimen/customization_option_entry_horizontal_padding"
+ android:paddingVertical="@dimen/customization_option_entry_vertical_padding"
+ android:clickable="true">
+
+ <TextView
+ android:id="@+id/option_entry_color_contrast_title"
+ style="@style/CustomizationOptionEntryTitleTextStyle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:text="@string/color_contrast_section_title"
+ android:layout_marginEnd="@dimen/customization_option_entry_text_margin_end"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/option_entry_color_contrast_icon_container"
+ app:layout_constraintBottom_toTopOf="@+id/option_entry_color_contrast_description"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_chainStyle="packed" />
+
+ <TextView
+ android:id="@+id/option_entry_color_contrast_description"
+ style="@style/CustomizationOptionEntrySubtitleTextStyle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="@dimen/customization_option_entry_text_margin_end"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/option_entry_color_contrast_icon_container"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/option_entry_color_contrast_title" />
+
+ <FrameLayout
+ android:id="@+id/option_entry_color_contrast_icon_container"
+ android:layout_width="@dimen/customization_option_entry_icon_size"
+ android:layout_height="@dimen/customization_option_entry_icon_size"
+ android:padding="@dimen/customization_option_entry_icon_padding"
+ android:background="@drawable/customization_option_entry_icon_background"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent">
+
+ <ImageView
+ android:id="@+id/option_entry_color_contrast_icon"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:contentDescription="@string/grid_preview_card_content_description" />
+ </FrameLayout>
+</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/res/layout/customization_option_entry_colors.xml b/res/layout/customization_option_entry_colors.xml
index 2709cf9..1011fcb 100644
--- a/res/layout/customization_option_entry_colors.xml
+++ b/res/layout/customization_option_entry_colors.xml
@@ -27,7 +27,7 @@
style="@style/CustomizationOptionEntryTitleTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:text="@string/color_picker_title"
+ android:text="@string/system_colors_title"
android:layout_marginEnd="@dimen/customization_option_entry_text_margin_end"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/option_entry_colors_icon_container"
diff --git a/res/layout/floating_sheet_clock_style_content.xml b/res/layout/floating_sheet_clock_style_content.xml
index 5b39776..582ad4f 100644
--- a/res/layout/floating_sheet_clock_style_content.xml
+++ b/res/layout/floating_sheet_clock_style_content.xml
@@ -80,7 +80,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/floating_sheet_content_horizontal_padding"
android:layout_marginEnd="@dimen/floating_sheet_clock_style_clock_size_text_margin_end"
- android:text="@string/clock_size_dynamic_description"
+ android:text="@string/clock_size_large_description"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/clock_style_clock_size_switch"
app:layout_constraintTop_toBottomOf="@+id/clock_style_clock_size_title"
diff --git a/res/layout/themed_icon_section_view.xml b/res/layout/themed_icon_section_view.xml
index b6e745b..e58517d 100644
--- a/res/layout/themed_icon_section_view.xml
+++ b/res/layout/themed_icon_section_view.xml
@@ -49,5 +49,20 @@
android:minHeight="0dp"
style="@style/Switch.SettingsLib"/>
+
</LinearLayout>
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="8dp" />
+
+ <TextView
+ android:id="@+id/beta_tag"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingHorizontal="8dp"
+ android:paddingVertical="4dp"
+ android:text="@string/beta_title"
+ android:textColor="@color/text_color_on_accent"
+ style="@style/BetaTagTextStyle" />
</com.android.customization.picker.themedicon.ThemedIconSectionView>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fa64eae..1b284bc 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -90,6 +90,9 @@
<!-- Title of a radio button to apply clock size large. [CHAR LIMIT=15] -->
<string name="clock_size_large">Large</string>
+ <!-- Description for toggling on large clock on the lock screen -->
+ <string name="clock_size_large_description">Shown when notifications aren\'t visible</string>
+
<!-- Title of a radio button to apply clock size small. [CHAR LIMIT=15] -->
<string name="clock_size_small">Small</string>
@@ -370,6 +373,13 @@
<string name="color_picker_title">System colors</string>
<!--
+ Title for a customization picker section where the user can configure the system colors by
+ selecting from a list of color options.
+ [CHAR LIMIT=32].
+ -->
+ <string name="system_colors_title">Colors</string>
+
+ <!--
Name of the slot on the "start" side of the bottom of the lock screen, where lock screen
shortcuts can be added to the lock screen. In left-to-right languages, this is the left-hand
side button. In right-to-left languages, this is the right-hand side button. [CHAR LIMIT=16].
@@ -487,7 +497,7 @@
[CHAR LIMIT=32].
-->
- <string name="more_settings_section_title">More lock screen options</string>
+ <string name="more_settings_section_title">More lock screen settings</string>
<!--
Summary for a setting that lets the user access additional settings related to lock screen
diff --git a/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt
index f62471d..60925bf 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt
@@ -55,6 +55,7 @@
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
@@ -74,6 +75,7 @@
lifecycleOwner: LifecycleOwner,
navigateToWallpaperCategoriesScreen: (screen: Screen) -> Unit,
navigateToMoreLockScreenSettingsActivity: () -> Unit,
+ navigateToColorContrastSettingsActivity: () -> Unit,
) {
defaultCustomizationOptionsBinder.bind(
view,
@@ -85,54 +87,59 @@
lifecycleOwner,
navigateToWallpaperCategoriesScreen,
navigateToMoreLockScreenSettingsActivity,
+ navigateToColorContrastSettingsActivity,
)
- val optionClock =
+ val optionClock: View =
lockScreenCustomizationOptionEntries
- .find { it.first == ThemePickerLockCustomizationOption.CLOCK }
- ?.second
- val optionClockIcon = optionClock?.findViewById<ImageView>(R.id.option_entry_clock_icon)
+ .first { it.first == ThemePickerLockCustomizationOption.CLOCK }
+ .second
+ val optionClockIcon: ImageView = optionClock.requireViewById(R.id.option_entry_clock_icon)
- val optionShortcut =
+ val optionShortcut: View =
lockScreenCustomizationOptionEntries
- .find { it.first == ThemePickerLockCustomizationOption.SHORTCUTS }
- ?.second
- val optionShortcutDescription =
- optionShortcut?.findViewById<TextView>(
- R.id.option_entry_keyguard_quick_affordance_description
- )
- val optionShortcutIcon1 =
- optionShortcut?.findViewById<ImageView>(
- R.id.option_entry_keyguard_quick_affordance_icon_1
- )
- val optionShortcutIcon2 =
- optionShortcut?.findViewById<ImageView>(
- R.id.option_entry_keyguard_quick_affordance_icon_2
- )
+ .first { it.first == ThemePickerLockCustomizationOption.SHORTCUTS }
+ .second
+ val optionShortcutDescription: TextView =
+ optionShortcut.requireViewById(R.id.option_entry_keyguard_quick_affordance_description)
+ val optionShortcutIcon1: ImageView =
+ optionShortcut.requireViewById(R.id.option_entry_keyguard_quick_affordance_icon_1)
+ val optionShortcutIcon2: ImageView =
+ optionShortcut.requireViewById(R.id.option_entry_keyguard_quick_affordance_icon_2)
- val optionMoreLockScreenSettings =
+ val optionMoreLockScreenSettings: View =
lockScreenCustomizationOptionEntries
- .find { it.first == ThemePickerLockCustomizationOption.MORE_LOCK_SCREEN_SETTINGS }
- ?.second
- optionMoreLockScreenSettings?.setOnClickListener {
+ .first { it.first == ThemePickerLockCustomizationOption.MORE_LOCK_SCREEN_SETTINGS }
+ .second
+ optionMoreLockScreenSettings.setOnClickListener {
navigateToMoreLockScreenSettingsActivity.invoke()
}
- val optionColors =
+ val optionColors: View =
homeScreenCustomizationOptionEntries
- .find { it.first == ThemePickerHomeCustomizationOption.COLORS }
- ?.second
- val optionColorsIcon =
- optionColors?.findViewById<ColorOptionIconView2>(R.id.option_entry_colors_icon)
+ .first { it.first == ThemePickerHomeCustomizationOption.COLORS }
+ .second
+ val optionColorsIcon: ColorOptionIconView2 =
+ optionColors.requireViewById(R.id.option_entry_colors_icon)
- val optionShapeGrid =
+ val optionShapeGrid: View =
homeScreenCustomizationOptionEntries
- .find { it.first == ThemePickerHomeCustomizationOption.APP_SHAPE_GRID }
- ?.second
- val optionShapeGridDescription =
- optionShapeGrid?.findViewById<TextView>(R.id.option_entry_app_shape_grid_description)
- val optionShapeGridIcon =
- optionShapeGrid?.findViewById<ImageView>(R.id.option_entry_app_shape_grid_icon)
+ .first { it.first == ThemePickerHomeCustomizationOption.APP_SHAPE_GRID }
+ .second
+ val optionShapeGridDescription: TextView =
+ optionShapeGrid.requireViewById(R.id.option_entry_app_shape_grid_description)
+ val optionShapeGridIcon: ImageView =
+ optionShapeGrid.requireViewById(R.id.option_entry_app_shape_grid_icon)
+
+ val optionColorContrast: View =
+ homeScreenCustomizationOptionEntries
+ .first { it.first == ThemePickerHomeCustomizationOption.COLOR_CONTRAST }
+ .second
+ optionColorContrast.setOnClickListener { navigateToColorContrastSettingsActivity.invoke() }
+ val optionColorContrastDescription: TextView =
+ optionColorContrast.requireViewById(R.id.option_entry_color_contrast_description)
+ val optionColorContrastIcon: ImageView =
+ optionColorContrast.requireViewById(R.id.option_entry_color_contrast_icon)
val optionsViewModel =
viewModel.customizationOptionsViewModel as ThemePickerCustomizationOptionsViewModel
@@ -140,66 +147,67 @@
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
launch {
optionsViewModel.onCustomizeClockClicked.collect {
- optionClock?.setOnClickListener { _ -> it?.invoke() }
+ optionClock.setOnClickListener { _ -> it?.invoke() }
}
}
launch {
optionsViewModel.clockPickerViewModel.selectedClock.collect {
- optionClockIcon?.setImageDrawable(it.thumbnail)
+ optionClockIcon.setImageDrawable(it.thumbnail)
}
}
launch {
optionsViewModel.onCustomizeShortcutClicked.collect {
- optionShortcut?.setOnClickListener { _ -> it?.invoke() }
+ optionShortcut.setOnClickListener { _ -> it?.invoke() }
}
}
launch {
optionsViewModel.keyguardQuickAffordancePickerViewModel2.summary.collect {
summary ->
- optionShortcutDescription?.let {
+ optionShortcutDescription.let {
TextViewBinder.bind(view = it, viewModel = summary.description)
}
summary.icon1?.let { icon ->
- optionShortcutIcon1?.let {
+ optionShortcutIcon1.let {
IconViewBinder.bind(view = it, viewModel = icon)
}
}
- optionShortcutIcon1?.isVisible = summary.icon1 != null
+ optionShortcutIcon1.isVisible = summary.icon1 != null
summary.icon2?.let { icon ->
- optionShortcutIcon2?.let {
+ optionShortcutIcon2.let {
IconViewBinder.bind(view = it, viewModel = icon)
}
}
- optionShortcutIcon2?.isVisible = summary.icon2 != null
+ optionShortcutIcon2.isVisible = summary.icon2 != null
}
}
launch {
optionsViewModel.onCustomizeColorsClicked.collect {
- optionColors?.setOnClickListener { _ -> it?.invoke() }
+ optionColors.setOnClickListener { _ -> it?.invoke() }
}
}
launch {
optionsViewModel.onCustomizeShapeGridClicked.collect {
- optionShapeGrid?.setOnClickListener { _ -> it?.invoke() }
+ optionShapeGrid.setOnClickListener { _ -> it?.invoke() }
}
}
launch {
optionsViewModel.shapeGridPickerViewModel.selectedGridOption.collect {
gridOption ->
- optionShapeGridDescription?.let { TextViewBinder.bind(it, gridOption.text) }
+ TextViewBinder.bind(optionShapeGridDescription, gridOption.text)
gridOption.payload?.let { gridIconViewModel ->
- optionShapeGridIcon?.let {
- GridIconViewBinder.bind(view = it, viewModel = gridIconViewModel)
- }
+ GridIconViewBinder.bind(
+ view = optionShapeGridIcon,
+ viewModel = gridIconViewModel,
+ )
// TODO(b/363018910): Use ColorUpdateBinder to update color
- optionShapeGridIcon?.setColorFilter(
+ optionShapeGridIcon.setColorFilter(
ContextCompat.getColor(
view.context,
com.android.wallpaper.R.color.system_on_surface_variant,
@@ -210,17 +218,28 @@
}
launch {
+ optionsViewModel.colorContrastSectionViewModel.summary.collectLatest { summary
+ ->
+ TextViewBinder.bind(
+ view = optionColorContrastDescription,
+ viewModel = summary.description,
+ )
+ summary.icon?.let {
+ IconViewBinder.bind(view = optionColorContrastIcon, viewModel = it)
+ }
+ optionColorContrastIcon.isVisible = summary.icon != null
+ }
+ }
+
+ 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,
- )
- }
+ ColorOptionIconBinder2.bind(
+ view = optionColorsIcon,
+ viewModel = ColorOptionIconViewModel.fromColorOption(colorOption),
+ darkTheme = view.resources.configuration.isNightModeActive,
+ )
}
}
}
diff --git a/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt
index 17888fc..9974b96 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt
@@ -169,7 +169,7 @@
viewModel.selectedOption.collect {
val stringResId =
when (it) {
- COLORS -> ThemePickerR.string.color_picker_title
+ COLORS -> ThemePickerR.string.system_colors_title
APP_SHAPE_GRID -> ThemePickerR.string.shape_and_grid_title
CLOCK -> ThemePickerR.string.clock_title
SHORTCUTS ->
diff --git a/src/com/android/wallpaper/customization/ui/util/ThemePickerCustomizationOptionUtil.kt b/src/com/android/wallpaper/customization/ui/util/ThemePickerCustomizationOptionUtil.kt
index 6006327..16d53f3 100644
--- a/src/com/android/wallpaper/customization/ui/util/ThemePickerCustomizationOptionUtil.kt
+++ b/src/com/android/wallpaper/customization/ui/util/ThemePickerCustomizationOptionUtil.kt
@@ -49,8 +49,9 @@
enum class ThemePickerHomeCustomizationOption : CustomizationOptionUtil.CustomizationOption {
COLORS,
- APP_SHAPE_GRID,
THEMED_ICONS,
+ APP_SHAPE_GRID,
+ COLOR_CONTRAST,
}
override fun getOptionEntries(
@@ -109,6 +110,14 @@
)
)
add(
+ ThemePickerHomeCustomizationOption.THEMED_ICONS to
+ layoutInflater.inflate(
+ R.layout.customization_option_entry_themed_icons,
+ optionContainer,
+ false,
+ )
+ )
+ add(
ThemePickerHomeCustomizationOption.APP_SHAPE_GRID to
layoutInflater.inflate(
R.layout.customization_option_entry_app_shape_grid,
@@ -117,9 +126,9 @@
)
)
add(
- ThemePickerHomeCustomizationOption.THEMED_ICONS to
+ ThemePickerHomeCustomizationOption.COLOR_CONTRAST to
layoutInflater.inflate(
- R.layout.customization_option_entry_themed_icons,
+ R.layout.customization_option_entry_color_contrast,
optionContainer,
false,
)
diff --git a/src/com/android/wallpaper/customization/ui/viewmodel/ColorContrastSectionViewModel2.kt b/src/com/android/wallpaper/customization/ui/viewmodel/ColorContrastSectionViewModel2.kt
new file mode 100644
index 0000000..7ac0053
--- /dev/null
+++ b/src/com/android/wallpaper/customization/ui/viewmodel/ColorContrastSectionViewModel2.kt
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.wallpaper.customization.ui.viewmodel
+
+import android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_HIGH
+import android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_MEDIUM
+import android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_STANDARD
+import android.util.Log
+import com.android.customization.picker.settings.domain.interactor.ColorContrastSectionInteractor
+import com.android.customization.picker.settings.ui.viewmodel.ColorContrastSectionDataViewModel
+import com.android.themepicker.R
+import com.android.wallpaper.picker.common.icon.ui.viewmodel.Icon
+import com.android.wallpaper.picker.common.text.ui.viewmodel.Text
+import dagger.hilt.android.scopes.ViewModelScoped
+import javax.inject.Inject
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.map
+
+@ViewModelScoped
+class ColorContrastSectionViewModel2
+@Inject
+constructor(colorContrastSectionInteractor: ColorContrastSectionInteractor) {
+
+ val summary: Flow<ColorContrastSectionDataViewModel> =
+ colorContrastSectionInteractor.contrast.map { contrastValue ->
+ when (contrastValue) {
+ CONTRAST_LEVEL_STANDARD ->
+ ColorContrastSectionDataViewModel(
+ Text.Resource(R.string.color_contrast_default_title),
+ Icon.Resource(
+ res = R.drawable.ic_contrast_standard,
+ contentDescription = null,
+ ),
+ )
+ CONTRAST_LEVEL_MEDIUM ->
+ ColorContrastSectionDataViewModel(
+ Text.Resource(R.string.color_contrast_medium_title),
+ Icon.Resource(
+ res = R.drawable.ic_contrast_medium,
+ contentDescription = null,
+ ),
+ )
+ CONTRAST_LEVEL_HIGH ->
+ ColorContrastSectionDataViewModel(
+ Text.Resource(R.string.color_contrast_high_title),
+ Icon.Resource(res = R.drawable.ic_contrast_high, contentDescription = null),
+ )
+ else -> {
+ Log.e(TAG, "Invalid contrast value: $contrastValue")
+ throw IllegalArgumentException("Invalid contrast value: $contrastValue")
+ }
+ }
+ }
+
+ companion object {
+ private const val TAG = "ColorContrastSectionViewModel2"
+ }
+}
diff --git a/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt b/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt
index f29be47..4832e1d 100644
--- a/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt
+++ b/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt
@@ -46,6 +46,7 @@
colorPickerViewModel2Factory: ColorPickerViewModel2.Factory,
clockPickerViewModelFactory: ClockPickerViewModel.Factory,
shapeGridPickerViewModelFactory: ShapeGridPickerViewModel.Factory,
+ val colorContrastSectionViewModel: ColorContrastSectionViewModel2,
val darkModeViewModel: DarkModeViewModel,
@Assisted private val viewModelScope: CoroutineScope,
) : CustomizationOptionsViewModel {