Content descriptions for current preview options

Fixes: 131293339
Test: manual
Change-Id: If378a60d46d8227c987cbdacd8bb907766a9def0
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 82a9347..319aa0a 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -60,6 +60,12 @@
     <!-- Content description indicating that the selected option is currently applied to the device. [CHAR_LIMIT=NONE] -->
     <string name="option_applied_description"><xliff:g name="style_name">%1$s</xliff:g>, currently applied</string>
 
+    <!-- Content description indicating that the selected option is currently applied and previewed. [CHAR_LIMIT=NONE] -->
+    <string name="option_applied_previewed_description"><xliff:g name="style_name">%1$s</xliff:g>, currently applied and previewed</string>
+
+    <!-- Content description indicating that the selected option is currently being previewed. [CHAR_LIMIT=NONE] -->
+    <string name="option_previewed_description"><xliff:g name="style_name">%1$s</xliff:g>, currently previewed</string>
+
     <!-- Sample text used to show a preview of a selected font [CHAR LIMIT=3] -->
     <string name="theme_font_example">ABC</string>
 
diff --git a/src/com/android/customization/widget/OptionSelectorController.java b/src/com/android/customization/widget/OptionSelectorController.java
index 5e4a30a..9725995 100644
--- a/src/com/android/customization/widget/OptionSelectorController.java
+++ b/src/com/android/customization/widget/OptionSelectorController.java
@@ -122,6 +122,28 @@
         RecyclerView.ViewHolder holder = mContainer.findViewHolderForAdapterPosition(index);
         if (holder != null && holder.itemView != null) {
             holder.itemView.setActivated(isActivated);
+
+            if (holder instanceof TileViewHolder) {
+                TileViewHolder tileHolder = (TileViewHolder) holder;
+                if (isActivated) {
+                    if (option == mAppliedOption) {
+                        CharSequence cd = mContainer.getContext().getString(
+                                R.string.option_applied_previewed_description, option.getTitle());
+                        tileHolder.labelView.setContentDescription(cd);
+                    } else {
+                        CharSequence cd = mContainer.getContext().getString(
+                                R.string.option_previewed_description, option.getTitle());
+                        tileHolder.labelView.setContentDescription(cd);
+                    }
+                } else if (option == mAppliedOption) {
+                    CharSequence cd = mContainer.getContext().getString(
+                            R.string.option_applied_description, option.getTitle());
+                    tileHolder.labelView.setContentDescription(cd);
+                } else {
+                    // Remove content description
+                    tileHolder.labelView.setContentDescription(null);
+                }
+            }
         }
     }
 
@@ -179,10 +201,10 @@
                     checkedFrame.setLayerInsetLeft(idx, checkSize/3);
                     holder.itemView.setForeground(checkedFrame);
 
+                    // Initialize the currently applied option
                     CharSequence cd = mContainer.getContext().getString(
-                            R.string.option_applied_description, option.getTitle());
+                            R.string.option_applied_previewed_description, option.getTitle());
                     holder.labelView.setContentDescription(cd);
-
                 } else if (mShowCheckmark) {
                     holder.itemView.setForeground(null);
                 }