if (!UriUtils.areEqual(updatedInfo.lookupUri, callLogInfo.lookupUri)) { values.put(Calls.CACHED_LOOKUP_URI, UriUtils.uriToString(updatedInfo.lookupUri)); needsUpdate = true; UriUtils.nullForNonContactsUri(updatedInfo.photoUri); if (DialerCompatUtils.isCallsCachedPhotoUriCompatible() && !UriUtils.areEqual(updatedPhotoUriContactsOnly, callLogInfo.photoUri)) { values.put(Calls.CACHED_PHOTO_URI, UriUtils.uriToString(updatedPhotoUriContactsOnly)); needsUpdate = true; values.put(Calls.CACHED_NUMBER_TYPE, updatedInfo.type); values.put(Calls.CACHED_NUMBER_LABEL, updatedInfo.label); values.put(Calls.CACHED_LOOKUP_URI, UriUtils.uriToString(updatedInfo.lookupUri)); values.put(Calls.CACHED_MATCHED_NUMBER, updatedInfo.number); values.put(Calls.CACHED_NORMALIZED_NUMBER, updatedInfo.normalizedNumber); values.put(Calls.CACHED_PHOTO_ID, updatedInfo.photoId); if (DialerCompatUtils.isCallsCachedPhotoUriCompatible()) { values.put(Calls.CACHED_PHOTO_URI, UriUtils.uriToString( UriUtils.nullForNonContactsUri(updatedInfo.photoUri)));
/** * Parses the given URI to determine the original lookup key of the contact. */ public static String getLookupKeyFromUri(Uri lookupUri) { // Would be nice to be able to persist the lookup key somehow to avoid having to parse // the uri entirely just to retrieve the lookup key, but every uri is already parsed // once anyway to check if it is an encoded JSON uri, so this has negligible effect // on performance. if (lookupUri != null && !UriUtils.isEncodedContactUri(lookupUri)) { final List<String> segments = lookupUri.getPathSegments(); // This returns the third path segment of the uri, where the lookup key is located. // See {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}. return (segments.size() < 3) ? null : Uri.encode(segments.get(2)); } else { return null; } } }
/** * Returns the contact information stored in an entry of the call log. * * @param c A cursor pointing to an entry in the call log. */ public static ContactInfo getContactInfo(Cursor c) { ContactInfo info = new ContactInfo(); info.lookupUri = UriUtils.parseUriOrNull(c.getString(CallLogQuery.CACHED_LOOKUP_URI)); info.name = c.getString(CallLogQuery.CACHED_NAME); info.type = c.getInt(CallLogQuery.CACHED_NUMBER_TYPE); info.label = c.getString(CallLogQuery.CACHED_NUMBER_LABEL); String matchedNumber = c.getString(CallLogQuery.CACHED_MATCHED_NUMBER); String postDialDigits = CompatUtils.isNCompatible() ? c.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; info.number = (matchedNumber == null) ? c.getString(CallLogQuery.NUMBER) + postDialDigits : matchedNumber; info.normalizedNumber = c.getString(CallLogQuery.CACHED_NORMALIZED_NUMBER); info.photoId = c.getLong(CallLogQuery.CACHED_PHOTO_ID); info.photoUri = DialerCompatUtils.isCallsCachedPhotoUriCompatible() ? UriUtils.nullForNonContactsUri( UriUtils.parseUriOrNull(c.getString(CallLogQuery.CACHED_PHOTO_URI))) : null; info.formattedNumber = c.getString(CallLogQuery.CACHED_FORMATTED_NUMBER); return info; }
private void loadContactPhoto(ContactInfo info, String displayName, QuickContactBadge badge) { final String lookupKey = info.lookupUri == null ? null : UriUtils.getLookupKeyFromUri(info.lookupUri); final int contactType = mContactInfoHelper.isBusiness(info.sourceType) ? ContactPhotoManager.TYPE_BUSINESS : ContactPhotoManager.TYPE_DEFAULT; final DefaultImageRequest request = new DefaultImageRequest(displayName, lookupKey, contactType, true /* isCircular */); badge.assignContactUri(info.lookupUri); badge.setContentDescription( mContext.getResources().getString(R.string.description_contact_details, displayName)); mContactPhotoManager.loadDirectoryPhoto(badge, info.photoUri, false /* darkTheme */, true /* isCircular */, request); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final Request that = (Request) obj; if (mId != that.mId) return false; if (mRequestedExtent != that.mRequestedExtent) return false; if (!UriUtils.areEqual(mUri, that.mUri)) return false; // Don't compare equality of mDarkTheme because it is only used in the default contact // photo case. When the contact does have a photo, the contact photo is the same // regardless of mDarkTheme, so we shouldn't need to put the photo request on the queue // twice. return true; }
private ContactInfo createPhoneLookupContactInfo(Cursor phoneLookupCursor, String lookupKey) { ContactInfo info = new ContactInfo(); info.lookupKey = lookupKey; info.lookupUri = Contacts.getLookupUri(phoneLookupCursor.getLong(PhoneQuery.PERSON_ID), lookupKey); info.name = phoneLookupCursor.getString(PhoneQuery.NAME); info.type = phoneLookupCursor.getInt(PhoneQuery.PHONE_TYPE); info.label = phoneLookupCursor.getString(PhoneQuery.LABEL); info.number = phoneLookupCursor.getString(PhoneQuery.MATCHED_NUMBER); info.normalizedNumber = phoneLookupCursor.getString(PhoneQuery.NORMALIZED_NUMBER); info.photoId = phoneLookupCursor.getLong(PhoneQuery.PHOTO_ID); info.photoUri = UriUtils.parseUriOrNull(phoneLookupCursor.getString(PhoneQuery.PHOTO_URI)); info.formattedNumber = null; info.userType = ContactsUtils.determineUserType(null, phoneLookupCursor.getLong(PhoneQuery.PERSON_ID)); return info; }
private void updateContactPhoto() { if (mDetails == null) { return; } final boolean isVoicemailNumber = PhoneNumberUtil.isVoicemailNumber(mContext, mDetails.accountHandle, mNumber); final boolean isBusiness = mContactInfoHelper.isBusiness(mDetails.sourceType); int contactType = ContactPhotoManager.TYPE_DEFAULT; if (isVoicemailNumber) { contactType = ContactPhotoManager.TYPE_VOICEMAIL; } else if (isBusiness) { contactType = ContactPhotoManager.TYPE_BUSINESS; } final String displayName = TextUtils.isEmpty(mDetails.namePrimary) ? mDetails.displayNumber : mDetails.namePrimary.toString(); final String lookupKey = mDetails.contactUri == null ? null : UriUtils.getLookupKeyFromUri(mDetails.contactUri); final DefaultImageRequest request = new DefaultImageRequest(displayName, lookupKey, contactType, true /* isCircular */); mQuickContactBadge.assignContactUri(mDetails.contactUri); mQuickContactBadge.setContentDescription( mResources.getString(R.string.description_contact_details, displayName)); mContactPhotoManager.loadDirectoryPhoto(mQuickContactBadge, mDetails.photoUri, false /* darkTheme */, true /* isCircular */, request); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ContactInfo other = (ContactInfo) obj; if (!UriUtils.areEqual(lookupUri, other.lookupUri)) return false; if (!TextUtils.equals(name, other.name)) return false; if (!TextUtils.equals(nameAlternative, other.nameAlternative)) return false; if (type != other.type) return false; if (!TextUtils.equals(label, other.label)) return false; if (!TextUtils.equals(number, other.number)) return false; if (!TextUtils.equals(formattedNumber, other.formattedNumber)) return false; if (!TextUtils.equals(normalizedNumber, other.normalizedNumber)) return false; if (photoId != other.photoId) return false; if (!UriUtils.areEqual(photoUri, other.photoUri)) return false; if (!TextUtils.equals(objectId, other.objectId)) return false; if (userType != other.userType) return false; return true; }
actionUri = UriUtils.parseUriOrNull(cursor.getString(VOICEMAIL_ACCESS_URI_INDEX)); actionUri = UriUtils.parseUriOrNull(cursor.getString(SETTINGS_URI_INDEX));
public void updatePhoto() { quickContactView.assignContactUri(info.lookupUri); final boolean isVoicemail = mCallLogCache.isVoicemailNumber(accountHandle, number); int contactType = ContactPhotoManager.TYPE_DEFAULT; if (isVoicemail) { contactType = ContactPhotoManager.TYPE_VOICEMAIL; } else if (isBusiness) { contactType = ContactPhotoManager.TYPE_BUSINESS; } final String lookupKey = info.lookupUri != null ? UriUtils.getLookupKeyFromUri(info.lookupUri) : null; final String displayName = TextUtils.isEmpty(info.name) ? displayNumber : info.name; final DefaultImageRequest request = new DefaultImageRequest( displayName, lookupKey, contactType, true /* isCircular */); if (info.photoId == 0 && info.photoUri != null) { ContactPhotoManager.getInstance(mContext).loadPhoto(quickContactView, info.photoUri, mPhotoSize, false /* darkTheme */, true /* isCircular */, request); } else { ContactPhotoManager.getInstance(mContext).loadThumbnail(quickContactView, info.photoId, false /* darkTheme */, true /* isCircular */, request); } if (mExtendedBlockingButtonRenderer != null) { mExtendedBlockingButtonRenderer.updatePhotoAndLabelIfNecessary( number, countryIso, quickContactView, phoneCallDetailsViews.callLocationAndDate); } }
final boolean resultIsCached; if (cachedResult != null && UriUtils.areEqual(cachedResult.getLookupUri(), mLookupUri)) {
if (info != null && UriUtils.isEncodedContactUri(info.lookupUri)) { createNewContactButtonView.setTag(IntentProvider.getAddContactIntentProvider( info.lookupUri, info.name, info.number, info.type, true /* isNewContact */));
lookupKey = UriUtils.getLookupKeyFromUri(contactUri);