Search in sources :

Example 1 with ContactCacheEntry

use of com.android.incallui.ContactInfoCache.ContactCacheEntry in project android_packages_apps_Dialer by LineageOS.

the class ConferenceParticipantListAdapter method updateParticipantInfo.

/**
 * Updates the participant info list which is bound to the ListView. Stores the call and contact
 * info for all entries. The list is sorted alphabetically by participant name.
 *
 * @param conferenceParticipants The calls which make up the conference participants.
 */
private void updateParticipantInfo(List<DialerCall> conferenceParticipants) {
    final ContactInfoCache cache = ContactInfoCache.getInstance(getContext());
    boolean newParticipantAdded = false;
    Set<String> newCallIds = new ArraySet<>(conferenceParticipants.size());
    // Update or add conference participant info.
    for (DialerCall call : conferenceParticipants) {
        String callId = call.getId();
        newCallIds.add(callId);
        ContactCacheEntry contactCache = cache.getInfo(callId);
        if (contactCache == null) {
            contactCache = ContactInfoCache.buildCacheEntryFromCall(getContext(), call, call.getState() == DialerCall.State.INCOMING);
        }
        if (mParticipantsByCallId.containsKey(callId)) {
            ParticipantInfo participantInfo = mParticipantsByCallId.get(callId);
            participantInfo.setCall(call);
            participantInfo.setContactCacheEntry(contactCache);
        } else {
            newParticipantAdded = true;
            ParticipantInfo participantInfo = new ParticipantInfo(call, contactCache);
            mConferenceParticipants.add(participantInfo);
            mParticipantsByCallId.put(call.getId(), participantInfo);
        }
    }
    // Remove any participants that no longer exist.
    Iterator<Map.Entry<String, ParticipantInfo>> it = mParticipantsByCallId.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, ParticipantInfo> entry = it.next();
        String existingCallId = entry.getKey();
        if (!newCallIds.contains(existingCallId)) {
            ParticipantInfo existingInfo = entry.getValue();
            mConferenceParticipants.remove(existingInfo);
            it.remove();
        }
    }
    if (newParticipantAdded) {
        // Sort the list of participants by contact name.
        sortParticipantList();
    }
    notifyDataSetChanged();
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ArraySet(android.util.ArraySet) DialerCall(com.android.incallui.call.DialerCall) ArrayMap(android.support.v4.util.ArrayMap) Map(java.util.Map)

Example 2 with ContactCacheEntry

use of com.android.incallui.ContactInfoCache.ContactCacheEntry in project android_packages_apps_Dialer by LineageOS.

the class ConferenceParticipantListAdapter method getView.

/**
 * Creates or populates an existing conference participant row.
 *
 * @param position The position of the item within the adapter's data set of the item whose view
 *     we want.
 * @param convertView The old view to reuse, if possible.
 * @param parent The parent that this view will eventually be attached to
 * @return The populated view.
 */
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Make sure we have a valid convertView to start with
    final View result = convertView == null ? LayoutInflater.from(parent.getContext()).inflate(R.layout.caller_in_conference, parent, false) : convertView;
    ParticipantInfo participantInfo = mConferenceParticipants.get(position);
    DialerCall call = participantInfo.getCall();
    ContactCacheEntry contactCache = participantInfo.getContactCacheEntry();
    final ContactInfoCache cache = ContactInfoCache.getInstance(getContext());
    // photo, do it now.
    if (!participantInfo.isCacheLookupComplete()) {
        cache.findInfo(participantInfo.getCall(), participantInfo.getCall().getState() == DialerCall.State.INCOMING, new ContactLookupCallback(this));
    }
    boolean thisRowCanSeparate = mParentCanSeparate && call.can(android.telecom.Call.Details.CAPABILITY_SEPARATE_FROM_CONFERENCE);
    boolean thisRowCanDisconnect = call.can(android.telecom.Call.Details.CAPABILITY_DISCONNECT_FROM_CONFERENCE);
    String name = ContactDisplayUtils.getPreferredDisplayName(contactCache.namePrimary, contactCache.nameAlternative, mContactsPreferences);
    setCallerInfoForRow(result, contactCache.namePrimary, call.updateNameIfRestricted(name), contactCache.number, contactCache.label, contactCache.lookupKey, contactCache.displayPhotoUri, thisRowCanSeparate, thisRowCanDisconnect);
    // Tag the row in the conference participant list with the call id to make it easier to
    // find calls when contact cache information is loaded.
    result.setTag(call.getId());
    return result;
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) DialerCall(com.android.incallui.call.DialerCall)

Example 3 with ContactCacheEntry

use of com.android.incallui.ContactInfoCache.ContactCacheEntry in project android_packages_apps_Dialer by MoKee.

the class StatusBarNotifier method showNotification.

private void showNotification(final Call call) {
    final boolean isGeocoderLocationNeeded = (call.getState() == Call.State.INCOMING || call.getState() == Call.State.CALL_WAITING || call.getState() == Call.State.DIALING || call.getState() == Call.State.CONNECTING || call.getState() == Call.State.SELECT_PHONE_ACCOUNT);
    Log.d(this, "showNotification isGeocoderLocationNeeded = " + isGeocoderLocationNeeded);
    if (!TextUtils.isEmpty(mCallId)) {
        CallList.getInstance().removeCallUpdateListener(mCallId, this);
    }
    mCallId = call.getId();
    CallList.getInstance().addCallUpdateListener(call.getId(), this);
    // we make a call to the contact info cache to query for supplemental data to what the
    // call provides.  This includes the contact name and photo.
    // This callback will always get called immediately and synchronously with whatever data
    // it has available, and may make a subsequent call later (same thread) if it had to
    // call into the contacts provider for more data.
    mContactInfoCache.findInfo(call, isGeocoderLocationNeeded, new ContactInfoCacheCallback() {

        @Override
        public void onContactInfoComplete(String callId, ContactCacheEntry entry) {
            Call call = CallList.getInstance().getCallById(callId);
            if (call != null) {
                call.getLogState().contactLookupResult = entry.contactLookupResult;
                buildAndSendNotification(call, entry);
            }
        }

        @Override
        public void onImageLoadComplete(String callId, ContactCacheEntry entry) {
            Call call = CallList.getInstance().getCallById(callId);
            if (call != null) {
                buildAndSendNotification(call, entry);
            }
        }

        @Override
        public void onContactInteractionsInfoComplete(String callId, ContactCacheEntry entry) {
        }
    });
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ContactInfoCacheCallback(com.android.incallui.ContactInfoCache.ContactInfoCacheCallback)

Example 4 with ContactCacheEntry

use of com.android.incallui.ContactInfoCache.ContactCacheEntry in project android_packages_apps_Dialer by MoKee.

the class CallCardPresenterTest method testGetNameForCall_EmptyPreferredName.

public void testGetNameForCall_EmptyPreferredName() {
    ContactCacheEntry contactInfo = new ContactCacheEntry();
    contactInfo.number = NUMBER;
    ContactsPreferencesFactory.setTestInstance(null);
    CallCardPresenter presenter = new CallCardPresenter();
    presenter.init(getContext(), null);
    assertEquals(NUMBER, presenter.getNameForCall(contactInfo));
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry)

Example 5 with ContactCacheEntry

use of com.android.incallui.ContactInfoCache.ContactCacheEntry in project android_packages_apps_Dialer by MoKee.

the class StatusBarNotifierTest method testGetContentTitle_EmptyPreferredName.

public void testGetContentTitle_EmptyPreferredName() {
    ContactCacheEntry contactCacheEntry = new ContactCacheEntry();
    contactCacheEntry.number = NUMBER;
    StatusBarNotifier statusBarNotifier = new StatusBarNotifier(mContext, null);
    assertEquals(NUMBER, statusBarNotifier.getContentTitle(contactCacheEntry, mCall));
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry)

Aggregations

ContactCacheEntry (com.android.incallui.ContactInfoCache.ContactCacheEntry)11 DialerCall (com.android.incallui.call.DialerCall)3 View (android.view.View)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 ContactInfoCacheCallback (com.android.incallui.ContactInfoCache.ContactInfoCacheCallback)2 Map (java.util.Map)2 RequiresPermission (android.support.annotation.RequiresPermission)1 ArrayMap (android.support.v4.util.ArrayMap)1 SpannableString (android.text.SpannableString)1 ArraySet (android.util.ArraySet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1