Search in sources :

Example 1 with CachedContactInfo

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;
}
Also used : CachedContactInfo(com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo) ContactInfo(com.android.dialer.phonenumbercache.ContactInfo) CachedContactInfo(com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo)

Example 2 with CachedContactInfo

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;
}
Also used : CachedContactInfo(com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo) DirectoryPartition(com.android.contacts.common.list.DirectoryPartition) ContactInfo(com.android.dialer.phonenumbercache.ContactInfo) CachedContactInfo(com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo) Cursor(android.database.Cursor)

Example 3 with CachedContactInfo

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);
        }
    }
}
Also used : CachedContactInfo(com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo)

Aggregations

CachedContactInfo (com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo)3 ContactInfo (com.android.dialer.phonenumbercache.ContactInfo)2 Cursor (android.database.Cursor)1 DirectoryPartition (com.android.contacts.common.list.DirectoryPartition)1