use of com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo in project android_packages_apps_Dialer by LineageOS.
the class CallerInfoUtils method buildCachedContactInfo.
/**
* Creates a new {@link CachedContactInfo} from a {@link CallerInfo}
*
* @param lookupService the {@link CachedNumberLookupService} used to build a new {@link
* CachedContactInfo}
* @param {@link CallerInfo} object
* @return a CachedContactInfo object created from this CallerInfo
* @throws NullPointerException if lookupService or ci are null
*/
public static CachedContactInfo buildCachedContactInfo(CachedNumberLookupService lookupService, CallerInfo ci) {
ContactInfo info = new ContactInfo();
info.name = ci.name;
info.type = ci.numberType;
info.label = ci.phoneLabel;
info.number = ci.phoneNumber;
info.normalizedNumber = ci.normalizedNumber;
info.photoUri = ci.contactDisplayPhotoUri;
info.userType = ci.userType;
CachedContactInfo cacheInfo = lookupService.buildCachedContactInfo(info);
cacheInfo.setLookupKey(ci.lookupKeyOrNull);
return cacheInfo;
}
use of com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo in project android_packages_apps_Dialer by LineageOS.
the class RegularSearchListAdapter method getContactInfo.
public CachedContactInfo getContactInfo(CachedNumberLookupService lookupService, int position) {
ContactInfo info = new ContactInfo();
CachedContactInfo cacheInfo = lookupService.buildCachedContactInfo(info);
final Cursor item = (Cursor) getItem(position);
if (item != null) {
final DirectoryPartition partition = (DirectoryPartition) getPartition(getPartitionForPosition(position));
final long directoryId = partition.getDirectoryId();
final boolean isExtendedDirectory = isExtendedDirectory(directoryId);
info.name = item.getString(PhoneQuery.DISPLAY_NAME);
info.type = item.getInt(PhoneQuery.PHONE_TYPE);
info.label = item.getString(PhoneQuery.PHONE_LABEL);
info.number = item.getString(PhoneQuery.PHONE_NUMBER);
final String photoUriStr = item.getString(PhoneQuery.PHOTO_URI);
info.photoUri = photoUriStr == null ? null : Uri.parse(photoUriStr);
/*
* An extended directory is custom directory in the app, but not a directory provided by
* framework. So it can't be USER_TYPE_WORK.
*
* When a search result is selected, RegularSearchFragment calls getContactInfo and
* cache the resulting @{link ContactInfo} into local db. Set usertype to USER_TYPE_WORK
* only if it's NOT extended directory id and is enterprise directory.
*/
info.userType = !isExtendedDirectory && DirectoryCompat.isEnterpriseDirectoryId(directoryId) ? ContactsUtils.USER_TYPE_WORK : ContactsUtils.USER_TYPE_CURRENT;
cacheInfo.setLookupKey(item.getString(PhoneQuery.LOOKUP_KEY));
final String sourceName = partition.getLabel();
if (isExtendedDirectory) {
cacheInfo.setExtendedSource(sourceName, directoryId);
} else {
cacheInfo.setDirectorySource(sourceName, directoryId);
}
}
return cacheInfo;
}
use of com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo in project android_packages_apps_Dialer by LineageOS.
the class ContactInfoHelper method updateCachedNumberLookupService.
public void updateCachedNumberLookupService(ContactInfo updatedInfo) {
if (mCachedNumberLookupService != null) {
if (hasName(updatedInfo)) {
CachedContactInfo cachedContactInfo = mCachedNumberLookupService.buildCachedContactInfo(updatedInfo);
mCachedNumberLookupService.addContact(mContext, cachedContactInfo);
}
}
}
Aggregations