Merge "Hide favorties in account view and stop loading ME (1/2)"
diff --git a/res/layout/user_profile_header.xml b/res/layout/user_profile_header.xml
deleted file mode 100644
index 828f08c..0000000
--- a/res/layout/user_profile_header.xml
+++ /dev/null
@@ -1,52 +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.
--->
-
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/user_profile_header"
-    android:orientation="horizontal"
-    android:layout_width="match_parent"
-    android:layout_height="?attr/list_item_header_height"
-    android:paddingLeft="?attr/list_item_padding_left"
-    android:paddingRight="?attr/list_item_padding_right"
-    android:paddingStart="?attr/list_item_padding_left"
-    android:paddingEnd="?attr/list_item_padding_right"
-    android:paddingTop="4dp"
-    android:paddingBottom="8dp" >
-
-    <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:textAppearance="@style/SectionHeaderStyle"
-        android:gravity="start|center_vertical" />
-
-    <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:paddingStart="?attr/list_item_padding_left"
-        android:paddingEnd="?attr/list_item_padding_right"
-        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" />
-
-</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1f6c80a..37e276f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -624,10 +624,6 @@
         <xliff:g id="call_type" example="Friends">%1$s</xliff:g>  <xliff:g id="call_short_date" example="Friends">%2$s</xliff:g>
     </string>
 
-    <!-- Text displayed in place of the display name for the contact that represents the user's
-      personal profile entry [CHAR LIMIT=64] -->
-    <string name="profile_display_name">Set up my profile</string>
-
     <!-- Label to instruct the user to type in a contact's name to add the contact as a member of the current group. [CHAR LIMIT=64] -->
     <string name="enter_contact_name">Type person\'s name</string>
 
diff --git a/src/com/android/contacts/activities/ContactSelectionActivity.java b/src/com/android/contacts/activities/ContactSelectionActivity.java
index c2951d8..50f50dd 100644
--- a/src/com/android/contacts/activities/ContactSelectionActivity.java
+++ b/src/com/android/contacts/activities/ContactSelectionActivity.java
@@ -290,7 +290,6 @@
             case ContactsRequest.ACTION_DEFAULT:
             case ContactsRequest.ACTION_PICK_CONTACT: {
                 ContactPickerFragment fragment = new ContactPickerFragment();
-                fragment.setIncludeProfile(mRequest.shouldIncludeProfile());
                 fragment.setIncludeFavorites(mRequest.shouldIncludeFavorites());
                 mListFragment = fragment;
                 break;
diff --git a/src/com/android/contacts/list/ContactBrowseListFragment.java b/src/com/android/contacts/list/ContactBrowseListFragment.java
index afd2543..4b4b326 100644
--- a/src/com/android/contacts/list/ContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/ContactBrowseListFragment.java
@@ -401,11 +401,8 @@
             }
         }
 
-        // Display the user's profile if not in search mode
-        adapter.setIncludeProfile(!searchMode);
-
-        // Display favorites if not in search mode
-        adapter.setIncludeFavorites(!searchMode);
+        adapter.setIncludeFavorites(!searchMode
+                && mFilter.filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS);
     }
 
     @Override
diff --git a/src/com/android/contacts/list/ContactsRequest.java b/src/com/android/contacts/list/ContactsRequest.java
index f867549..a1428be 100644
--- a/src/com/android/contacts/list/ContactsRequest.java
+++ b/src/com/android/contacts/list/ContactsRequest.java
@@ -85,7 +85,6 @@
     private CharSequence mTitle;
     private boolean mSearchMode;
     private String mQueryString;
-    private boolean mIncludeProfile;
     private boolean mIncludeFavorites;
     private boolean mLegacyCompatibilityMode;
     private boolean mDirectorySearchEnabled = true;
@@ -98,7 +97,6 @@
                 + " mTitle=" + mTitle
                 + " mSearchMode=" + mSearchMode
                 + " mQueryString=" + mQueryString
-                + " mIncludeProfile=" + mIncludeProfile
                 + " mIncludeFavorites=" + mIncludeFavorites
                 + " mLegacyCompatibilityMode=" + mLegacyCompatibilityMode
                 + " mDirectorySearchEnabled=" + mDirectorySearchEnabled
@@ -146,14 +144,6 @@
         mQueryString = string;
     }
 
-    public boolean shouldIncludeProfile() {
-        return mIncludeProfile;
-    }
-
-    public void setIncludeProfile(boolean includeProfile) {
-        mIncludeProfile = includeProfile;
-    }
-
     public boolean shouldIncludeFavorites() {
         return mIncludeFavorites;
     }
diff --git a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
index 2ce22c0..672e63e 100644
--- a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
@@ -17,29 +17,22 @@
 
 import android.content.Context;
 import android.content.CursorLoader;
-import android.content.Intent;
 import android.net.Uri;
 import android.provider.ContactsContract.Contacts;
 import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.accessibility.AccessibilityEvent;
-import android.widget.Button;
 import android.widget.FrameLayout;
 import android.widget.ListView;
 import android.widget.TextView;
 
 import com.android.contacts.R;
 import com.android.contacts.common.list.ContactListAdapter;
-import com.android.contacts.common.list.ContactListFilter;
 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.ImplicitIntentsUtil;
-import com.android.contacts.editor.ContactEditorFragment;
-import com.android.contacts.common.util.AccountFilterUtil;
+import com.android.contacts.common.list.FavoritesAndContactsLoader;
 
 /**
  * Fragment containing a contact list used for browsing (as compared to
@@ -49,11 +42,6 @@
     private static final String TAG = DefaultContactBrowseListFragment.class.getSimpleName();
 
     private View mSearchHeaderView;
-    private View mAccountFilterHeader;
-    private FrameLayout mProfileHeaderContainer;
-    private View mProfileHeader;
-    private Button mProfileMessage;
-    private TextView mProfileTitle;
     private View mSearchProgress;
     private TextView mSearchProgressText;
 
@@ -68,7 +56,7 @@
 
     @Override
     public CursorLoader createCursorLoader(Context context) {
-        return new ProfileAndContactsLoader(context);
+        return new FavoritesAndContactsLoader(context);
     }
 
     @Override
@@ -99,11 +87,6 @@
     protected void onCreateView(LayoutInflater inflater, ViewGroup container) {
         super.onCreateView(inflater, container);
 
-        // Create an empty user profile header and hide it for now (it will be visible if the
-        // contacts list will have no user profile).
-        addEmptyUserProfileHeader(inflater);
-        showEmptyUserProfile(false);
-
         // Putting the header view inside a container will allow us to make
         // it invisible later. See checkHeaderViewVisibility()
         FrameLayout headerContainer = new FrameLayout(inflater.getContext());
@@ -138,70 +121,30 @@
     }
 
     @Override
-    protected void setProfileHeader() {
-        mUserProfileExists = getAdapter().hasProfile();
-        showEmptyUserProfile(!mUserProfileExists && !isSearchMode());
-
-        if (isSearchMode()) {
-            ContactListAdapter adapter = getAdapter();
-            if (adapter == null) {
-                return;
-            }
-
-            // In search mode we only display the header if there is nothing found
-            if (TextUtils.isEmpty(getQueryString()) || !adapter.areAllPartitionsEmpty()) {
-                mSearchHeaderView.setVisibility(View.GONE);
-                showSearchProgress(false);
-            } else {
-                mSearchHeaderView.setVisibility(View.VISIBLE);
-                if (adapter.isLoading()) {
-                    mSearchProgressText.setText(R.string.search_results_searching);
-                    showSearchProgress(true);
-                } else {
-                    mSearchProgressText.setText(R.string.listFoundAllContactsZero);
-                    mSearchProgressText.sendAccessibilityEvent(
-                            AccessibilityEvent.TYPE_VIEW_SELECTED);
-                    showSearchProgress(false);
-                }
-            }
-            showEmptyUserProfile(false);
+    protected void setListHeader() {
+        if (!isSearchMode()) {
+            return;
         }
-    }
+        ContactListAdapter adapter = getAdapter();
+        if (adapter == null) {
+            return;
+        }
 
-    private void showEmptyUserProfile(boolean show) {
-        // Changing visibility of just the mProfileHeader doesn't do anything unless
-        // you change visibility of its children, hence the call to mCounterHeaderView
-        // and mProfileTitle
-        mProfileHeaderContainer.setVisibility(show ? View.VISIBLE : View.GONE);
-        mProfileHeader.setVisibility(show ? View.VISIBLE : View.GONE);
-        mProfileTitle.setVisibility(show ? View.VISIBLE : View.GONE);
-        mProfileMessage.setVisibility(show ? View.VISIBLE : View.GONE);
-    }
-
-    /**
-     * This method creates a pseudo user profile contact. When the returned query doesn't have
-     * a profile, this methods creates 2 views that are inserted as headers to the listview:
-     * 1. A header view with the "ME" title and the contacts count.
-     * 2. A button that prompts the user to create a local profile
-     */
-    private void addEmptyUserProfileHeader(LayoutInflater inflater) {
-        ListView list = getListView();
-        // 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);
-        mProfileTitle = (TextView) mProfileHeader.findViewById(R.id.profile_title);
-        mProfileHeaderContainer = new FrameLayout(inflater.getContext());
-        mProfileHeaderContainer.addView(mProfileHeader);
-        list.addHeaderView(mProfileHeaderContainer, null, false);
-
-        // 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);
-                intent.putExtra(ContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE, true);
-                ImplicitIntentsUtil.startActivityInApp(getActivity(), intent);
+        // In search mode we only display the header if there is nothing found
+        if (TextUtils.isEmpty(getQueryString()) || !adapter.areAllPartitionsEmpty()) {
+            mSearchHeaderView.setVisibility(View.GONE);
+            showSearchProgress(false);
+        } else {
+            mSearchHeaderView.setVisibility(View.VISIBLE);
+            if (adapter.isLoading()) {
+                mSearchProgressText.setText(R.string.search_results_searching);
+                showSearchProgress(true);
+            } else {
+                mSearchProgressText.setText(R.string.listFoundAllContactsZero);
+                mSearchProgressText.sendAccessibilityEvent(
+                        AccessibilityEvent.TYPE_VIEW_SELECTED);
+                showSearchProgress(false);
             }
-        });
+        }
     }
 }
diff --git a/src/com/android/contacts/list/MultiSelectContactsListFragment.java b/src/com/android/contacts/list/MultiSelectContactsListFragment.java
index 76dd3f3..8dd18c1 100644
--- a/src/com/android/contacts/list/MultiSelectContactsListFragment.java
+++ b/src/com/android/contacts/list/MultiSelectContactsListFragment.java
@@ -144,8 +144,7 @@
         final int previouslySelectedCount = getAdapter().getSelectedContactIds().size();
         final Uri uri = getAdapter().getContactUri(position);
         final int partition = getAdapter().getPartitionForPosition(position);
-        if (uri != null && (partition == ContactsContract.Directory.DEFAULT
-                && (position > 0 || !getAdapter().hasProfile()))) {
+        if (uri != null && partition == ContactsContract.Directory.DEFAULT) {
             final String contactId = uri.getLastPathSegment();
             if (!TextUtils.isEmpty(contactId)) {
                 if (mCheckBoxListListener != null) {
diff --git a/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java b/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java
index b080657..5a54c51 100644
--- a/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java
+++ b/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java
@@ -115,13 +115,12 @@
 
     private void bindCheckBox(ContactListItemView view, Cursor cursor, int position,
             boolean isLocalDirectory) {
-        // Disable clicking on the ME profile and all contacts from remote directories
-        // when showing check boxes. We do this by telling the view to handle clicking itself.
-        view.setClickable((position == 0 && hasProfile() || !isLocalDirectory)
-                && mDisplayCheckBoxes);
+        // Disable clicking on all contacts from remote directories when showing check boxes. We do
+        // this by telling the view to handle clicking itself.
+        view.setClickable(!isLocalDirectory && mDisplayCheckBoxes);
         // Only show checkboxes if mDisplayCheckBoxes is enabled. Also, never show the
-        // checkbox for the Me profile entry and other directory contacts except local directory.
-        if (position == 0 && hasProfile() || !mDisplayCheckBoxes || !isLocalDirectory) {
+        // checkbox for other directory contacts except local directory.
+        if (!mDisplayCheckBoxes || !isLocalDirectory) {
             view.hideCheckBox();
             return;
         }