Search in sources :

Example 6 with ContactCacheEntry

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

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<Call> conferenceParticipants) {
    Log.d(this, "updateParticipantInfo: " + conferenceParticipants);
    final ContactInfoCache cache = ContactInfoCache.getInstance(mContext);
    boolean newParticipantAdded = false;
    HashSet<String> newCallIds = new HashSet<>(conferenceParticipants.size());
    // Update or add conference participant info.
    for (Call call : conferenceParticipants) {
        String callId = call.getId();
        newCallIds.add(callId);
        ContactCacheEntry contactCache = cache.getInfo(callId);
        if (contactCache == null) {
            contactCache = ContactInfoCache.buildCacheEntryFromCall(mContext, call, call.getState() == Call.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) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 7 with ContactCacheEntry

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

the class StatusBarNotifier method showNotification.

@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
private void showNotification(final CallList callList, final DialerCall call) {
    final boolean isIncoming = (call.getState() == DialerCall.State.INCOMING || call.getState() == DialerCall.State.CALL_WAITING);
    setStatusBarCallListener(new StatusBarCallListener(call));
    // 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, isIncoming, new ContactInfoCacheCallback() {

        @Override
        @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
        public void onContactInfoComplete(String callId, ContactCacheEntry entry) {
            DialerCall call = callList.getCallById(callId);
            if (call != null) {
                call.getLogState().contactLookupResult = entry.contactLookupResult;
                buildAndSendNotification(callList, call, entry);
            }
        }

        @Override
        @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
        public void onImageLoadComplete(String callId, ContactCacheEntry entry) {
            DialerCall call = callList.getCallById(callId);
            if (call != null) {
                buildAndSendNotification(callList, call, entry);
            }
        }
    });
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry) ContactInfoCacheCallback(com.android.incallui.ContactInfoCache.ContactInfoCacheCallback) RequiresPermission(android.support.annotation.RequiresPermission) SpannableString(android.text.SpannableString) DialerCall(com.android.incallui.call.DialerCall) RequiresPermission(android.support.annotation.RequiresPermission)

Example 8 with ContactCacheEntry

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

the class CallCardPresenterTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    MockitoAnnotations.initMocks(this);
    Mockito.when(mContactsPreferences.getDisplayOrder()).thenReturn(ContactsPreferences.DISPLAY_ORDER_PRIMARY);
    // Unlocked all contact info is available
    mUnlockedContactInfo = new ContactCacheEntry();
    mUnlockedContactInfo.namePrimary = NAME_PRIMARY;
    mUnlockedContactInfo.nameAlternative = NAME_ALTERNATIVE;
    mUnlockedContactInfo.location = LOCATION;
    mUnlockedContactInfo.number = NUMBER;
    // Locked only number and location are available
    mLockedContactInfo = new ContactCacheEntry();
    mLockedContactInfo.location = LOCATION;
    mLockedContactInfo.number = NUMBER;
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry)

Example 9 with ContactCacheEntry

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

the class CallCardPresenterTest method testGetNumberForCall_EmptyPreferredName.

public void testGetNumberForCall_EmptyPreferredName() {
    ContactCacheEntry contactInfo = new ContactCacheEntry();
    contactInfo.location = LOCATION;
    ContactsPreferencesFactory.setTestInstance(null);
    CallCardPresenter presenter = new CallCardPresenter();
    presenter.init(getContext(), null);
    assertEquals(LOCATION, presenter.getNumberForCall(contactInfo));
}
Also used : ContactCacheEntry(com.android.incallui.ContactInfoCache.ContactCacheEntry)

Example 10 with ContactCacheEntry

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

the class StatusBarNotifierTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    MockitoAnnotations.initMocks(this);
    Mockito.when(mContactsPreferences.getDisplayOrder()).thenReturn(ContactsPreferences.DISPLAY_ORDER_PRIMARY);
    // Unlocked all contact info is available
    mUnlockedContactInfo = new ContactCacheEntry();
    mUnlockedContactInfo.namePrimary = NAME_PRIMARY;
    mUnlockedContactInfo.nameAlternative = NAME_ALTERNATIVE;
    mUnlockedContactInfo.location = LOCATION;
    mUnlockedContactInfo.number = NUMBER;
    // Locked only number and location are available
    mLockedContactInfo = new ContactCacheEntry();
    mLockedContactInfo.location = LOCATION;
    mLockedContactInfo.number = NUMBER;
}
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