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);
});
}
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;
}
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;
}
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);
}
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);
}
}
Aggregations