diff options
author | Andrew Lee <anwlee@google.com> | 2015-03-31 16:37:23 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-04-01 11:20:38 -0700 |
commit | 81c3829f8a9377cb2e93c1fa6d223d223b78f371 (patch) | |
tree | 5fea96e34254f7d5894d12d224d24fcbeabf6cbb /src | |
parent | 25e732727f5bf2c38c40cd353b739742278940c1 (diff) |
Move setPhoto logic to CallLogListItemViews.
Bug: 19372817
Change-Id: Icddc1edd2ca1ad040a03726471a19ddc9d434d4d
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAdapter.java | 47 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogListItemViews.java | 52 |
2 files changed, 46 insertions, 53 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index d1a164acd..ff841e66b 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -42,8 +42,6 @@ import android.widget.ImageView; import android.widget.TextView; import com.android.common.widget.GroupingListAdapter; -import com.android.contacts.common.ContactPhotoManager; -import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.util.UriUtils; import com.android.dialer.PhoneCallDetails; import com.android.dialer.PhoneCallDetailsHelper; @@ -241,8 +239,6 @@ public class CallLogAdapter extends GroupingListAdapter /** Instance of helper class for managing views. */ private final CallLogListItemHelper mCallLogViewsHelper; - /** Helper to set up contact photos. */ - private final ContactPhotoManager mContactPhotoManager; /** Helper to parse and process phone numbers. */ private PhoneNumberDisplayHelper mPhoneNumberHelper; /** Helper to access Telephony phone number utils class */ @@ -255,8 +251,6 @@ public class CallLogAdapter extends GroupingListAdapter /** Can be set to true by tests to disable processing of requests. */ private volatile boolean mRequestProcessingDisabled = false; - private int mPhotoSize; - /** Listener for the primary or secondary actions in the list. * Primary opens the call details. * Secondary calls or plays. @@ -344,9 +338,7 @@ public class CallLogAdapter extends GroupingListAdapter Resources resources = mContext.getResources(); CallTypeHelper callTypeHelper = new CallTypeHelper(resources); - mPhotoSize = resources.getDimensionPixelSize(R.dimen.contact_photo_size); - mContactPhotoManager = ContactPhotoManager.getInstance(mContext); mPhoneNumberHelper = new PhoneNumberDisplayHelper(mContext, resources); mPhoneNumberUtilsWrapper = new PhoneNumberUtilsWrapper(mContext); PhoneCallDetailsHelper phoneCallDetailsHelper = @@ -744,17 +736,6 @@ public class CallLogAdapter extends GroupingListAdapter mCallLogViewsHelper.setPhoneCallDetails(mContext, views, details); - int contactType = ContactPhotoManager.TYPE_DEFAULT; - - if (isVoicemailNumber) { - contactType = ContactPhotoManager.TYPE_VOICEMAIL; - } else if (mContactInfoHelper.isBusiness(info.sourceType)) { - contactType = ContactPhotoManager.TYPE_BUSINESS; - } - - String lookupKey = lookupUri == null ? null - : ContactInfoHelper.getLookupKeyFromUri(lookupUri); - String nameForDefaultImage = null; if (TextUtils.isEmpty(name)) { nameForDefaultImage = mPhoneNumberHelper.getDisplayNumber(details.accountHandle, @@ -763,11 +744,8 @@ public class CallLogAdapter extends GroupingListAdapter nameForDefaultImage = name; } - if (photoId == 0 && photoUri != null) { - setPhoto(views, photoUri, lookupUri, nameForDefaultImage, lookupKey, contactType); - } else { - setPhoto(views, photoId, lookupUri, nameForDefaultImage, lookupKey, contactType); - } + views.setPhoto(photoId, photoUri, lookupUri, nameForDefaultImage, isVoicemailNumber, + mContactInfoHelper.isBusiness(info.sourceType)); views.quickContactView.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE); // Listen for the first draw @@ -809,6 +787,7 @@ public class CallLogAdapter extends GroupingListAdapter } return CallLogGroupBuilder.DAY_GROUP_NONE; } + /** * Determines if a call log row with the given Id is expanded. * @param rowId The row Id of the call. @@ -987,26 +966,6 @@ public class CallLogAdapter extends GroupingListAdapter return features; } - private void setPhoto(CallLogListItemViews views, long photoId, Uri contactUri, - String displayName, String identifier, int contactType) { - views.quickContactView.assignContactUri(contactUri); - views.quickContactView.setOverlay(null); - DefaultImageRequest request = new DefaultImageRequest(displayName, identifier, - contactType, true /* isCircular */); - mContactPhotoManager.loadThumbnail(views.quickContactView, photoId, false /* darkTheme */, - true /* isCircular */, request); - } - - private void setPhoto(CallLogListItemViews views, Uri photoUri, Uri contactUri, - String displayName, String identifier, int contactType) { - views.quickContactView.assignContactUri(contactUri); - views.quickContactView.setOverlay(null); - DefaultImageRequest request = new DefaultImageRequest(displayName, identifier, - contactType, true /* isCircular */); - mContactPhotoManager.loadPhoto(views.quickContactView, photoUri, mPhotoSize, - false /* darkTheme */, true /* isCircular */, request); - } - /** * Bind a call log entry view for testing purposes. Also inflates the action view stub so * unit tests can access the buttons contained within. diff --git a/src/com/android/dialer/calllog/CallLogListItemViews.java b/src/com/android/dialer/calllog/CallLogListItemViews.java index 427732e0a..9d11a3ab6 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViews.java +++ b/src/com/android/dialer/calllog/CallLogListItemViews.java @@ -18,6 +18,7 @@ package com.android.dialer.calllog; import android.content.Context; import android.content.res.Resources; +import android.net.Uri; import android.provider.CallLog.Calls; import android.telecom.PhoneAccountHandle; import android.text.TextUtils; @@ -28,6 +29,8 @@ import android.widget.QuickContactBadge; import android.widget.TextView; import com.android.contacts.common.CallUtil; +import com.android.contacts.common.ContactPhotoManager; +import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.testing.NeededForTesting; import com.android.dialer.PhoneCallDetailsViews; import com.android.dialer.R; @@ -130,6 +133,7 @@ public final class CallLogListItemViews { private static final int VOICEMAIL_TRANSCRIPTION_MAX_LINES = 10; private Context mContext; + private int mPhotoSize; private int mCallLogBackgroundColor; private int mExpandedBackgroundColor; @@ -156,6 +160,18 @@ public final class CallLogListItemViews { mCallLogBackgroundColor = resources.getColor(R.color.background_dialer_list_items); mExpandedBackgroundColor = resources.getColor(R.color.call_log_expanded_background_color); mExpandedTranslationZ = resources.getDimension(R.dimen.call_log_expanded_translation_z); + mPhotoSize = mContext.getResources().getDimensionPixelSize(R.dimen.contact_photo_size); + } + + public static CallLogListItemViews fromView(Context context, View view) { + return new CallLogListItemViews( + context, + view, + (QuickContactBadge) view.findViewById(R.id.quick_contact_photo), + view.findViewById(R.id.primary_action_view), + PhoneCallDetailsViews.fromView(view), + view.findViewById(R.id.call_log_row), + (TextView) view.findViewById(R.id.call_log_day_group_label)); } /** @@ -335,15 +351,33 @@ public final class CallLogListItemViews { view.setSingleLine(!isExpanded); } - public static CallLogListItemViews fromView(Context context, View view) { - return new CallLogListItemViews( - context, - view, - (QuickContactBadge) view.findViewById(R.id.quick_contact_photo), - view.findViewById(R.id.primary_action_view), - PhoneCallDetailsViews.fromView(view), - view.findViewById(R.id.call_log_row), - (TextView) view.findViewById(R.id.call_log_day_group_label)); + public void setPhoto(long photoId, Uri photoUri, Uri contactUri, String displayName, + boolean isVoicemail, boolean isBusiness) { + quickContactView.assignContactUri(contactUri); + quickContactView.setOverlay(null); + + int contactType = ContactPhotoManager.TYPE_DEFAULT; + if (isVoicemail) { + contactType = ContactPhotoManager.TYPE_VOICEMAIL; + } else if (isBusiness) { + contactType = ContactPhotoManager.TYPE_BUSINESS; + } + + String lookupKey = null; + if (contactUri != null) { + lookupKey = ContactInfoHelper.getLookupKeyFromUri(contactUri); + } + + DefaultImageRequest request = new DefaultImageRequest( + displayName, lookupKey, contactType, true /* isCircular */); + + if (photoId == 0 && photoUri != null) { + ContactPhotoManager.getInstance(mContext).loadPhoto(quickContactView, photoUri, + mPhotoSize, false /* darkTheme */, true /* isCircular */, request); + } else { + ContactPhotoManager.getInstance(mContext).loadThumbnail(quickContactView, photoId, + false /* darkTheme */, true /* isCircular */, request); + } } @NeededForTesting |