use of com.android.contacts.common.model.Contact in project android_packages_apps_Dialer by LineageOS.
the class CallerInfoUtils method sendViewNotification.
/**
* Send a notification using a {@link ContactLoader} to inform the sync adapter that we are
* viewing a particular contact, so that it can download the high-res photo.
*/
public static void sendViewNotification(Context context, Uri contactUri) {
final ContactLoader loader = new ContactLoader(context, contactUri, true);
loader.registerListener(0, new OnLoadCompleteListener<Contact>() {
@Override
public void onLoadComplete(Loader<Contact> loader, Contact contact) {
try {
loader.reset();
} catch (RuntimeException e) {
LogUtil.e("CallerInfoUtils.onLoadComplete", "Error resetting loader", e);
}
}
});
loader.startLoading();
}
use of com.android.contacts.common.model.Contact in project android_packages_apps_Dialer by LineageOS.
the class IntentProvider method getAddContactIntentProvider.
/**
* Retrieves an add contact intent for the given contact and phone call details.
*/
public static IntentProvider getAddContactIntentProvider(final Uri lookupUri, final CharSequence name, final CharSequence number, final int numberType, final boolean isNewContact) {
return new IntentProvider() {
@Override
public Intent getClickIntent(Context context) {
Contact contactToSave = null;
if (lookupUri != null) {
contactToSave = ContactLoader.parseEncodedContactEntity(lookupUri);
}
if (contactToSave != null) {
// Populate the intent with contact information stored in the lookup URI.
// Note: This code mirrors code in Contacts/QuickContactsActivity.
final Intent intent;
if (isNewContact) {
intent = IntentUtil.getNewContactIntent();
} else {
intent = IntentUtil.getAddToExistingContactIntent();
}
ArrayList<ContentValues> values = contactToSave.getContentValues();
// or better (e.g. structured name, nickname)
if (contactToSave.getDisplayNameSource() >= ContactsContract.DisplayNameSources.NICKNAME) {
intent.putExtra(ContactsContract.Intents.Insert.NAME, contactToSave.getDisplayName());
} else if (contactToSave.getDisplayNameSource() == ContactsContract.DisplayNameSources.ORGANIZATION) {
// This is probably an organization. Instead of copying the organization
// name into a name entry, copy it into the organization entry. This
// way we will still consider the contact an organization.
final ContentValues organization = new ContentValues();
organization.put(ContactsContract.CommonDataKinds.Organization.COMPANY, contactToSave.getDisplayName());
organization.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE);
values.add(organization);
}
// properly
for (ContentValues value : values) {
value.remove(ContactsContract.Data.LAST_TIME_USED);
value.remove(ContactsContract.Data.TIMES_USED);
}
intent.putExtra(ContactsContract.Intents.Insert.DATA, values);
return intent;
} else {
// If no lookup uri is provided, rely on the available phone number and name.
if (isNewContact) {
return IntentUtil.getNewContactIntent(name, number, numberType);
} else {
return IntentUtil.getAddToExistingContactIntent(name, number, numberType);
}
}
}
};
}
Aggregations