Restyle "Set up my profile" option.

- Delete header count functionality.
- Relayout the "ME" header to the left of the profile button.
- Styling tweaks to get things to layout properly.

Change-Id: Icbadef9fb7b6e5acc7fc878948a8fe5c4985b394
diff --git a/res/layout/user_profile_button.xml b/res/layout/user_profile_button.xml
deleted file mode 100644
index 6a7c3b4..0000000
--- a/res/layout/user_profile_button.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<Button
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:minHeight="@dimen/contact_browser_list_item_photo_size"
-    android:layout_marginLeft="?attr/list_item_padding_left"
-    android:layout_marginRight="?attr/list_item_padding_right"
-    android:layout_marginStart="?attr/list_item_padding_left"
-    android:layout_marginEnd="?attr/list_item_padding_right"
-    android:paddingLeft="?attr/list_item_header_text_indent"
-    android:paddingStart="?attr/list_item_header_text_indent"
-    android:background="?android:attr/selectableItemBackground"
-    android:singleLine="true"
-    android:text="@string/profile_display_name"
-    android:ellipsize="end"
-    android:gravity="start|center_vertical"
-    android:textAppearance="?android:attr/textAppearanceMedium" />
diff --git a/res/layout/user_profile_header.xml b/res/layout/user_profile_header.xml
index 1d08298..5a07313 100644
--- a/res/layout/user_profile_header.xml
+++ b/res/layout/user_profile_header.xml
@@ -25,31 +25,32 @@
     android:paddingStart="?attr/list_item_padding_left"
     android:paddingEnd="?attr/list_item_padding_right"
     android:paddingTop="4dp"
-    android:paddingBottom="8dp"
-    android:background="@drawable/list_section_divider_holo_custom"
-    android:gravity="center_vertical"
-    >
+    android:paddingBottom="8dp" >
 
-    <TextView
-        android:id="@+id/profile_title"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+    <TextView android:id="@+id/profile_title"
+        android:layout_width="@dimen/contact_list_section_header_width"
+        android:layout_height="?android:attr/listPreferredItemHeight"
         android:singleLine="true"
         android:text="@string/user_profile_contacts_list_header"
         android:ellipsize="end"
-        android:layout_weight="1"
-        android:textAppearance="@style/DirectoryHeaderStyle"
-        android:paddingLeft="?attr/list_item_text_indent"
-        android:paddingStart="?attr/list_item_text_indent" />
+        android:textAppearance="@style/SectionHeaderStyle"
+        android:gravity="start|center_vertical" />
 
-    <TextView
-        android:id="@+id/contacts_count"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+    <Button android:id="@+id/user_profile_button"
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="?android:attr/listPreferredItemHeight"
+        android:layout_marginLeft="?attr/list_item_padding_left"
+        android:layout_marginRight="?attr/list_item_padding_right"
+        android:layout_marginStart="?attr/list_item_padding_left"
+        android:layout_marginEnd="?attr/list_item_padding_right"
+        android:paddingLeft="?attr/list_item_gap_between_image_and_text"
+        android:paddingStart="?attr/list_item_gap_between_image_and_text"
+        android:background="?android:attr/selectableItemBackground"
         android:singleLine="true"
+        android:text="@string/profile_display_name"
         android:ellipsize="end"
-        android:textAppearance="?android:attr/textAppearanceSmall"
-        android:textSize="12sp"
-        android:textColor="@color/people_app_theme_color" />
+        android:gravity="start|center_vertical"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
 
 </LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d88d688..5cad5f2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -258,12 +258,6 @@
     <!-- Displayed at the top of the contacts showing the zero as total number of contacts visible when "Only contacts with phones" is selected [CHAR LIMIT=64]-->
     <string name="listTotalPhoneContactsZero">No contacts with phone numbers</string>
 
-    <!-- Displayed at the top of the contacts showing the total number of contacts visible when "Only contacts with phones" not selected -->
-    <plurals name="listTotalAllContacts">
-        <item quantity="one">1 contact</item>
-        <item quantity="other"><xliff:g id="count">%d</xliff:g> contacts</item>
-    </plurals>
-
     <!-- Displayed at the top of the contacts showing the total number of contacts found when "Only contacts with phones" not selected [CHAR LIMIT=30] -->
     <plurals name="listFoundAllContacts">
         <item quantity="one">1 found</item>
diff --git a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
index 90495fa..b16b76e 100644
--- a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
@@ -19,9 +19,11 @@
 import android.content.CursorLoader;
 import android.content.Intent;
 import android.database.Cursor;
+import android.graphics.Color;
 import android.provider.ContactsContract.Contacts;
 import android.text.TextUtils;
 import android.util.Log;
+import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -39,6 +41,7 @@
 import com.android.contacts.common.list.ContactListItemView;
 import com.android.contacts.common.list.DefaultContactListAdapter;
 import com.android.contacts.common.list.ProfileAndContactsLoader;
+import com.android.contacts.common.util.ViewUtil;
 import com.android.contacts.editor.ContactEditorFragment;
 import com.android.contacts.common.util.AccountFilterUtil;
 
@@ -51,13 +54,11 @@
 
     private static final int REQUEST_CODE_ACCOUNT_FILTER = 1;
 
-    private TextView mCounterHeaderView;
     private View mSearchHeaderView;
     private View mAccountFilterHeader;
     private FrameLayout mProfileHeaderContainer;
     private View mProfileHeader;
     private Button mProfileMessage;
-    private FrameLayout mMessageContainer;
     private TextView mProfileTitle;
     private View mSearchProgress;
     private TextView mSearchProgressText;
@@ -113,7 +114,6 @@
 
         mAccountFilterHeader = getView().findViewById(R.id.account_filter_header_container);
         mAccountFilterHeader.setOnClickListener(mFilterHeaderClickListener);
-        mCounterHeaderView = (TextView) getView().findViewById(R.id.contacts_count);
 
         // Create an empty user profile header and hide it for now (it will be visible if the
         // contacts list will have no user profile).
@@ -145,12 +145,9 @@
     }
 
     private void checkHeaderViewVisibility() {
-        if (mCounterHeaderView != null) {
-            mCounterHeaderView.setVisibility(isSearchMode() ? View.GONE : View.VISIBLE);
-        }
         updateFilterHeaderView();
 
-        // Hide the search header by default. See showCount().
+        // Hide the search header by default.
         if (mSearchHeaderView != null) {
             mSearchHeaderView.setVisibility(View.GONE);
         }
@@ -177,43 +174,11 @@
     }
 
     @Override
-    protected void showCount(int partitionIndex, Cursor data) {
-        if (!isSearchMode() && data != null) {
-            int count = data.getCount();
-            if (count != 0) {
-                count -= (mUserProfileExists ? 1: 0);
-                String format = getResources().getQuantityText(
-                        R.plurals.listTotalAllContacts, count).toString();
-                // Do not count the user profile in the contacts count
-                if (mUserProfileExists) {
-                    getAdapter().setContactsCount(String.format(format, count));
-                } else {
-                    mCounterHeaderView.setText(String.format(format, count));
-                }
-            } else {
-                ContactListFilter filter = getFilter();
-                int filterType = filter != null ? filter.filterType
-                        : ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS;
-                switch (filterType) {
-                    case ContactListFilter.FILTER_TYPE_ACCOUNT:
-                        mCounterHeaderView.setText(getString(
-                                R.string.listTotalAllContactsZeroGroup, filter.accountName));
-                        break;
-                    case ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY:
-                        mCounterHeaderView.setText(R.string.listTotalPhoneContactsZero);
-                        break;
-                    case ContactListFilter.FILTER_TYPE_STARRED:
-                        mCounterHeaderView.setText(R.string.listTotalAllContactsZeroStarred);
-                        break;
-                    case ContactListFilter.FILTER_TYPE_CUSTOM:
-                        mCounterHeaderView.setText(R.string.listTotalAllContactsZeroCustom);
-                        break;
-                    default:
-                        mCounterHeaderView.setText(R.string.listTotalAllContactsZero);
-                        break;
-                }
-            }
-        } else {
+    protected void setProfileHeader() {
+        mUserProfileExists = getAdapter().hasProfile();
+        showEmptyUserProfile(!mUserProfileExists && !isSearchMode());
+
+        if (isSearchMode()) {
             ContactListAdapter adapter = getAdapter();
             if (adapter == null) {
                 return;
@@ -240,12 +205,6 @@
     }
 
     @Override
-    protected void setProfileHeader() {
-        mUserProfileExists = getAdapter().hasProfile();
-        showEmptyUserProfile(!mUserProfileExists && !isSearchMode());
-    }
-
-    @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         if (requestCode == REQUEST_CODE_ACCOUNT_FILTER) {
             if (getActivity() != null) {
@@ -263,9 +222,7 @@
         // and mProfileTitle
         mProfileHeaderContainer.setVisibility(show ? View.VISIBLE : View.GONE);
         mProfileHeader.setVisibility(show ? View.VISIBLE : View.GONE);
-        mCounterHeaderView.setVisibility(show ? View.VISIBLE : View.GONE);
         mProfileTitle.setVisibility(show ? View.VISIBLE : View.GONE);
-        mMessageContainer.setVisibility(show ? View.VISIBLE : View.GONE);
         mProfileMessage.setVisibility(show ? View.VISIBLE : View.GONE);
     }
 
@@ -276,24 +233,17 @@
      * 2. A button that prompts the user to create a local profile
      */
     private void addEmptyUserProfileHeader(LayoutInflater inflater) {
-
         ListView list = getListView();
-        // Put a header with the "ME" name and a view for the number of contacts
-        // The view is embedded in a frame view since you cannot change the visibility of a
-        // view in a ListView without having a parent view.
-        mProfileHeaderContainer = new FrameLayout(inflater.getContext());
+        // Add a header with the "ME" name. The view is embedded in a frame view since you cannot
+        // change the visibility of a view in a ListView without having a parent view.
         mProfileHeader = inflater.inflate(R.layout.user_profile_header, null, false);
-        mCounterHeaderView = (TextView) mProfileHeader.findViewById(R.id.contacts_count);
         mProfileTitle = (TextView) mProfileHeader.findViewById(R.id.profile_title);
+        mProfileHeaderContainer = new FrameLayout(inflater.getContext());
         mProfileHeaderContainer.addView(mProfileHeader);
         list.addHeaderView(mProfileHeaderContainer, null, false);
 
-        // Add a selectable view with a message inviting the user to create a local profile
-        mMessageContainer = new FrameLayout(inflater.getContext());
-        mProfileMessage = (Button)inflater.inflate(R.layout.user_profile_button, null, false);
-        mMessageContainer.addView(mProfileMessage);
-        list.addHeaderView(mMessageContainer, null, true);
-
+        // Add a button with a message inviting the user to create a local profile
+        mProfileMessage = (Button) mProfileHeader.findViewById(R.id.user_profile_button);
         mProfileMessage.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);