Accessibility: Announce star/unstar actions

Bug: 341812
Change-Id: Ifa448f8609ee0f50b3827f5d7aec5d0a6a2e6f9c
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 494e115..17b95a6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -93,6 +93,11 @@
     <!-- Menu item used to remove a star from a contact, making the contact no longer show up at the top of favorites -->
     <string name="menu_removeStar">Remove from favorites</string>
 
+    <!-- Description of what happens when you click on the unstar MenuItem. [CHAR LIMIT=NONE] -->
+    <string name="description_action_menu_remove_star">Removed from favorites</string>
+    <!-- Description of what happens when you click on the star MenuItem. [CHAR LIMIT=NONE] -->
+    <string name="description_action_menu_add_star">Added to favorites</string>
+
     <!-- Menu item used to edit a specific contact -->
     <string name="menu_editContact">Edit</string>
 
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index e453a4b..69fef9e 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -26,7 +26,6 @@
 import android.app.LoaderManager.LoaderCallbacks;
 import android.app.SearchManager;
 import android.content.ActivityNotFoundException;
-import android.content.ComponentName;
 import android.content.ContentUris;
 import android.content.ContentValues;
 import android.content.Intent;
@@ -1560,6 +1559,13 @@
             final Intent intent = ContactSaveService.createSetStarredIntent(
                     QuickContactActivity.this, mLookupUri, !isStarred);
             startService(intent);
+
+            final CharSequence accessibilityText = !isStarred
+                    ? getResources().getText(R.string.description_action_menu_add_star)
+                    : getResources().getText(R.string.description_action_menu_remove_star);
+            // Accessibility actions need to have an associated view. We can't access the MenuItem's
+            // underlying view, so put this accessibility action on the root view.
+            mScroller.announceForAccessibility(accessibilityText);
         }
     }