Announce chips dropdown for accessibility

Announce when chip's dropdown opens.

b/17262070

Change-Id: Ic99ee22f4a4f41e0f0d468496992822f8b60dbdd
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d1c9c7f..82cbf25 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -26,4 +26,6 @@
     <!-- Text displayed in the enter key slot when the recipientedittextview has focus.
          [CHAR LIMIT=12] -->
     <string name="action_label">Return</string>
+    <!-- Announce the number of possible recipient entries that the user can select from for accessibility purposes [CHAR LIMIT=200] -->
+    <string name="accessbility_suggestion_dropdown_opened">Contact suggestions opened</string>
 </resources>
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 7a6ae7a..6306498 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -183,10 +183,11 @@
     private ReplacementDrawableSpan mMoreChip;
     private TextView mMoreItem;
 
+    private int mCurrentSuggestionCount;
+
     // VisibleForTesting
     final ArrayList<String> mPendingChips = new ArrayList<String>();
 
-
     private int mPendingChipsCount = 0;
     private int mCheckedItem;
     private boolean mNoChips = false;
@@ -504,6 +505,13 @@
                 // that the user can see as many results as possible.
                 if (entries != null && entries.size() > 0) {
                     scrollBottomIntoView();
+                    // Here the current suggestion count is still the old one since we update
+                    // the count at the bottom of this function.
+                    if (mCurrentSuggestionCount == 0) {
+                        // Announce the new number of possible choices for accessibility.
+                        announceForAccessibility(getContext().getString(
+                                R.string.accessbility_suggestion_dropdown_opened));
+                    }
                 }
                 // Set the dropdown height to be the remaining height
                 final int[] coords = new int[2];
@@ -511,6 +519,8 @@
                 final Rect displayFrame = new Rect();
                 getWindowVisibleDisplayFrame(displayFrame);
                 setDropDownHeight(displayFrame.bottom - coords[1] - getHeight());
+
+                mCurrentSuggestionCount = entries == null ? 0 : entries.size();
             }
         });
         baseAdapter.setDropdownChipLayouter(mDropdownChipLayouter);