diff options
Diffstat (limited to 'src/com/android/dialer/calllog')
3 files changed, 35 insertions, 4 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 316864fe2..703b18f8f 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -44,13 +44,16 @@ import com.android.dialer.PhoneCallDetails; import com.android.dialer.R; import com.android.dialer.contactinfo.ContactInfoCache; import com.android.dialer.contactinfo.ContactInfoCache.OnContactInfoChangedListener; +import com.android.dialer.contactinfo.NumberWithCountryIso; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; +import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener; import com.android.dialer.util.PhoneNumberUtil; import com.android.dialer.voicemail.VoicemailPlaybackPresenter; import com.google.common.annotations.VisibleForTesting; import java.util.HashMap; +import java.util.Map; /** * Adapter class to fill in data for the Call Log. @@ -85,6 +88,7 @@ public class CallLogAdapter extends GroupingListAdapter private final FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; protected ContactInfoCache mContactInfoCache; + protected final Map<NumberWithCountryIso, Integer> mBlockedIdCache; private boolean mIsCallLogActivity; @@ -248,6 +252,7 @@ public class CallLogAdapter extends GroupingListAdapter CallTypeHelper callTypeHelper = new CallTypeHelper(resources); mTelecomCallLogCache = new TelecomCallLogCache(mContext); + mBlockedIdCache = new HashMap<NumberWithCountryIso, Integer>(); PhoneCallDetailsHelper phoneCallDetailsHelper = new PhoneCallDetailsHelper(mContext, resources, mTelecomCallLogCache); mCallLogListItemHelper = @@ -296,6 +301,7 @@ public class CallLogAdapter extends GroupingListAdapter public void invalidateCache() { mContactInfoCache.invalidate(); + mBlockedIdCache.clear(); } public void startCache() { @@ -456,7 +462,7 @@ public class CallLogAdapter extends GroupingListAdapter details.objectId = info.objectId; } - CallLogListItemViewHolder views = (CallLogListItemViewHolder) viewHolder; + final CallLogListItemViewHolder views = (CallLogListItemViewHolder) viewHolder; views.info = info; views.rowId = c.getLong(CallLogQuery.ID); // Store values used when the actions ViewStub is inflated on expansion. @@ -492,8 +498,28 @@ public class CallLogAdapter extends GroupingListAdapter mCurrentlyExpandedPosition = position; } + // Update the photo, once we know whether the user's number is blocked or not. + final NumberWithCountryIso blockedIdKey = new NumberWithCountryIso(number, countryIso); + if (mBlockedIdCache.containsKey(blockedIdKey)) { + views.blockId = mBlockedIdCache.get(blockedIdKey); + views.updatePhoto(); + } else { + views.blockId = null; + boolean failed = mFilteredNumberAsyncQueryHandler.startBlockedQuery( + new OnCheckBlockedListener() { + @Override + public void onCheckComplete(Integer id) { + mBlockedIdCache.put(blockedIdKey, id); + views.blockId = id; + views.updatePhoto(); + } + }, null, number, countryIso); + if (failed) { + views.updatePhoto(); + } + } + views.showActions(mCurrentlyExpandedPosition == position); - views.updatePhoto(); mCallLogListItemHelper.setPhoneCallDetails(views, details); } diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index 5b47d4477..d22947b66 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -528,8 +528,13 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } public void updatePhoto() { - quickContactView.assignContactUri(info.lookupUri); quickContactView.setOverlay(null); + quickContactView.assignContactUri(info.lookupUri); + + if (blockId != null) { + quickContactView.setImageDrawable(mContext.getDrawable(R.drawable.blocked_contact)); + return; + } final boolean isVoicemail = mTelecomCallLogCache.isVoicemailNumber(accountHandle, number); int contactType = ContactPhotoManager.TYPE_DEFAULT; diff --git a/src/com/android/dialer/calllog/CallTypeIconsView.java b/src/com/android/dialer/calllog/CallTypeIconsView.java index cfd8f9748..d2be380a5 100644 --- a/src/com/android/dialer/calllog/CallTypeIconsView.java +++ b/src/com/android/dialer/calllog/CallTypeIconsView.java @@ -199,7 +199,7 @@ public class CallTypeIconsView extends View { voicemail = r.getDrawable(R.drawable.ic_call_voicemail_holo_dark); - blocked = getScaledBitmap(context, R.drawable.ic_block_24dp); + blocked = getScaledBitmap(context, R.drawable.ic_block_18dp); blocked.setColorFilter(r.getColor(R.color.blocked_call), PorterDuff.Mode.MULTIPLY); videoCall = getScaledBitmap(context, R.drawable.ic_videocam_24dp); |