Show checkboxes for all entries except for Me

Bug: 19549465
Change-Id: I676baf82162e09904940f860fce4220f93857454
diff --git a/src/com/android/contacts/list/MultiSelectContactsListFragment.java b/src/com/android/contacts/list/MultiSelectContactsListFragment.java
index bdd0a6f..5e17aee 100644
--- a/src/com/android/contacts/list/MultiSelectContactsListFragment.java
+++ b/src/com/android/contacts/list/MultiSelectContactsListFragment.java
@@ -23,6 +23,7 @@
 
 import android.net.Uri;
 import android.os.Bundle;
+import android.text.TextUtils;
 
 import java.util.TreeSet;
 
@@ -102,9 +103,11 @@
             mCheckBoxListListener.onStartDisplayingCheckBoxes();
         }
         final Uri uri = getAdapter().getContactUri(position);
-        if (position > 0 && uri != null) {
+        if (uri != null && (position > 0 || !getAdapter().hasProfile())) {
             final String contactId = uri.getLastPathSegment();
-            getAdapter().toggleSelectionOfContactId(Long.valueOf(contactId));
+            if (!TextUtils.isEmpty(contactId)) {
+                getAdapter().toggleSelectionOfContactId(Long.valueOf(contactId));
+            }
         }
         return true;
     }
@@ -117,7 +120,9 @@
         }
         if (getAdapter().isDisplayingCheckBoxes()) {
             final String contactId = uri.getLastPathSegment();
-            getAdapter().toggleSelectionOfContactId(Long.valueOf(contactId));
+            if (!TextUtils.isEmpty(contactId)) {
+                getAdapter().toggleSelectionOfContactId(Long.valueOf(contactId));
+            }
         } else {
             super.onItemClick(position, id);
         }
diff --git a/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java b/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java
index 5acd570..39fc4e8 100644
--- a/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java
+++ b/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java
@@ -111,10 +111,10 @@
     private void bindCheckBox(ContactListItemView view, Cursor cursor, int position) {
         // Disable clicking on the first entry when showing check boxes. We do this by
         // telling the view to handle clicking itself.
-        view.setClickable(position == 0 && mDisplayCheckBoxes);
-        // Only show checkboxes is mDisplayCheckBoxes is enabled. Also, never show the
-        // checkbox for the first entry in the list (the Me profile).
-        if (position == 0 || !mDisplayCheckBoxes) {
+        view.setClickable(position == 0 && hasProfile() && mDisplayCheckBoxes);
+        // Only show checkboxes if mDisplayCheckBoxes is enabled. Also, never show the
+        // checkbox for the Me profile entry.
+        if (position == 0 && hasProfile() || !mDisplayCheckBoxes) {
             view.hideCheckBox();
             return;
         }