Correct content description of labels spinner and delete button in editor

Now, pressing on the labels spinner, Talkback will say "<Kind> drop down
list"; pressing on the delete button of editor with labels, Talkback will
say "Delete <Type> <Kind>"; pressing on the delete button of editor without
labels, Talkback will say "Delete <Kind>".

Bug: 11553536
Bug: 25499016
Change-Id: Ibb57ee2226c4eea159e75c7cf901c3febd83fa82
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1ddb2da..bacf641 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -882,4 +882,12 @@
     <!-- Message below contact name, showing from which account [CHAR LIMIT=NONE]-->
     <string name="contact_from_account_name">From <xliff:g id="account_name">%s</xliff:g></string>
 
+    <!-- Content description of delete button to the right of each section in editor, including
+    data type. For example: Delete Home Phone, Delete Work Email, etc [CHAR LIMIT=30]-->
+    <string name="editor_delete_view_description">Delete <xliff:g id="data_type">%s </xliff:g><xliff:g id="data_kind">%s</xliff:g></string>
+
+    <!-- Content description of delete button to the right of each section in editor, without data
+    type. For example: Delete Website, Delete SIP, etc [CHAR LIMIT=30]-->
+    <string name="editor_delete_view_description_short">Delete <xliff:g id="data_kind">%s</xliff:g></string>
+
 </resources>
diff --git a/src/com/android/contacts/editor/LabeledEditorView.java b/src/com/android/contacts/editor/LabeledEditorView.java
index 97926f4..f862303 100644
--- a/src/com/android/contacts/editor/LabeledEditorView.java
+++ b/src/com/android/contacts/editor/LabeledEditorView.java
@@ -308,8 +308,23 @@
         mLabel.setAdapter(mEditTypeAdapter);
         if (mEditTypeAdapter.hasCustomSelection()) {
             mLabel.setSelection(mEditTypeAdapter.getPosition(CUSTOM_SELECTION));
+            mDeleteContainer.setContentDescription(
+                    getContext().getString(R.string.editor_delete_view_description,
+                            mEntry.getAsString(mType.customColumn),
+                            getContext().getString(mKind.titleRes)));
         } else {
             mLabel.setSelection(mEditTypeAdapter.getPosition(mType));
+            if (mType != null) {
+                mDeleteContainer.setContentDescription(
+                        getContext().getString(R.string.editor_delete_view_description,
+                                getContext().getString(mType.labelRes),
+                                getContext().getString(mKind.titleRes)));
+            } else {
+                mDeleteContainer.setContentDescription(
+                        getContext().getString(R.string.editor_delete_view_description_short,
+                                getContext().getString(mKind.titleRes)));
+            }
+
         }
     }
 
@@ -404,6 +419,8 @@
         final boolean hasTypes = RawContactModifier.hasEditTypes(kind);
         setupLabelButton(hasTypes);
         mLabel.setEnabled(!readOnly && isEnabled());
+        mLabel.setContentDescription(getContext().getResources().getString(mKind.titleRes));
+
         if (hasTypes) {
             mType = RawContactModifier.getCurrentType(entry, kind);
             rebuildLabel();