Use CONTACT_ID field for the quick contact badge.

Currently the code uses the PHOTO_ID as the id of the contact that is
used to open the quick contact badge, which is not the correct
identifier.

Change-Id: I5ada4e2e8e7924d6212e7e8b472a131fcf18e80d
diff --git a/src/com/android/contacts/list/ContactEntryListAdapter.java b/src/com/android/contacts/list/ContactEntryListAdapter.java
index 69b0077..06e31e3 100644
--- a/src/com/android/contacts/list/ContactEntryListAdapter.java
+++ b/src/com/android/contacts/list/ContactEntryListAdapter.java
@@ -622,7 +622,7 @@
     // TODO: move sharable logic (bindXX() methods) to here with extra arguments
 
     protected void bindQuickContact(final ContactListItemView view, int partitionIndex,
-            Cursor cursor, int photoIdColumn, int lookUpKeyColumn) {
+            Cursor cursor, int photoIdColumn, int contactIdColumn, int lookUpKeyColumn) {
         long photoId = 0;
         if (!cursor.isNull(photoIdColumn)) {
             photoId = cursor.getLong(photoIdColumn);
@@ -630,13 +630,13 @@
 
         QuickContactBadge quickContact = view.getQuickContact();
         quickContact.assignContactUri(
-                getContactUri(partitionIndex, cursor, photoIdColumn, lookUpKeyColumn));
+                getContactUri(partitionIndex, cursor, contactIdColumn, lookUpKeyColumn));
         getPhotoLoader().loadPhoto(quickContact, photoId);
     }
 
     protected Uri getContactUri(int partitionIndex, Cursor cursor,
-            int photoIdColumn, int lookUpKeyColumn) {
-        long contactId = cursor.getLong(photoIdColumn);
+            int contactIdColumn, int lookUpKeyColumn) {
+        long contactId = cursor.getLong(contactIdColumn);
         String lookupKey = cursor.getString(lookUpKeyColumn);
         Uri uri = Contacts.getLookupUri(contactId, lookupKey);
         long directoryId = ((DirectoryPartition)getPartition(partitionIndex)).getDirectoryId();
diff --git a/src/com/android/contacts/list/DefaultContactListAdapter.java b/src/com/android/contacts/list/DefaultContactListAdapter.java
index 5ba1d8e..7f96906 100644
--- a/src/com/android/contacts/list/DefaultContactListAdapter.java
+++ b/src/com/android/contacts/list/DefaultContactListAdapter.java
@@ -225,7 +225,8 @@
 
         if (isQuickContactEnabled()) {
             bindQuickContact(view, partition, cursor,
-                    CONTACT_PHOTO_ID_COLUMN_INDEX, CONTACT_LOOKUP_KEY_COLUMN_INDEX);
+                    CONTACT_PHOTO_ID_COLUMN_INDEX, CONTACT_ID_COLUMN_INDEX,
+                    CONTACT_LOOKUP_KEY_COLUMN_INDEX);
         } else {
             bindPhoto(view, partition, cursor);
         }
diff --git a/src/com/android/contacts/list/PhoneNumberListAdapter.java b/src/com/android/contacts/list/PhoneNumberListAdapter.java
index 109d857..9e1cb93 100644
--- a/src/com/android/contacts/list/PhoneNumberListAdapter.java
+++ b/src/com/android/contacts/list/PhoneNumberListAdapter.java
@@ -24,14 +24,12 @@
 import android.provider.ContactsContract;
 import android.provider.ContactsContract.CommonDataKinds.Phone;
 import android.provider.ContactsContract.ContactCounts;
-import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.Directory;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.QuickContactBadge;
 
 /**
  * A cursor adapter for the {@link Phone#CONTENT_TYPE} content type.
@@ -208,7 +206,8 @@
             bindName(view, cursor);
             if (isQuickContactEnabled()) {
                 bindQuickContact(view, partition, cursor,
-                        PHONE_PHOTO_ID_COLUMN_INDEX, PHONE_LOOKUP_KEY_COLUMN_INDEX);
+                        PHONE_PHOTO_ID_COLUMN_INDEX, PHONE_CONTACT_ID_COLUMN_INDEX,
+                        PHONE_LOOKUP_KEY_COLUMN_INDEX);
             } else {
                 bindPhoto(view, cursor);
             }