summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/CallDetailActivity.java
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-02-21 10:02:18 -0800
committerYorke Lee <yorkelee@google.com>2014-02-28 16:30:47 -0800
commit56cb0efa5eda1670077e66fc0e8c79478d0c1c67 (patch)
treeda64925c0d47acb56889f3226859b4843bf0dcfe /src/com/android/dialer/CallDetailActivity.java
parent8b58491588d5128f23e5a6eee37baad77839b2ca (diff)
Use new ContactPhotoManager APIs for letter tile avatars
*Modify the following uses of ContactPhotoManager.loadPhoto in the following classes to include a DefaultImageRequest, populated with the contact's display name, lookupkey, and contact type as necessary CallDetailActivity CallLogAdapter PhoneFavoriteTileView *Add utility methods to ContactInfoHelper, to parse a lookupUri for a lookup key, as well as determine whether or not a contact is a business contact, from its sourceType field. *Add a sourceType field to PhoneCallDetails which can be used to track whether or not PhoneCallDetails belongs to a business contact *Add a lookupKey field to ContactInfo Bug: 13101785 Change-Id: If339a9c038f92a0212f8f8b45b5e3cc5f6442562
Diffstat (limited to 'src/com/android/dialer/CallDetailActivity.java')
-rw-r--r--src/com/android/dialer/CallDetailActivity.java41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 2b6566fa5..e09e6f302 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -32,6 +32,7 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.CallLog;
+import android.provider.ContactsContract;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
@@ -56,6 +57,7 @@ import android.widget.Toast;
import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.CallUtil;
import com.android.contacts.common.ClipboardUtils;
+import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
import com.android.contacts.common.GeoUtil;
import com.android.contacts.common.model.Contact;
import com.android.contacts.common.model.ContactLoader;
@@ -545,14 +547,14 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
mainActionDescription);
}
+ final CharSequence displayNumber =
+ mPhoneNumberHelper.getDisplayNumber(
+ firstDetails.number,
+ firstDetails.numberPresentation,
+ firstDetails.formattedNumber);
+
// This action allows to call the number that places the call.
if (canPlaceCallsTo) {
- final CharSequence displayNumber =
- mPhoneNumberHelper.getDisplayNumber(
- firstDetails.number,
- firstDetails.numberPresentation,
- firstDetails.formattedNumber);
-
ViewEntry entry = new ViewEntry(
getString(R.string.menu_callNumber,
forceLeftToRight(displayNumber)),
@@ -623,7 +625,20 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
}
},
historyList);
- loadContactPhotos(photoUri);
+
+ final String displayNameForDefaultImage = TextUtils.isEmpty(firstDetails.name) ?
+ displayNumber.toString() : firstDetails.name.toString();
+
+ final String lookupKey = ContactInfoHelper.getLookupKeyFromUri(contactUri);
+
+ final boolean isBusiness = mContactInfoHelper.isBusiness(firstDetails.sourceType);
+
+ final int contactType =
+ isVoicemailNumber? ContactPhotoManager.TYPE_VOICEMAIL :
+ isBusiness ? ContactPhotoManager.TYPE_BUSINESS :
+ ContactPhotoManager.TYPE_DEFAULT;
+
+ loadContactPhotos(photoUri, displayNameForDefaultImage, lookupKey, contactType);
findViewById(R.id.call_detail).setVisibility(View.VISIBLE);
}
}
@@ -690,6 +705,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
final CharSequence numberLabel;
final Uri photoUri;
final Uri lookupUri;
+ int sourceType;
// If this is not a regular number, there is no point in looking it up in the contacts.
ContactInfo info =
PhoneNumberUtilsWrapper.canPlaceCallsTo(number, numberPresentation)
@@ -704,6 +720,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
numberLabel = "";
photoUri = null;
lookupUri = null;
+ sourceType = 0;
} else {
formattedNumber = info.formattedNumber;
nameText = info.name;
@@ -711,11 +728,12 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
numberLabel = info.label;
photoUri = info.photoUri;
lookupUri = info.lookupUri;
+ sourceType = info.sourceType;
}
return new PhoneCallDetails(number, numberPresentation,
formattedNumber, countryIso, geocode,
new int[]{ callType }, date, duration,
- nameText, numberType, numberLabel, lookupUri, photoUri);
+ nameText, numberType, numberLabel, lookupUri, photoUri, sourceType);
} finally {
if (callCursor != null) {
callCursor.close();
@@ -724,9 +742,12 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
}
/** Load the contact photos and places them in the corresponding views. */
- private void loadContactPhotos(Uri photoUri) {
+ private void loadContactPhotos(Uri photoUri, String displayName, String lookupKey,
+ int contactType) {
+ final DefaultImageRequest request = new DefaultImageRequest(displayName, lookupKey,
+ contactType);
mContactPhotoManager.loadPhoto(mContactBackgroundView, photoUri,
- mContactBackgroundView.getWidth(), true);
+ mContactBackgroundView.getWidth(), true, request);
}
static final class ViewEntry {