Merge "Add meaningful accessibility labels for color picker (1/2)" into udc-dev
diff --git a/res/layout/color_option_no_background.xml b/res/layout/color_option_no_background.xml
index 6bdbc15..3b8e2dc 100644
--- a/res/layout/color_option_no_background.xml
+++ b/res/layout/color_option_no_background.xml
@@ -52,5 +52,6 @@
         android:layout_height="match_parent"
         android:adjustViewBounds="true"
         android:src="@drawable/color_option_selected_no_background"
-        android:visibility="gone"/>
+        android:visibility="gone"
+        android:importantForAccessibility="no" />
 </androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/color_option_overflow_no_background.xml b/res/layout/color_option_overflow_no_background.xml
index fb25c35..abb9c6b 100644
--- a/res/layout/color_option_overflow_no_background.xml
+++ b/res/layout/color_option_overflow_no_background.xml
@@ -51,6 +51,7 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:adjustViewBounds="true"
-            android:src="@drawable/color_overflow" />
+            android:src="@drawable/color_overflow"
+            android:contentDescription="@string/more_colors"/>
     </androidx.constraintlayout.widget.ConstraintLayout>
 </androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1f71bd6..96ff1bf 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -456,6 +456,38 @@
     <string name="more_colors">More Colors</string>
 
     <!--
+    Accessibility string for a button that allows the user to select a color scheme generated from
+    their current wallpaper as the system color. This is shown in a list with other color options.
+
+    [CHAR LIMIT=NONE].
+    -->
+    <string name="content_description_dynamic_color_option">Primary dynamic theme</string>
+
+    <!--
+    Accessibility string for a button that allows the user to select a color scheme generated from
+    their current wallpaper as the system color. This is shown in a list with other color options.
+
+    [CHAR LIMIT=NONE].
+    -->
+    <string name="content_description_neutral_color_option">Primary neutral theme</string>
+
+    <!--
+    Accessibility string for a button that allows the user to select a color scheme generated from
+    their current wallpaper as the system color. This is shown in a list with other color options.
+
+    [CHAR LIMIT=NONE].
+    -->
+    <string name="content_description_vibrant_color_option">Primary vibrant theme</string>
+
+    <!--
+    Accessibility string for a button that allows the user to select a color scheme generated from
+    their current wallpaper as the system color. This is shown in a list with other color options.
+
+    [CHAR LIMIT=NONE].
+    -->
+    <string name="content_description_expressive_color_option">Primary expressive theme</string>
+
+    <!--
     Accessibility string for a button that allows the user to select the default color for their
     lock screen clock on the device. This is shown next to other buttons that allow the user to
     select from a set of custom colors.
diff --git a/src/com/android/customization/model/color/ColorOptionImpl.kt b/src/com/android/customization/model/color/ColorOptionImpl.kt
index 70aaa92..3273ce2 100644
--- a/src/com/android/customization/model/color/ColorOptionImpl.kt
+++ b/src/com/android/customization/model/color/ColorOptionImpl.kt
@@ -61,10 +61,7 @@
     }
 
     override fun getContentDescription(context: Context): CharSequence? {
-        if (type == ColorType.WALLPAPER_COLOR) {
-            return context.getString(R.string.wallpaper_color_title)
-        }
-        return super.getContentDescription(context)
+        return title
     }
 
     override fun getSource(): String? {
diff --git a/src/com/android/customization/model/color/ColorProvider.kt b/src/com/android/customization/model/color/ColorProvider.kt
index b2ff452..6c83f23 100644
--- a/src/com/android/customization/model/color/ColorProvider.kt
+++ b/src/com/android/customization/model/color/ColorProvider.kt
@@ -37,6 +37,7 @@
 import com.android.customization.picker.color.shared.model.ColorType
 import com.android.systemui.monet.ColorScheme
 import com.android.systemui.monet.Style
+import com.android.wallpaper.R
 import com.android.wallpaper.compat.WallpaperManagerCompat
 import com.android.wallpaper.module.InjectorProvider
 import kotlinx.coroutines.CoroutineScope
@@ -48,7 +49,7 @@
 /**
  * Default implementation of {@link ColorOptionsProvider} that reads preset colors from a stub APK.
  */
-class ColorProvider(context: Context, stubPackageName: String) :
+class ColorProvider(private val context: Context, stubPackageName: String) :
     ResourcesApkProvider(context, stubPackageName), ColorOptionsProvider {
 
     companion object {
@@ -244,6 +245,18 @@
                     OVERLAY_CATEGORY_SYSTEM_PALETTE,
                     if (isDefault) "" else toColorString(colorInt)
                 )
+                builder.title =
+                    when (style) {
+                        Style.TONAL_SPOT ->
+                            context.getString(R.string.content_description_dynamic_color_option)
+                        Style.SPRITZ ->
+                            context.getString(R.string.content_description_neutral_color_option)
+                        Style.VIBRANT ->
+                            context.getString(R.string.content_description_vibrant_color_option)
+                        Style.EXPRESSIVE ->
+                            context.getString(R.string.content_description_expressive_color_option)
+                        else -> context.getString(R.string.content_description_dynamic_color_option)
+                    }
                 builder.source = source
                 builder.style = style
                 // Color option index value starts from 1.
diff --git a/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt b/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt
index 16cdd75..45e3cde 100644
--- a/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt
+++ b/src/com/android/customization/picker/color/ui/binder/ColorSectionViewBinder.kt
@@ -30,6 +30,7 @@
 import com.android.customization.picker.color.ui.viewmodel.ColorOptionIconViewModel
 import com.android.customization.picker.color.ui.viewmodel.ColorPickerViewModel
 import com.android.wallpaper.R
+import com.android.wallpaper.picker.common.icon.ui.viewbinder.ContentDescriptionViewBinder
 import com.android.wallpaper.picker.option.ui.viewmodel.OptionItemViewModel
 import kotlinx.coroutines.launch
 
@@ -103,6 +104,10 @@
                     item.payload,
                     night
                 )
+                ContentDescriptionViewBinder.bind(
+                    view = itemView.requireViewById(R.id.option_tile),
+                    viewModel = item.text,
+                )
             }
             val optionSelectedView = itemView.findViewById<ImageView>(R.id.option_selected)