Fix TalkBack can't say in "Name your style" page

Override getAccessibilityTitle() and define related
accessibility strings to let TakbackBack speak out
each custom style page.

Video:
https://drive.google.com/file/d/1dOBKrfmr7PkrPLTp0XQta3co1GQpSdeN/view?usp=sharing&resourcekey=0-CW-4b9ZT5eMAEWmnqVnlNw

Bug: 174213366
Test: Manual
Change-Id: Ic41b5d0e6df43fbccfc2e31c7b9fce9a50b95f89
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 55de455..929bd4e 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -212,4 +212,19 @@
 
     <!-- Bottom sheet dialog which displaying different theme's info. [CHAR_LIMIT=80] -->
     <string name="style_info_description">Preview of font, icons, app shape, and color</string>
+
+    <!-- Accessibility for custom style font page [CHAR_LIMIT=50] -->
+    <string name="accessibility_custom_font_title">Custom font</string>
+
+    <!-- Accessibility for custom style icon page [CHAR_LIMIT=50] -->
+    <string name="accessibility_custom_icon_title">Custom icon</string>
+
+    <!-- Accessibility for custom style color page [CHAR_LIMIT=50] -->
+    <string name="accessibility_custom_color_title">Custom color</string>
+
+    <!-- Accessibility for custom style shape page [CHAR_LIMIT=50] -->
+    <string name="accessibility_custom_shape_title">Custom shape</string>
+
+    <!-- Accessibility for custom style name page [CHAR_LIMIT=50] -->
+    <string name="accessibility_custom_name_title">Custom style name</string>
 </resources>
diff --git a/src/com/android/customization/picker/theme/CustomThemeActivity.java b/src/com/android/customization/picker/theme/CustomThemeActivity.java
index a91faeb..c1c2d0e 100644
--- a/src/com/android/customization/picker/theme/CustomThemeActivity.java
+++ b/src/com/android/customization/picker/theme/CustomThemeActivity.java
@@ -290,13 +290,15 @@
      */
     private static abstract class ComponentStep<T extends ThemeComponentOption> {
         @StringRes final int titleResId;
+        @StringRes final int accessibilityResId;
         final ThemeComponentOptionProvider<T> provider;
         final int position;
         private CustomThemeStepFragment mFragment;
 
-        protected ComponentStep(@StringRes int titleResId, ThemeComponentOptionProvider<T> provider,
-                                int position) {
+        protected ComponentStep(@StringRes int titleResId, @StringRes int accessibilityResId,
+                ThemeComponentOptionProvider<T> provider, int position) {
             this.titleResId = titleResId;
+            this.accessibilityResId = accessibilityResId;
             this.provider = provider;
             this.position = position;
         }
@@ -318,7 +320,8 @@
 
         protected FontStep(ThemeComponentOptionProvider<FontOption> provider,
                 int position) {
-            super(R.string.font_component_title, provider, position);
+            super(R.string.font_component_title, R.string.accessibility_custom_font_title, provider,
+                    position);
         }
 
         @Override
@@ -326,7 +329,8 @@
             return CustomThemeComponentFragment.newInstance(
                     title,
                     position,
-                    titleResId);
+                    titleResId,
+                    accessibilityResId);
         }
     }
 
@@ -334,7 +338,8 @@
 
         protected IconStep(ThemeComponentOptionProvider<IconOption> provider,
                 int position) {
-            super(R.string.icon_component_title, provider, position);
+            super(R.string.icon_component_title, R.string.accessibility_custom_icon_title, provider,
+                    position);
         }
 
         @Override
@@ -342,7 +347,8 @@
             return CustomThemeComponentFragment.newInstance(
                     title,
                     position,
-                    titleResId);
+                    titleResId,
+                    accessibilityResId);
         }
     }
 
@@ -350,7 +356,8 @@
 
         protected ColorStep(ThemeComponentOptionProvider<ColorOption> provider,
                 int position) {
-            super(R.string.color_component_title, provider, position);
+            super(R.string.color_component_title, R.string.accessibility_custom_color_title,
+                    provider, position);
         }
 
         @Override
@@ -358,7 +365,8 @@
             return CustomThemeComponentFragment.newInstance(
                     title,
                     position,
-                    titleResId);
+                    titleResId,
+                    accessibilityResId);
         }
     }
 
@@ -366,7 +374,8 @@
 
         protected ShapeStep(ThemeComponentOptionProvider<ShapeOption> provider,
                 int position) {
-            super(R.string.shape_component_title, provider, position);
+            super(R.string.shape_component_title, R.string.accessibility_custom_shape_title,
+                    provider, position);
         }
 
         @Override
@@ -374,14 +383,16 @@
             return CustomThemeComponentFragment.newInstance(
                     title,
                     position,
-                    titleResId);
+                    titleResId,
+                    accessibilityResId);
         }
     }
 
     private class NameStep extends ComponentStep {
 
         protected NameStep(int position) {
-            super(R.string.name_component_title, null, position);
+            super(R.string.name_component_title, R.string.accessibility_custom_name_title, null,
+                    position);
         }
 
         @Override
@@ -389,7 +400,8 @@
             return CustomThemeNameFragment.newInstance(
                     title,
                     position,
-                    titleResId);
+                    titleResId,
+                    accessibilityResId);
         }
     }
 }
diff --git a/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java b/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
index a6fdb1c..5495e9a 100644
--- a/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
@@ -34,16 +34,17 @@
     private static final String ARG_USE_GRID_LAYOUT = "CustomThemeComponentFragment.use_grid";;
 
     public static CustomThemeComponentFragment newInstance(CharSequence toolbarTitle, int position,
-            int titleResId) {
-        return newInstance(toolbarTitle, position, titleResId, false);
+            int titleResId, int accessibilityResId) {
+        return newInstance(toolbarTitle, position, titleResId, accessibilityResId, false);
     }
 
     public static CustomThemeComponentFragment newInstance(CharSequence toolbarTitle, int position,
-            int titleResId, boolean allowGridLayout) {
+            int titleResId, int accessibilityResId, boolean allowGridLayout) {
         CustomThemeComponentFragment fragment = new CustomThemeComponentFragment();
         Bundle arguments = AppbarFragment.createArguments(toolbarTitle);
         arguments.putInt(ARG_KEY_POSITION, position);
         arguments.putInt(ARG_KEY_TITLE_RES_ID, titleResId);
+        arguments.putInt(ARG_KEY_ACCESSIBILITY_RES_ID, accessibilityResId);
         arguments.putBoolean(ARG_USE_GRID_LAYOUT, allowGridLayout);
         fragment.setArguments(arguments);
         return fragment;
diff --git a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
index f36c80b..9929ccf 100644
--- a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
@@ -54,11 +54,12 @@
     private static final String TAG = "CustomThemeNameFragment";
 
     public static CustomThemeNameFragment newInstance(CharSequence toolbarTitle, int position,
-            int titleResId) {
+            int titleResId, int accessibilityResId) {
         CustomThemeNameFragment fragment = new CustomThemeNameFragment();
         Bundle arguments = AppbarFragment.createArguments(toolbarTitle);
         arguments.putInt(ARG_KEY_POSITION, position);
         arguments.putInt(ARG_KEY_TITLE_RES_ID, titleResId);
+        arguments.putInt(ARG_KEY_ACCESSIBILITY_RES_ID, accessibilityResId);
         fragment.setArguments(arguments);
         return fragment;
     }
diff --git a/src/com/android/customization/picker/theme/CustomThemeStepFragment.java b/src/com/android/customization/picker/theme/CustomThemeStepFragment.java
index b05ebc4..50f391d 100644
--- a/src/com/android/customization/picker/theme/CustomThemeStepFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeStepFragment.java
@@ -23,6 +23,8 @@
 abstract class CustomThemeStepFragment extends AppbarFragment {
     protected static final String ARG_KEY_POSITION = "CustomThemeStepFragment.position";
     protected static final String ARG_KEY_TITLE_RES_ID = "CustomThemeStepFragment.title_res";
+    protected static final String ARG_KEY_ACCESSIBILITY_RES_ID =
+            "CustomThemeStepFragment.accessibility_res";
     protected CustomThemeComponentStepHost mHost;
     protected CustomThemeManager mCustomThemeManager;
     protected int mPosition;
@@ -30,6 +32,8 @@
     protected TextView mTitle;
     @StringRes
     protected int mTitleResId;
+    @StringRes
+    protected int mAccessibilityResId;
 
     @Override
     public void onAttach(Context context) {
@@ -48,6 +52,7 @@
         super.onCreate(savedInstanceState);
         mPosition = getArguments().getInt(ARG_KEY_POSITION);
         mTitleResId = getArguments().getInt(ARG_KEY_TITLE_RES_ID);
+        mAccessibilityResId = getArguments().getInt(ARG_KEY_ACCESSIBILITY_RES_ID);
         mCustomThemeManager = mHost.getCustomThemeManager();
     }
 
@@ -77,6 +82,11 @@
     }
 
     @Override
+    protected String getAccessibilityTitle() {
+        return getString(mAccessibilityResId);
+    }
+
+    @Override
     public boolean onMenuItemClick(MenuItem item) {
         if (item.getItemId() == R.id.custom_theme_delete) {
             AlertDialog.Builder builder = new AlertDialog.Builder(getContext());