[Quantum] update alt/single chips to quantum

Updated UI for alternates/single chips dropdown.

Not included: X button next to selected chip for removal.

b/15934812

Change-Id: Id34e28f1783f85ffbe33f82b1d230c3def27589a
diff --git a/res/color/chips_dropdown_text.xml b/res/color/chips_dropdown_subtitle_text.xml
similarity index 90%
rename from res/color/chips_dropdown_text.xml
rename to res/color/chips_dropdown_subtitle_text.xml
index f6addfd..e7b0f3e 100644
--- a/res/color/chips_dropdown_text.xml
+++ b/res/color/chips_dropdown_subtitle_text.xml
@@ -17,7 +17,7 @@
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <item android:state_activated="true" android:color="#212121"/>
+    <item android:state_activated="true" android:color="@android:color/white"/>
     <item android:color="#757575"/>
 
 </selector>
\ No newline at end of file
diff --git a/res/color/chips_dropdown_text.xml b/res/color/chips_dropdown_title_text.xml
similarity index 86%
copy from res/color/chips_dropdown_text.xml
copy to res/color/chips_dropdown_title_text.xml
index f6addfd..7c79390 100644
--- a/res/color/chips_dropdown_text.xml
+++ b/res/color/chips_dropdown_title_text.xml
@@ -17,7 +17,7 @@
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <item android:state_activated="true" android:color="#212121"/>
-    <item android:color="#757575"/>
+    <item android:state_activated="true" android:color="@android:color/white"/>
+    <item android:color="#212121"/>
 
 </selector>
\ No newline at end of file
diff --git a/res/layout/chips_autocomplete_recipient_dropdown_item.xml b/res/layout/chips_autocomplete_recipient_dropdown_item.xml
index 3f35e86..4f8427d 100644
--- a/res/layout/chips_autocomplete_recipient_dropdown_item.xml
+++ b/res/layout/chips_autocomplete_recipient_dropdown_item.xml
@@ -16,7 +16,7 @@
 -->
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_height="@dimen/chip_dropdown_height"
     android:background="@drawable/chips_dropdown_background"
     style="@style/ChipAutocompleteWrapperStyle">
 
diff --git a/res/layout/chips_recipient_dropdown_item.xml b/res/layout/chips_recipient_dropdown_item.xml
index 343bf61..ec0740b 100644
--- a/res/layout/chips_recipient_dropdown_item.xml
+++ b/res/layout/chips_recipient_dropdown_item.xml
@@ -16,8 +16,9 @@
 -->
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="@drawable/chips_dropdown_background">
+    android:layout_height="@dimen/chip_dropdown_height"
+    android:background="@drawable/chips_dropdown_background"
+    android:padding="16dp">
 
     <com.android.ex.chips.CircularImageView style="@style/ChipStartIconStyle" />
 
diff --git a/res/values/dimen.xml b/res/values/dimen.xml
index 636fd26..8c0d2c2 100644
--- a/res/values/dimen.xml
+++ b/res/values/dimen.xml
@@ -28,6 +28,8 @@
 
     <!-- dropdown -->
     <dimen name="chip_icon_margin_end">16dp</dimen>
+    <dimen name="chip_dropdown_height">72dp</dimen>
+    <!-- autocomplete dropdown -->
     <dimen name="chip_wrapper_start_padding">16dp</dimen>
     <dimen name="chip_wrapper_top_padding">16dp</dimen>
     <dimen name="chip_wrapper_end_padding">16dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a2b8585..8b671d1 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -16,20 +16,20 @@
 <resources xmlns:tools="http://schemas.android.com/tools"
            xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <style name="RecipientEditTextView" parent="@android:attr/autoCompleteTextViewStyle">
-        <item name="android:inputType">textEmailAddress|textMultiLine</item>
-        <item name="android:imeOptions">actionNext|flagNoFullscreen</item>
-        <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
-        <item name="android:background">@null</item>
-        <item name="android:layout_height">wrap_content</item>
         <item name="android:layout_width">match_parent</item>
-        <item name="android:dropDownVerticalOffset">-6dip</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:background">@null</item>
         <item name="android:dropDownHorizontalOffset">-16dip</item>
+        <item name="android:dropDownVerticalOffset">-6dip</item>
         <item name="android:dropDownWidth">match_parent</item>
-        <item name="android:minHeight">48dip</item>
+        <item name="android:imeOptions">actionNext|flagNoFullscreen</item>
+        <item name="android:inputType">textEmailAddress|textMultiLine</item>
         <item name="android:lineSpacingExtra">@dimen/line_spacing_extra</item>
-        <item name="android:textAlignment" tools:ignore="NewApi">viewStart</item>
-        <item name="android:textDirection" tools:ignore="NewApi">locale</item>
+        <item name="android:minHeight">@dimen/chip_height</item>
         <item name="android:popupBackground">@drawable/chips_popup_background</item>
+        <item name="android:textAlignment" tools:ignore="NewApi">viewStart</item>
+        <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+        <item name="android:textDirection" tools:ignore="NewApi">locale</item>
     </style>
 
     <style name="ChipAutocompleteWrapperStyle">
@@ -43,12 +43,12 @@
         <item name="android:id">@android:id/title</item>
         <item name="android:layout_width">match_parent</item>
         <item name="android:layout_height">wrap_content</item>
+        <item name="android:layout_gravity">center_vertical</item>
         <item name="android:ellipsize">middle</item>
         <item name="android:paddingTop">1dp</item>
         <item name="android:singleLine">true</item>
-        <item name="android:textColor">@color/chips_dropdown_text</item>
-        <item name="android:textSize">14sp</item>
-        <item name="android:textStyle">bold</item>
+        <item name="android:textColor">@color/chips_dropdown_title_text</item>
+        <item name="android:textSize">16sp</item>
     </style>
 
     <style name="ChipTitleStartIconStyle" parent="@style/ChipTitleBaseStyle">
@@ -67,7 +67,7 @@
         <item name="android:ellipsize">middle</item>
         <item name="android:paddingBottom">1dp</item>
         <item name="android:singleLine">true</item>
-        <item name="android:textColor">@color/chips_dropdown_text</item>
+        <item name="android:textColor">@color/chips_dropdown_subtitle_text</item>
         <item name="android:textSize">14sp</item>
     </style>
 
diff --git a/src/com/android/ex/chips/DropdownChipLayouter.java b/src/com/android/ex/chips/DropdownChipLayouter.java
index bda8108..afa25f8 100644
--- a/src/com/android/ex/chips/DropdownChipLayouter.java
+++ b/src/com/android/ex/chips/DropdownChipLayouter.java
@@ -64,6 +64,12 @@
         boolean showImage = true;
         CharSequence destinationType = getDestinationType(entry);
 
+        // If we don't have name but have destination, show destination as the main entry.
+        if (displayName == null && destination != null) {
+            displayName = destination;
+            destination = null;
+        }
+
         final View itemView = reuseOrInflateView(convertView, parent, type);
 
         final ViewHolder viewHolder = new ViewHolder(itemView);
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 6dd8de4..fb8e81c 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -924,6 +924,14 @@
     }
 
     /**
+     * Calculate the offset from bottom of the EditText to top of the provided line.
+     */
+    private int calculateOffsetFromBottomToTop(int line) {
+        return -(int) ((mChipHeight + (2 * mLineSpacingExtra)) * (Math
+                .abs(getLineCount() - line)) + getPaddingBottom());
+    }
+
+    /**
      * Get the max amount of space a chip can take up. The formula takes into
      * account the width of the EditTextView, any view padding, and padding
      * that will be added to the chip.
@@ -1708,18 +1716,13 @@
                     return;
                 }
                 int line = getLayout().getLineForOffset(getChipStart(currentChip));
-                int bottom;
-                if (line == getLineCount() -1) {
-                    bottom = 0;
-                } else {
-                    bottom = -(int) ((mChipHeight + (2 * mLineSpacingExtra)) * (Math
-                            .abs(getLineCount() - 1 - line)));
-                }
+                int bottomOffset = calculateOffsetFromBottomToTop(line);
+
                 // Align the alternates popup with the left side of the View,
                 // regardless of the position of the chip tapped.
                 alternatesPopup.setWidth(width);
                 alternatesPopup.setAnchorView(RecipientEditTextView.this);
-                alternatesPopup.setVerticalOffset(bottom);
+                alternatesPopup.setVerticalOffset(bottomOffset);
                 alternatesPopup.setAdapter(result);
                 alternatesPopup.setOnItemClickListener(mAlternatesListener);
                 // Clear the checked item.
@@ -2254,12 +2257,12 @@
             return;
         }
         int line = getLayout().getLineForOffset(getChipStart(currentChip));
-        int bottom = calculateOffsetFromBottom(line);
+        int bottomOffset = calculateOffsetFromBottomToTop(line);
         // Align the alternates popup with the left side of the View,
         // regardless of the position of the chip tapped.
         popup.setWidth(width);
         popup.setAnchorView(this);
-        popup.setVerticalOffset(bottom);
+        popup.setVerticalOffset(bottomOffset);
         popup.setAdapter(createSingleAddressAdapter(currentChip));
         popup.setOnItemClickListener(new OnItemClickListener() {
             @Override