Search in sources :

Example 16 with CallContact

use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.

the class ContactService method loadContacts.

/**
 * Load contacts from system and generate a local contact cache
 *
 * @param loadRingContacts if true, ring contacts will be taken care of
 * @param loadSipContacts  if true, sip contacts will be taken care of
 */
public void loadContacts(final boolean loadRingContacts, final boolean loadSipContacts, final Account account) {
    mApplicationExecutor.submit(() -> {
        Settings settings = mPreferencesService.loadSettings();
        if (settings.isAllowSystemContacts() && mDeviceRuntimeService.hasContactPermission()) {
            mContactList = loadContactsFromSystem(loadRingContacts, loadSipContacts);
        }
        mContactsRing.clear();
        mAccountId = account.getAccountID();
        Map<String, CallContact> ringContacts = account.getContacts();
        for (CallContact contact : ringContacts.values()) {
            mContactsRing.put(contact.getPhones().get(0).getNumber().getRawUriString(), contact);
        }
        setChanged();
        ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CONTACTS_CHANGED);
        notifyObservers(event);
    });
}
Also used : ServiceEvent(cx.ring.model.ServiceEvent) Settings(cx.ring.model.Settings) CallContact(cx.ring.model.CallContact)

Example 17 with CallContact

use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.

the class ContactService method findContact.

public CallContact findContact(Uri uri) {
    if (uri == null) {
        return null;
    }
    String searchedCanonicalNumber = uri.getRawUriString();
    // Look for Ring contact by ID
    boolean isRingId = uri.isRingId();
    if (isRingId) {
        CallContact contact = mContactsRing.get(searchedCanonicalNumber);
        if (contact != null) {
            return contact;
        }
    }
    // Look for other contact
    for (CallContact c : mContactsRing.values()) {
        if (c.hasNumber(searchedCanonicalNumber)) {
            return c;
        }
    }
    Settings settings = mPreferencesService.loadSettings();
    if (settings.isAllowSystemContacts() && mDeviceRuntimeService.hasContactPermission()) {
        CallContact contact = findContactByNumberFromSystem(searchedCanonicalNumber);
        if (contact != null) {
            mContactList.put(contact.getId(), contact);
            return contact;
        }
    }
    CallContact contact = CallContact.buildUnknown(uri);
    mContactsRing.put(searchedCanonicalNumber, contact);
    return contact;
}
Also used : CallContact(cx.ring.model.CallContact) Settings(cx.ring.model.Settings)

Example 18 with CallContact

use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.

the class ContactService method getContactsNoBanned.

public Collection<CallContact> getContactsNoBanned() {
    List<CallContact> contacts = new ArrayList<>(getContacts());
    Iterator<CallContact> it = contacts.iterator();
    while (it.hasNext()) {
        CallContact contact = it.next();
        if (contact.isBanned()) {
            it.remove();
        }
    }
    return contacts;
}
Also used : ArrayList(java.util.ArrayList) CallContact(cx.ring.model.CallContact)

Example 19 with CallContact

use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.

the class CallPresenter method getContactDetails.

private void getContactDetails() {
    if (mSipCall == null) {
        Log.e(TAG, "Not able to get SIP call");
        return;
    }
    CallContact callContact = mSipCall.getContact();
    if (mContactService == null) {
        Log.e(TAG, "Not able to get contact service");
        return;
    }
    mContactService.loadContactData(callContact);
    getView().updateContactBubble(callContact);
}
Also used : CallContact(cx.ring.model.CallContact)

Example 20 with CallContact

use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.

the class BlackListPresenter method updateList.

public void updateList() {
    if (getView() == null) {
        return;
    }
    Account account = mAccountService.getAccount(mAccountID);
    if (account == null) {
        return;
    }
    List<CallContact> list = account.getBannedContacts();
    if (list.isEmpty()) {
        getView().hideListView();
        getView().displayEmptyListMessage(true);
    } else {
        getView().updateView(list);
        getView().displayEmptyListMessage(false);
    }
}
Also used : Account(cx.ring.model.Account) CallContact(cx.ring.model.CallContact)

Aggregations

CallContact (cx.ring.model.CallContact)38 Conversation (cx.ring.model.Conversation)9 Uri (cx.ring.model.Uri)8 Account (cx.ring.model.Account)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)5 ContentResolver (android.content.ContentResolver)4 Cursor (android.database.Cursor)4 SipCall (cx.ring.model.SipCall)4 ServiceEvent (cx.ring.model.ServiceEvent)3 Settings (cx.ring.model.Settings)3 TextMessage (cx.ring.model.TextMessage)3 IOException (java.io.IOException)3 Map (java.util.Map)3 Intent (android.content.Intent)2 StringMap (cx.ring.daemon.StringMap)2 TrustRequest (cx.ring.model.TrustRequest)2 TVListViewModel (cx.ring.tv.model.TVListViewModel)2 List (java.util.List)2 PendingIntent (android.app.PendingIntent)1