Merge "Load groups even when there are no group writable accounts" into ub-contactsdialer-g-dev
diff --git a/res/drawable/ic_close_black_24dp.xml b/res/drawable/ic_close_24dp.xml
similarity index 95%
rename from res/drawable/ic_close_black_24dp.xml
rename to res/drawable/ic_close_24dp.xml
index 14513be..52070d5 100644
--- a/res/drawable/ic_close_black_24dp.xml
+++ b/res/drawable/ic_close_24dp.xml
@@ -20,6 +20,6 @@
         android:viewportWidth="24.0"
         android:viewportHeight="24.0">
     <path
-        android:fillColor="#FF000000"
+        android:fillColor="@android:color/white"
         android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
 </vector>
diff --git a/res/drawable/ic_menu_expand_maximized_24dp.xml b/res/drawable/ic_menu_expand_maximized_24dp.xml
new file mode 100644
index 0000000..9c626cc
--- /dev/null
+++ b/res/drawable/ic_menu_expand_maximized_24dp.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+    <path
+        android:fillColor="@android:color/white"
+        android:pathData="M7.41,15.41L12,10.83l4.59,4.58L18,14l-6,-6 -6,6z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_menu_expand_minimized_24dp.xml b/res/drawable/ic_menu_expand_minimized_24dp.xml
new file mode 100644
index 0000000..95a1bf7
--- /dev/null
+++ b/res/drawable/ic_menu_expand_minimized_24dp.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+    <path
+        android:fillColor="@android:color/white"
+        android:pathData="M7.41,7.84L12,12.42l4.59,-4.58L18,9.25l-6,6 -6,-6z"/>
+</vector>
\ No newline at end of file
diff --git a/res/layout/edit_delete_button.xml b/res/layout/edit_delete_button.xml
index d2c7fb9..d352801 100644
--- a/res/layout/edit_delete_button.xml
+++ b/res/layout/edit_delete_button.xml
@@ -29,7 +29,8 @@
         android:layout_gravity="center"
         android:duplicateParentState="true"
         android:background="?android:attr/selectableItemBackground"
-        android:src="@drawable/ic_menu_remove_field_holo_light"
+        android:src="@drawable/ic_close_24dp"
+        android:tint="@color/quantum_black_hint_text"
         android:paddingLeft="@dimen/editor_round_button_padding_left"
         android:paddingRight="@dimen/editor_round_button_padding_right"
         android:paddingStart="@dimen/editor_round_button_padding_left"
diff --git a/res/layout/editor_account_header.xml b/res/layout/editor_account_header.xml
index 5a93b58..3a382f4 100644
--- a/res/layout/editor_account_header.xml
+++ b/res/layout/editor_account_header.xml
@@ -66,7 +66,8 @@
 
     <ImageView
         android:id="@+id/account_expander_icon"
-        android:src="@drawable/ic_menu_expander_minimized_holo_light"
+        android:src="@drawable/ic_menu_expand_minimized_24dp"
+        android:tint="@color/quantum_black_secondary_text"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_vertical|end"
diff --git a/res/layout/editor_all_rawcontacts_accounts_selector.xml b/res/layout/editor_all_rawcontacts_accounts_selector.xml
index c830d38..7cff162 100644
--- a/res/layout/editor_all_rawcontacts_accounts_selector.xml
+++ b/res/layout/editor_all_rawcontacts_accounts_selector.xml
@@ -45,7 +45,8 @@
             android:ellipsize="end" />
 
     <ImageView
-            android:src="@drawable/ic_menu_expander_minimized_holo_light"
+            android:src="@drawable/ic_menu_expand_minimized_24dp"
+            android:tint="@color/quantum_black_secondary_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="center_vertical|end"
diff --git a/res/layout/name_edit_expansion_view.xml b/res/layout/name_edit_expansion_view.xml
index 13a50a8..4d1bd61 100644
--- a/res/layout/name_edit_expansion_view.xml
+++ b/res/layout/name_edit_expansion_view.xml
@@ -32,6 +32,7 @@
         android:layout_height="wrap_content"
         android:layout_gravity="center"
         android:duplicateParentState="true"
+        android:tint="@color/quantum_black_secondary_text"
         android:background="?android:attr/selectableItemBackground"
         android:paddingLeft="@dimen/editor_round_button_padding_left"
         android:paddingRight="@dimen/editor_round_button_padding_right"
diff --git a/res/layout/search_bar_expanded.xml b/res/layout/search_bar_expanded.xml
index ecadbd1..945521f 100644
--- a/res/layout/search_bar_expanded.xml
+++ b/res/layout/search_bar_expanded.xml
@@ -53,10 +53,10 @@
         android:layout_height="@dimen/search_box_close_icon_size"
         android:layout_width="@dimen/search_box_close_icon_size"
         android:padding="@dimen/search_box_close_icon_padding"
-        android:src="@drawable/ic_close_black_24dp"
+        android:src="@drawable/ic_close_24dp"
+        android:tint="@color/quantum_black_secondary_text"
         android:clickable="true"
         android:background="?attr/selectableItemBackgroundBorderless"
-        android:contentDescription="@string/description_clear_search"
-        android:alpha="@dimen/close_icon_alpha" />
+        android:contentDescription="@string/description_clear_search" />
 
 </LinearLayout>
diff --git a/res/layout/selection_bar.xml b/res/layout/selection_bar.xml
index 72a5a10..b26dc8a 100644
--- a/res/layout/selection_bar.xml
+++ b/res/layout/selection_bar.xml
@@ -25,10 +25,10 @@
         android:layout_width="@dimen/selection_bar_close_icon_size"
         android:layout_height="@dimen/selection_bar_close_icon_size"
         android:layout_gravity="center_vertical|start"
-        android:alpha="@dimen/close_icon_alpha"
+        android:tint="@color/quantum_black_secondary_text"
         android:background="?attr/selectableItemBackgroundBorderless"
         android:contentDescription="@string/action_menu_back_from_edit_select"
-        android:src="@drawable/ic_close_black_24dp"/>
+        android:src="@drawable/ic_close_24dp"/>
 
     <TextView
         android:id="@+id/selection_count_text"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 771ba44..607b7a0 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -14,6 +14,11 @@
      limitations under the License.
 -->
 <resources>
+    <!-- 54% black -->
+    <color name="quantum_black_secondary_text">#89000000</color>
+
+    <!-- 38% black -->
+    <color name="quantum_black_hint_text">#61000000</color>
 
     <color name="quickcontact_name_detail_background">#66000000</color>
     <color name="quickcontact_entry_sub_header_text_color">#737373</color>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 14207d2..04f2b0d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -712,8 +712,6 @@
     <string name="expanding_entry_card_view_see_more">See more</string>
     <!-- Button Label to see less on an ExpandingEntryCardView [CHAR LIMIT=40] -->
     <string name="expanding_entry_card_view_see_less">See less</string>
-    <!-- Button Label to see all on an ExpandingEntryCardView [CHAR LIMIT=40] -->
-    <string name="expanding_entry_card_view_see_all">See all</string>
 
     <!-- Title of recent card. [CHAR LIMIT=60] -->
     <string name="recent_card_title">Recent</string>
diff --git a/src/com/android/contacts/common/logging/QuickContactEvent.java b/src/com/android/contacts/common/logging/QuickContactEvent.java
index 079e435..a1069ae 100644
--- a/src/com/android/contacts/common/logging/QuickContactEvent.java
+++ b/src/com/android/contacts/common/logging/QuickContactEvent.java
@@ -62,7 +62,7 @@
         public static final int UNSTAR = 3;
         public static final int EDIT = 4;
         public static final int ADD = 5;
-        public static final int DELETE = 6;
+        public static final int REMOVE = 6;
         public static final int SHARE = 7;
         public static final int SHORTCUT = 8;
         public static final int HELP = 9;
@@ -71,7 +71,7 @@
         public static final int VIDEOCALL = 12;
         public static final int EMAIL = 13;
         public static final int SIPCALL = 14;
-        public static final int MAP = 15;
+        public static final int ADDRESS = 15;
         public static final int DIRECTIONS = 16;
         public static final int THIRD_PARTY = 17;
     }
diff --git a/src/com/android/contacts/editor/BaseRawContactEditorView.java b/src/com/android/contacts/editor/BaseRawContactEditorView.java
index fc1e8a1..1cdfafb 100644
--- a/src/com/android/contacts/editor/BaseRawContactEditorView.java
+++ b/src/com/android/contacts/editor/BaseRawContactEditorView.java
@@ -81,6 +81,7 @@
 
         mAccountHeaderContainer = findViewById(R.id.account_header_container);
         mExpandAccountButton = (ImageView) findViewById(R.id.account_expander_icon);
+        mExpandAccountButton.setColorFilter(R.color.quantum_black_secondary_text);
         mCollapsibleSection = (LinearLayout) findViewById(R.id.collapsable_section);
         mAccountName = (TextView) findViewById(R.id.account_name);
         mAccountType = (TextView) findViewById(R.id.account_type);
@@ -187,11 +188,13 @@
         if (isCollapsed) {
             params.height = 0;
             mCollapsibleSection.setLayoutParams(params);
-            mExpandAccountButton.setImageResource(R.drawable.ic_menu_expander_minimized_holo_light);
+            mExpandAccountButton.setImageDrawable(getContext().getDrawable(
+                    R.drawable.ic_menu_expand_minimized_24dp));
         } else {
             params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
             mCollapsibleSection.setLayoutParams(params);
-            mExpandAccountButton.setImageResource(R.drawable.ic_menu_expander_maximized_holo_light);
+            mExpandAccountButton.setImageDrawable(getContext().getDrawable(
+                    R.drawable.ic_menu_expand_maximized_24dp));
         }
     }
 
diff --git a/src/com/android/contacts/editor/TextFieldsEditorView.java b/src/com/android/contacts/editor/TextFieldsEditorView.java
index df201e1..564a9f5 100644
--- a/src/com/android/contacts/editor/TextFieldsEditorView.java
+++ b/src/com/android/contacts/editor/TextFieldsEditorView.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.provider.ContactsContract;
@@ -39,9 +40,9 @@
 import android.widget.LinearLayout;
 
 import com.android.contacts.R;
-import com.android.contacts.common.model.RawContactDelta;
-import com.android.contacts.common.compat.PhoneNumberUtilsCompat;
 import com.android.contacts.common.ContactsUtils;
+import com.android.contacts.common.compat.PhoneNumberUtilsCompat;
+import com.android.contacts.common.model.RawContactDelta;
 import com.android.contacts.common.model.ValuesDelta;
 import com.android.contacts.common.model.account.AccountType.EditField;
 import com.android.contacts.common.model.dataitem.DataKind;
@@ -165,9 +166,10 @@
      * Creates or removes the type/label button. Doesn't do anything if already correctly configured
      */
     private void setupExpansionView(boolean shouldExist, boolean collapsed) {
-        mExpansionView.setImageResource(collapsed
-                ? R.drawable.ic_menu_expander_minimized_holo_light
-                : R.drawable.ic_menu_expander_maximized_holo_light);
+        final Drawable expandIcon = getContext().getDrawable(collapsed
+                ? R.drawable.ic_menu_expand_minimized_24dp
+                : R.drawable.ic_menu_expand_maximized_24dp);
+        mExpansionView.setImageDrawable(expandIcon);
         mExpansionViewContainer.setVisibility(shouldExist ? View.VISIBLE : View.INVISIBLE);
     }
 
@@ -226,7 +228,8 @@
             fieldView.setInputType(inputType);
             if (inputType == InputType.TYPE_CLASS_PHONE) {
                 PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(
-                        getContext(), fieldView, /* formatAfterWatcherSet =*/ false);
+                        getContext(), fieldView,
+                        /* formatAfterWatcherSet =*/ state.isContactInsert());
                 fieldView.setTextDirection(View.TEXT_DIRECTION_LTR);
             }
             fieldView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
diff --git a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
index da017cc..018f468 100644
--- a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
+++ b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
@@ -244,8 +244,6 @@
     private View mExpandCollapseButton;
     private TextView mExpandCollapseTextView;
     private TextView mTitleTextView;
-    private CharSequence mExpandButtonText;
-    private CharSequence mCollapseButtonText;
     private OnClickListener mOnClickListener;
     private OnCreateContextMenuListener mOnCreateContextMenuListener;
     private boolean mIsExpanded = false;
@@ -263,11 +261,6 @@
     private final ImageView mExpandCollapseArrow;
     private int mThemeColor;
     private ColorFilter mThemeColorFilter;
-    /**
-     * Whether to prioritize the first entry type. If prioritized, we should show at least two
-     * of this entry type.
-     */
-    private boolean mShowFirstEntryTypeTwice;
     private boolean mIsAlwaysExpanded;
     /** The ViewGroup to run the expand/collapse animation on */
     private ViewGroup mAnimationViewGroup;
@@ -319,22 +312,14 @@
         mBadgeIds = new ArrayList<Integer>();
     }
 
-    public void initialize(List<List<Entry>> entries, int numInitialVisibleEntries,
-            boolean isExpanded, boolean isAlwaysExpanded, ExpandingEntryCardViewListener listener,
-            ViewGroup animationViewGroup) {
-        initialize(entries, numInitialVisibleEntries, isExpanded, isAlwaysExpanded,
-                listener, animationViewGroup, /* showFirstEntryTypeTwice = */ false);
-    }
-
     /**
      * Sets the Entry list to display.
      *
      * @param entries The Entry list to display.
      */
     public void initialize(List<List<Entry>> entries, int numInitialVisibleEntries,
-            boolean isExpanded, boolean isAlwaysExpanded,
-            ExpandingEntryCardViewListener listener, ViewGroup animationViewGroup,
-            boolean showFirstEntryTypeTwice) {
+            boolean isExpanded, boolean isAlwaysExpanded, ExpandingEntryCardViewListener listener,
+            ViewGroup animationViewGroup) {
         LayoutInflater layoutInflater = LayoutInflater.from(getContext());
         mIsExpanded = isExpanded;
         mIsAlwaysExpanded = isAlwaysExpanded;
@@ -344,7 +329,6 @@
         mEntries = entries;
         mNumEntries = 0;
         mAllEntriesInflated = false;
-        mShowFirstEntryTypeTwice = showFirstEntryTypeTwice;
         for (List<Entry> entryList : mEntries) {
             mNumEntries += entryList.size();
             mEntryViews.add(new ArrayList<View>());
@@ -368,30 +352,6 @@
         applyColor();
     }
 
-    /**
-     * Sets the text for the expand button.
-     *
-     * @param expandButtonText The expand button text.
-     */
-    public void setExpandButtonText(CharSequence expandButtonText) {
-        mExpandButtonText = expandButtonText;
-        if (mExpandCollapseTextView != null && !mIsExpanded) {
-            mExpandCollapseTextView.setText(expandButtonText);
-        }
-    }
-
-    /**
-     * Sets the text for the expand button.
-     *
-     * @param expandButtonText The expand button text.
-     */
-    public void setCollapseButtonText(CharSequence expandButtonText) {
-        mCollapseButtonText = expandButtonText;
-        if (mExpandCollapseTextView != null && mIsExpanded) {
-            mExpandCollapseTextView.setText(mCollapseButtonText);
-        }
-    }
-
     @Override
     public void setOnClickListener(OnClickListener listener) {
         mOnClickListener = listener;
@@ -468,19 +428,9 @@
                 viewsToDisplay.add(entryViewList.get(0));
                 numInViewGroup++;
 
-                int indexInEntryViewList = 1;
-                if (mShowFirstEntryTypeTwice && i == 0 && entryViewList.size() > 1) {
-                    viewsToDisplay.add(entryViewList.get(1));
-                    numInViewGroup++;
-                    extraEntries--;
-                    indexInEntryViewList++;
-                }
-
                 // Insert entries in this list to hit mCollapsedEntriesCount.
-                for (int j = indexInEntryViewList;
-                        j < entryViewList.size() && numInViewGroup < mCollapsedEntriesCount &&
-                        extraEntries > 0;
-                        j++) {
+                for (int j = 1; j < entryViewList.size() && numInViewGroup < mCollapsedEntriesCount
+                        && extraEntries > 0; j++) {
                     viewsToDisplay.add(entryViewList.get(j));
                     numInViewGroup++;
                     extraEntries--;
@@ -532,21 +482,13 @@
     }
 
     private CharSequence getExpandButtonText() {
-        if (!TextUtils.isEmpty(mExpandButtonText)) {
-            return mExpandButtonText;
-        } else {
-            // Default to "See more".
-            return getResources().getText(R.string.expanding_entry_card_view_see_more);
-        }
+        // Default to "See more".
+        return getResources().getText(R.string.expanding_entry_card_view_see_more);
     }
 
     private CharSequence getCollapseButtonText() {
-        if (!TextUtils.isEmpty(mCollapseButtonText)) {
-            return mCollapseButtonText;
-        } else {
-            // Default to "See less".
-            return getResources().getText(R.string.expanding_entry_card_view_see_less);
-        }
+        // Default to "See less".
+        return getResources().getText(R.string.expanding_entry_card_view_see_less);
     }
 
     /**
@@ -569,18 +511,8 @@
                         /* showIcon = */ View.VISIBLE));
                 numInflated++;
 
-                int indexInEntryViewList = 1;
-                if (mShowFirstEntryTypeTwice && i == 0 && entryList.size() > 1) {
-                    entryViewList.add(createEntryView(layoutInflater, entryList.get(1),
-                        /* showIcon = */ View.INVISIBLE));
-                    numInflated++;
-                    extraEntries--;
-                    indexInEntryViewList++;
-                }
-
                 // Inflate entries in this list to hit mCollapsedEntriesCount.
-                for (int j = indexInEntryViewList; j < entryList.size()
-                        && numInflated < mCollapsedEntriesCount
+                for (int j = 1; j < entryList.size() && numInflated < mCollapsedEntriesCount
                         && extraEntries > 0; j++) {
                     entryViewList.add(createEntryView(layoutInflater, entryList.get(j),
                             /* showIcon = */ View.INVISIBLE));
@@ -851,10 +783,7 @@
             mBadgeContainer.removeAllViews();
         } else {
             int numberOfMimeTypesShown = mCollapsedEntriesCount;
-            if (mShowFirstEntryTypeTwice && mEntries.size() > 0
-                    && mEntries.get(0).size() > 1) {
-                numberOfMimeTypesShown--;
-            }
+
             // Inflate badges if not yet created
             if (mBadges.size() < mEntries.size() - numberOfMimeTypesShown) {
                 for (int i = numberOfMimeTypesShown; i < mEntries.size(); i++) {
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index fc43b9e..40bcd55 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -977,7 +977,7 @@
             return;
         }
 
-        mIsRecreatedInstance = (savedInstanceState != null);
+        mIsRecreatedInstance = savedInstanceState != null;
         mShouldLog = true;
 
         // There're 3 states for each permission:
@@ -1106,8 +1106,6 @@
         mPermissionExplanationCard.setOnClickListener(mEntryClickHandler);
         mNoContactDetailsCard.setOnClickListener(mEntryClickHandler);
         mContactCard.setOnClickListener(mEntryClickHandler);
-        mContactCard.setExpandButtonText(
-        getResources().getString(R.string.expanding_entry_card_view_see_all));
         mContactCard.setOnCreateContextMenuListener(mEntryContextMenuListener);
 
         mRecentCard.setOnClickListener(mEntryClickHandler);
@@ -1366,7 +1364,7 @@
             newContactType = ContactType.UNKNOWN_TYPE;
         }
         if (mShouldLog && mContactType != newContactType) {
-            Logger.logQuickContactEvent( mReferrer, newContactType, CardType.UNKNOWN_CARD,
+            Logger.logQuickContactEvent(mReferrer, newContactType, CardType.UNKNOWN_CARD,
                     actionType, /* thirdPartyAction */ null);
         }
         mContactType = newContactType;
@@ -1593,17 +1591,12 @@
         final String customAboutCardName = cp2DataCardModel.customAboutCardName;
 
         if (contactCardEntries.size() > 0) {
-            final boolean firstEntriesArePrioritizedMimeType =
-                    !TextUtils.isEmpty(mExtraPrioritizedMimeType) &&
-                    mCachedCp2DataCardModel.dataItemsMap.containsKey(mExtraPrioritizedMimeType) &&
-                    mCachedCp2DataCardModel.dataItemsMap.get(mExtraPrioritizedMimeType).size() != 0;
             mContactCard.initialize(contactCardEntries,
                     /* numInitialVisibleEntries = */ MIN_NUM_CONTACT_ENTRIES_SHOWN,
                     /* isExpanded = */ mContactCard.isExpanded(),
-                    /* isAlwaysExpanded = */ false,
+                    /* isAlwaysExpanded = */ true,
                     mExpandingEntryCardViewListener,
-                    mScroller,
-                    firstEntriesArePrioritizedMimeType);
+                    mScroller);
             if (mContactCard.getVisibility() == View.GONE && mShouldLog) {
                 Logger.logQuickContactEvent(mReferrer, mContactType, CardType.CONTACT,
                         ActionType.UNKNOWN_ACTION, /* thirdPartyAction */ null);
@@ -2121,7 +2114,7 @@
             if (!TextUtils.isEmpty(postalAddress)) {
                 primaryContentDescription.append(res.getString(R.string.map_other)).append(" ");
                 intent = StructuredPostalUtils.getViewPostalAddressIntent(postalAddress);
-                intent.putExtra(EXTRA_ACTION_TYPE, ActionType.MAP);
+                intent.putExtra(EXTRA_ACTION_TYPE, ActionType.ADDRESS);
                 header = postal.getFormattedAddress();
                 entryContextMenuInfo = new EntryContextMenuInfo(header,
                         res.getString(R.string.postalLabelsGroup), dataItem.getMimeType(),
@@ -3121,7 +3114,7 @@
                 return true;
             case R.id.menu_delete:
                 Logger.logQuickContactEvent(mReferrer, mContactType, CardType.UNKNOWN_CARD,
-                        ActionType.DELETE, /* thirdPartyAction */ null);
+                        ActionType.REMOVE, /* thirdPartyAction */ null);
                 if (isContactEditable()) {
                     deleteContact();
                 }