Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9228d4a2 authored by Gilles Franck Mevaa's avatar Gilles Franck Mevaa
Browse files

CallLogListItemViewHolder distinguishes block/spam numbers

A new method is added to show the appropriate photo and label
if the number is either blocked or spam. This occurs after the
normal photo and labels are rendered. Because of that, there is
a flickering if the photo and labels should be changed.
b/27295728 will help track the fix of the flickering bug.

Change-Id: I639c0c0d4167b48956892f2b955d4e1f0cc8e8eb
parent 24c02ee4
Loading
Loading
Loading
Loading
+8 −11
Original line number Original line Diff line number Diff line
@@ -27,11 +27,9 @@ import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.support.v7.widget.CardView;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView;
import android.telecom.PhoneAccountHandle;
import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
import android.text.BidiFormatter;
import android.text.BidiFormatter;
import android.text.TextDirectionHeuristics;
import android.text.TextDirectionHeuristics;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.MenuItem;
import android.view.View;
import android.view.View;
@@ -66,8 +64,6 @@ import com.android.dialerbind.ObjectFactory;
import com.google.common.collect.Lists;
import com.google.common.collect.Lists;


import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Set;


/**
/**
 * This is an object containing references to views contained by the call log list item. This
 * This is an object containing references to views contained by the call log list item. This
@@ -625,13 +621,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
    public void updatePhoto() {
    public void updatePhoto() {
        quickContactView.assignContactUri(info.lookupUri);
        quickContactView.assignContactUri(info.lookupUri);


        if (isBlocked && !TextUtils.isEmpty(number) /* maybe a private number ? */) {
            quickContactView.setImageDrawable(mContext.getDrawable(R.drawable.blocked_contact));
            phoneCallDetailsViews.callLocationAndDate.setText(
                    mContext.getString(R.string.blocked_number_call_log_label));
            return;
        }

        final boolean isVoicemail = mCallLogCache.isVoicemailNumber(accountHandle, number);
        final boolean isVoicemail = mCallLogCache.isVoicemailNumber(accountHandle, number);
        int contactType = ContactPhotoManager.TYPE_DEFAULT;
        int contactType = ContactPhotoManager.TYPE_DEFAULT;
        if (isVoicemail) {
        if (isVoicemail) {
@@ -653,6 +642,14 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
            ContactPhotoManager.getInstance(mContext).loadThumbnail(quickContactView, info.photoId,
            ContactPhotoManager.getInstance(mContext).loadThumbnail(quickContactView, info.photoId,
                    false /* darkTheme */, true /* isCircular */, request);
                    false /* darkTheme */, true /* isCircular */, request);
        }
        }

        if (mExtendedBlockingButtonRenderer != null) {
            mExtendedBlockingButtonRenderer.updatePhotoAndLabelIfNecessary(
                    number,
                    countryIso,
                    quickContactView,
                    phoneCallDetailsViews.callLocationAndDate);
        }
    }
    }


    @Override
    @Override
+13 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.dialer.service;
import android.support.annotation.Nullable;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.View;
import android.view.ViewStub;
import android.view.ViewStub;
import android.widget.QuickContactBadge;
import android.widget.TextView;


import java.util.List;
import java.util.List;


@@ -70,4 +72,15 @@ public interface ExtendedBlockingButtonRenderer {
    void render(ViewStub viewStub);
    void render(ViewStub viewStub);


    void setViewHolderInfo(ViewHolderInfo info);
    void setViewHolderInfo(ViewHolderInfo info);

    /**
     * Updates the photo and label for the given phone number and country iso.
     *
     * @param number Phone number for which the rendering occurs.
     * @param countryIso Two-letter country code.
     * @param badge {@link QuickContactBadge} in which the photo should be rendered.
     * @param view Textview that will hold the new label.
     */
    void updatePhotoAndLabelIfNecessary(
            String number, String countryIso, QuickContactBadge badge, TextView view);
}
}