private Drawable getPhotoDrawable(byte[] bitmapData, String displayName, String lookupKey) { if (bitmapData != null) { Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length, null); return new BitmapDrawable(mContext.getResources(), bitmap); } else { return ContactPhotoManager.getDefaultAvatarDrawableForContact(mContext.getResources(), false, new DefaultImageRequest(displayName, lookupKey, false)); } }
/** * Retrieves the lookup key and display name from a cursor, and returns a * {@link DefaultImageRequest} containing these contact details * * @param cursor Contacts cursor positioned at the current row to retrieve contact details for * @param displayNameColumn Column index of the display name * @param lookupKeyColumn Column index of the lookup key * @return {@link DefaultImageRequest} with the displayName and identifier fields set to the * display name and lookup key of the contact. */ public DefaultImageRequest getDefaultImageRequestFromCursor(Cursor cursor, int displayNameColumn, int lookupKeyColumn) { final String displayName = cursor.getString(displayNameColumn); final String lookupKey = cursor.getString(lookupKeyColumn); return new DefaultImageRequest(displayName, lookupKey, mCircularPhotos); } }
protected static DefaultImageRequest getDefaultImageRequestFromUri(Uri uri) { final DefaultImageRequest request = new DefaultImageRequest( uri.getQueryParameter(DISPLAY_NAME_PARAM_KEY), uri.getQueryParameter(IDENTIFIER_PARAM_KEY), false); try { String contactType = uri.getQueryParameter(CONTACT_TYPE_PARAM_KEY); if (!TextUtils.isEmpty(contactType)) { request.contactType = Integer.valueOf(contactType); } String scale = uri.getQueryParameter(SCALE_PARAM_KEY); if (!TextUtils.isEmpty(scale)) { request.scale = Float.valueOf(scale); } String offset = uri.getQueryParameter(OFFSET_PARAM_KEY); if (!TextUtils.isEmpty(offset)) { request.offset = Float.valueOf(offset); } String isCircular = uri.getQueryParameter(IS_CIRCULAR_PARAM_KEY); if (!TextUtils.isEmpty(isCircular)) { request.isCircular = Boolean.valueOf(isCircular); } } catch (NumberFormatException e) { Log.w(TAG, "Invalid DefaultImageRequest image parameters provided, ignoring and using " + "defaults."); } return request; }
request = new ContactPhotoManager.DefaultImageRequest( displayName, lookupKey, contactType, true /* isCircular */);
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); } }
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); }
protected void bindPhoto(final ContactListItemView view, int partitionIndex, Cursor cursor) { if (!isPhotoSupported(partitionIndex)) { view.removePhotoView(); return; } long photoId = 0; if (!cursor.isNull(PhoneQuery.PHOTO_ID)) { photoId = cursor.getLong(PhoneQuery.PHOTO_ID); } if (photoId != 0) { getPhotoLoader().loadThumbnail(view.getPhotoView(), photoId, false, getCircularPhotos(), null); } else { final String photoUriString = cursor.getString(PhoneQuery.PHOTO_URI); final Uri photoUri = photoUriString == null ? null : Uri.parse(photoUriString); DefaultImageRequest request = null; if (photoUri == null) { final String displayName = cursor.getString(PhoneQuery.DISPLAY_NAME); final String lookupKey = cursor.getString(PhoneQuery.LOOKUP_KEY); request = new DefaultImageRequest(displayName, lookupKey, getCircularPhotos()); } getPhotoLoader().loadDirectoryPhoto(view.getPhotoView(), photoUri, false, getCircularPhotos(), request); } }
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); }
/** * Implemented by subclasses to allow them to return a {@link DefaultImageRequest} with the * various image parameters defined to match their own layouts. * * @param displayName The display name of the contact * @param lookupKey The lookup key of the contact * @return A {@link DefaultImageRequest} object with each field configured by the subclass * as desired, or {@code null}. */ protected DefaultImageRequest getDefaultImageRequest(String displayName, String lookupKey) { return new DefaultImageRequest(displayName, lookupKey, isContactPhotoCircular()); }
@Override protected DefaultImageRequest getDefaultImageRequest(String displayName, String lookupKey) { return new DefaultImageRequest(displayName, lookupKey, ContactPhotoManager.TYPE_DEFAULT, DEFAULT_IMAGE_LETTER_SCALE, DEFAULT_IMAGE_LETTER_OFFSET, false); }
@Override protected DefaultImageRequest getDefaultImageRequest(String displayName, String lookupKey) { return new DefaultImageRequest(displayName, lookupKey, ContactPhotoManager.TYPE_DEFAULT, DEFAULT_IMAGE_LETTER_SCALE, /* offset = */ 0, /* isCircular = */ true); } }