Merge "Adding common contact list view and card layout" into lmp-dev
diff --git a/src/com/android/contacts/common/model/Contact.java b/src/com/android/contacts/common/model/Contact.java
index 74b5596..9b96f86 100644
--- a/src/com/android/contacts/common/model/Contact.java
+++ b/src/com/android/contacts/common/model/Contact.java
@@ -85,6 +85,11 @@
     private ImmutableList<GroupMetaData> mGroups;
 
     private byte[] mPhotoBinaryData;
+    /**
+     * Small version of the contact photo loaded from a blob instead of from a file. If a large
+     * contact photo is not available yet, then this has the same value as mPhotoBinaryData.
+     */
+    private byte[] mThumbnailPhotoBinaryData;
     private final boolean mSendToVoicemail;
     private final String mCustomRingtone;
     private final boolean mIsUserProfile;
@@ -218,6 +223,10 @@
         mPhotoBinaryData = photoBinaryData;
     }
 
+    /* package */ void setThumbnailPhotoBinaryData(byte[] photoBinaryData) {
+        mThumbnailPhotoBinaryData = photoBinaryData;
+    }
+
     /**
      * Returns the URI for the contact that contains both the lookup key and the ID. This is
      * the best URI to reference a contact.
@@ -417,6 +426,10 @@
         return mPhotoBinaryData;
     }
 
+    public byte[] getThumbnailPhotoBinaryData() {
+        return mThumbnailPhotoBinaryData;
+    }
+
     public ArrayList<ContentValues> getContentValues() {
         if (mRawContacts.size() != 1) {
             throw new IllegalStateException(
diff --git a/src/com/android/contacts/common/model/ContactLoader.java b/src/com/android/contacts/common/model/ContactLoader.java
index 8305540..5f9c164 100644
--- a/src/com/android/contacts/common/model/ContactLoader.java
+++ b/src/com/android/contacts/common/model/ContactLoader.java
@@ -40,7 +40,6 @@
 
 import com.android.contacts.common.GeoUtil;
 import com.android.contacts.common.GroupMetaData;
-import com.android.contacts.common.model.AccountTypeManager;
 import com.android.contacts.common.model.account.AccountType;
 import com.android.contacts.common.model.account.AccountTypeWithDataSet;
 import com.android.contacts.common.util.Constants;
@@ -501,11 +500,13 @@
     }
 
     /**
-     * Looks for the photo data item in entities. If found, creates a new Bitmap instance. If
-     * not found, returns null
+     * Looks for the photo data item in entities. If found, a thumbnail will be stored. A larger
+     * photo will also be stored if available.
      */
     private void loadPhotoBinaryData(Contact contactData) {
-        // If we have a photo URI, try loading that first.
+        loadThumbnailBinaryData(contactData);
+
+        // Try to load the large photo from a file using the photo URI.
         String photoUri = contactData.getPhotoUri();
         if (photoUri != null) {
             try {
@@ -542,6 +543,10 @@
         }
 
         // If we couldn't load from a file, fall back to the data blob.
+        contactData.setPhotoBinaryData(contactData.getThumbnailPhotoBinaryData());
+    }
+
+    private void loadThumbnailBinaryData(Contact contactData) {
         final long photoId = contactData.getPhotoId();
         if (photoId <= 0) {
             // No photo ID
@@ -556,7 +561,7 @@
                     }
 
                     final PhotoDataItem photo = (PhotoDataItem) dataItem;
-                    contactData.setPhotoBinaryData(photo.getPhoto());
+                    contactData.setThumbnailPhotoBinaryData(photo.getPhoto());
                     break;
                 }
             }