Use highres pictures in call-log (if available)
Change-Id: I71df0f38ab27b5ff1cb223a0b609b3e384e75224
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index cce48dd..e014938 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -103,7 +103,7 @@
PhoneLookup.LABEL,
PhoneLookup.NUMBER,
PhoneLookup.NORMALIZED_NUMBER,
- PhoneLookup.PHOTO_ID,
+ PhoneLookup.PHOTO_URI,
};
static final int COLUMN_INDEX_ID = 0;
static final int COLUMN_INDEX_NAME = 1;
@@ -111,7 +111,7 @@
static final int COLUMN_INDEX_LABEL = 3;
static final int COLUMN_INDEX_NUMBER = 4;
static final int COLUMN_INDEX_NORMALIZED_NUMBER = 5;
- static final int COLUMN_INDEX_PHOTO_ID = 6;
+ static final int COLUMN_INDEX_PHOTO_URI = 6;
@Override
protected void onCreate(Bundle icicle) {
@@ -220,7 +220,7 @@
// We know that all calls are from the same number and the same contact, so pick the first.
mNumber = details[0].number.toString();
final long personId = details[0].personId;
- final long photoId = details[0].photoId;
+ final Uri photoUri = details[0].photoUri;
// Set the details header, based on the first phone call.
mPhoneCallDetailsHelper.setPhoneCallDetails(mPhoneCallDetailsViews,
@@ -327,7 +327,7 @@
ListView historyList = (ListView) findViewById(R.id.history);
historyList.setAdapter(
new CallDetailHistoryAdapter(this, mInflater, mCallTypeHelper, details));
- loadContactPhotos(photoId);
+ loadContactPhotos(photoUri);
}
/** Return the phone call details for a given call log URI. */
@@ -356,7 +356,7 @@
int numberType = 0;
CharSequence numberLabel = "";
long personId = -1L;
- long photoId = 0L;
+ Uri photoUri = null;
// If this is not a regular number, there is no point in looking it up in the contacts.
if (!mPhoneNumberHelper.canPlaceCallsTo(number)) {
numberText = mPhoneNumberHelper.getDisplayNumber(number, null);
@@ -370,7 +370,8 @@
if (phonesCursor != null && phonesCursor.moveToFirst()) {
personId = phonesCursor.getLong(COLUMN_INDEX_ID);
nameText = phonesCursor.getString(COLUMN_INDEX_NAME);
- photoId = phonesCursor.getLong(COLUMN_INDEX_PHOTO_ID);
+ String photoUriString = phonesCursor.getString(COLUMN_INDEX_PHOTO_URI);
+ photoUri = photoUriString == null ? null : Uri.parse(photoUriString);
candidateNumberText = PhoneNumberUtils.formatNumber(
phonesCursor.getString(COLUMN_INDEX_NUMBER),
phonesCursor.getString(COLUMN_INDEX_NORMALIZED_NUMBER),
@@ -390,7 +391,7 @@
}
}
return new PhoneCallDetails(number, numberText, new int[]{ callType }, date, duration,
- nameText, numberType, numberLabel, personId, photoId);
+ nameText, numberType, numberLabel, personId, photoUri);
} finally {
if (callCursor != null) {
callCursor.close();
@@ -399,8 +400,8 @@
}
/** Load the contact photos and places them in the corresponding views. */
- private void loadContactPhotos(final long photoId) {
- mContactPhotoManager.loadPhoto(mContactBackgroundView, photoId);
+ private void loadContactPhotos(Uri photoUri) {
+ mContactPhotoManager.loadPhoto(mContactBackgroundView, photoUri);
}
private String getVoicemailNumber() {
diff --git a/src/com/android/contacts/PhoneCallDetails.java b/src/com/android/contacts/PhoneCallDetails.java
index 6ab47aa..d4786d9 100644
--- a/src/com/android/contacts/PhoneCallDetails.java
+++ b/src/com/android/contacts/PhoneCallDetails.java
@@ -16,6 +16,7 @@
package com.android.contacts;
+import android.net.Uri;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
@@ -45,19 +46,22 @@
public final CharSequence numberLabel;
/** The id of the contact associated with this phone call. */
public final long personId;
- /** The photo id of the contact associated with this phone call. */
- public final long photoId;
+ /**
+ * The photo uri of the picture of the contact that is associated with this phone call or
+ * null if there is none.
+ */
+ public final Uri photoUri;
/** Create the details for a call with a number not associated with a contact. */
public PhoneCallDetails(CharSequence number, CharSequence formattedNumber, int[] callTypes,
long date, long duration) {
- this(number, formattedNumber, callTypes, date, duration, "", 0, "", -1L, 0L);
+ this(number, formattedNumber, callTypes, date, duration, "", 0, "", -1L, null);
}
/** Create the details for a call with a number associated with a contact. */
public PhoneCallDetails(CharSequence number, CharSequence formattedNumber, int[] callTypes,
long date, long duration, CharSequence name, int numberType, CharSequence numberLabel,
- long personId, long photoId) {
+ long personId, Uri photoUri) {
this.number = number;
this.formattedNumber = formattedNumber;
this.callTypes = callTypes;
@@ -67,6 +71,6 @@
this.numberType = numberType;
this.numberLabel = numberLabel;
this.personId = personId;
- this.photoId = photoId;
+ this.photoUri = photoUri;
}
}
diff --git a/src/com/android/contacts/calllog/CallLogFragment.java b/src/com/android/contacts/calllog/CallLogFragment.java
index d4871ec..bf70e67 100644
--- a/src/com/android/contacts/calllog/CallLogFragment.java
+++ b/src/com/android/contacts/calllog/CallLogFragment.java
@@ -120,7 +120,7 @@
PhoneLookup.LABEL,
PhoneLookup.NUMBER,
PhoneLookup.NORMALIZED_NUMBER,
- PhoneLookup.PHOTO_ID,
+ PhoneLookup.PHOTO_THUMBNAIL_URI,
PhoneLookup.LOOKUP_KEY};
public static final int PERSON_ID = 0;
@@ -129,7 +129,7 @@
public static final int LABEL = 3;
public static final int MATCHED_NUMBER = 4;
public static final int NORMALIZED_NUMBER = 5;
- public static final int PHOTO_ID = 6;
+ public static final int THUMBNAIL_URI = 6;
public static final int LOOKUP_KEY = 7;
}
@@ -158,7 +158,7 @@
public String number;
public String formattedNumber;
public String normalizedNumber;
- public long photoId;
+ public Uri thumbnailUri;
public String lookupKey;
public static ContactInfo EMPTY = new ContactInfo();
@@ -170,7 +170,7 @@
public String name;
public int numberType;
public String numberLabel;
- public long photoId;
+ public Uri thumbnailUri;
public String lookupKey;
}
@@ -342,15 +342,15 @@
mContactInfoCache.expireAll();
}
- private void enqueueRequest(String number, boolean immediate, int position,
- String name, int numberType, String numberLabel, long photoId, String lookupKey) {
+ private void enqueueRequest(String number, boolean immediate, int position, String name,
+ int numberType, String numberLabel, Uri thumbnailUri, String lookupKey) {
CallerInfoQuery ciq = new CallerInfoQuery();
ciq.number = number;
ciq.position = position;
ciq.name = name;
ciq.numberType = numberType;
ciq.numberLabel = numberLabel;
- ciq.photoId = photoId;
+ ciq.thumbnailUri = thumbnailUri;
ciq.lookupKey = lookupKey;
synchronized (mRequests) {
mRequests.add(ciq);
@@ -431,8 +431,11 @@
info.number = dataTableCursor.getString(
dataTableCursor.getColumnIndex(Data.DATA1));
info.normalizedNumber = null; // meaningless for SIP addresses
- info.photoId = dataTableCursor.getLong(
- dataTableCursor.getColumnIndex(Data.PHOTO_ID));
+ final String thumbnailUriString = dataTableCursor.getString(
+ dataTableCursor.getColumnIndex(Data.PHOTO_THUMBNAIL_URI));
+ info.thumbnailUri = thumbnailUriString == null
+ ? null
+ : Uri.parse(thumbnailUriString);
info.lookupKey = dataTableCursor.getString(
dataTableCursor.getColumnIndex(Data.LOOKUP_KEY));
@@ -459,7 +462,11 @@
.getString(PhoneQuery.MATCHED_NUMBER);
info.normalizedNumber = phonesCursor
.getString(PhoneQuery.NORMALIZED_NUMBER);
- info.photoId = phonesCursor.getLong(PhoneQuery.PHOTO_ID);
+ final String thumbnailUriString = phonesCursor.getString(
+ PhoneQuery.THUMBNAIL_URI);
+ info.thumbnailUri = thumbnailUriString == null
+ ? null
+ : Uri.parse(thumbnailUriString);
info.lookupKey = phonesCursor.getString(PhoneQuery.LOOKUP_KEY);
infoUpdated = true;
@@ -697,7 +704,7 @@
mContactInfoCache.put(number, info);
Log.d(TAG, "Contact info missing: " + number);
// Request the contact details immediately since they are currently missing.
- enqueueRequest(number, true, c.getPosition(), "", 0, "", 0L, "");
+ enqueueRequest(number, true, c.getPosition(), "", 0, "", null, "");
} else if (info != ContactInfo.EMPTY) { // Has been queried
if (cachedInfo.isExpired()) {
Log.d(TAG, "Contact info expired: " + number);
@@ -707,7 +714,7 @@
// The contact info is no longer up to date, we should request it. However, we
// do not need to request them immediately.
enqueueRequest(number, false, c.getPosition(), info.name, info.type, info.label,
- info.photoId, info.lookupKey);
+ info.thumbnailUri, info.lookupKey);
}
// Format and cache phone number for found contact
@@ -725,7 +732,7 @@
final String name = info.name;
final int ntype = info.type;
final String label = info.label;
- final long photoId = info.photoId;
+ final Uri thumbnailUri = info.thumbnailUri;
final String lookupKey = info.lookupKey;
// Assumes the call back feature is on most of the
// time. For private and unknown numbers: hide it.
@@ -739,7 +746,7 @@
details = new PhoneCallDetails(number, formattedNumber, callTypes, date, duration);
} else {
details = new PhoneCallDetails(number, formattedNumber, callTypes, date, duration,
- name, ntype, label, personId, photoId);
+ name, ntype, label, personId, thumbnailUri);
}
final boolean isNew = isNewSection(c);
@@ -749,7 +756,7 @@
final boolean isHighlighted = isNew;
mCallLogViewsHelper.setPhoneCallDetails(views, details, useIcons, isHighlighted);
if (views.photoView != null) {
- bindQuickContact(views.photoView, photoId, personId, lookupKey);
+ bindQuickContact(views.photoView, thumbnailUri, personId, lookupKey);
}
@@ -779,10 +786,10 @@
return callTypes;
}
- private void bindQuickContact(QuickContactBadge view, long photoId, long contactId,
+ private void bindQuickContact(QuickContactBadge view, Uri thumbnailUri, long contactId,
String lookupKey) {
view.assignContactUri(getContactUri(contactId, lookupKey));
- mContactPhotoManager.loadPhoto(view, photoId);
+ mContactPhotoManager.loadPhoto(view, thumbnailUri);
}
private Uri getContactUri(long contactId, String lookupKey) {