use of org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto in project Signal-Android by signalapp.
the class ProfilePreference method refresh.
public void refresh() {
if (profileNumberView == null)
return;
final Address localAddress = Address.fromSerialized(TextSecurePreferences.getLocalNumber(getContext()));
final String profileName = TextSecurePreferences.getProfileName(getContext());
GlideApp.with(getContext().getApplicationContext()).load(new ProfileContactPhoto(localAddress, String.valueOf(TextSecurePreferences.getProfileAvatarId(getContext())))).error(new ResourceContactPhoto(R.drawable.ic_camera_alt_white_24dp).asDrawable(getContext(), getContext().getResources().getColor(R.color.grey_400))).circleCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(avatarView);
if (!TextUtils.isEmpty(profileName)) {
profileNameView.setText(profileName);
}
profileNumberView.setText(localAddress.toPhoneString());
}
use of org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto in project Signal-Android by signalapp.
the class AvatarImageView method setAvatar.
private void setAvatar(@NonNull GlideRequests requestManager, @Nullable Recipient recipient, @NonNull AvatarOptions avatarOptions) {
if (recipient != null) {
RecipientContactPhoto photo = (recipient.isSelf() && avatarOptions.useSelfProfileAvatar) ? new RecipientContactPhoto(recipient, new ProfileContactPhoto(Recipient.self(), Recipient.self().getProfileAvatar())) : new RecipientContactPhoto(recipient);
boolean shouldBlur = recipient.shouldBlurAvatar();
ChatColors chatColors = recipient.getChatColors();
if (!photo.equals(recipientContactPhoto) || shouldBlur != blurred || !Objects.equals(chatColors, this.chatColors)) {
requestManager.clear(this);
this.chatColors = chatColors;
recipientContactPhoto = photo;
Drawable fallbackContactPhotoDrawable = size == SIZE_SMALL ? photo.recipient.getSmallFallbackContactPhotoDrawable(getContext(), inverted, fallbackPhotoProvider, ViewUtil.getWidth(this)) : photo.recipient.getFallbackContactPhotoDrawable(getContext(), inverted, fallbackPhotoProvider, ViewUtil.getWidth(this));
if (fixedSizeTarget != null) {
requestManager.clear(fixedSizeTarget);
}
if (photo.contactPhoto != null) {
List<Transformation<Bitmap>> transforms = new ArrayList<>();
if (shouldBlur) {
transforms.add(new BlurTransformation(ApplicationDependencies.getApplication(), 0.25f, BlurTransformation.MAX_RADIUS));
}
transforms.add(new CircleCrop());
blurred = shouldBlur;
GlideRequest<Drawable> request = requestManager.load(photo.contactPhoto).dontAnimate().fallback(fallbackContactPhotoDrawable).error(fallbackContactPhotoDrawable).diskCacheStrategy(DiskCacheStrategy.ALL).downsample(DownsampleStrategy.CENTER_INSIDE).transform(new MultiTransformation<>(transforms));
if (avatarOptions.fixedSize > 0) {
fixedSizeTarget = new FixedSizeTarget(avatarOptions.fixedSize);
request.into(fixedSizeTarget);
} else {
request.into(this);
}
} else {
setImageDrawable(fallbackContactPhotoDrawable);
}
}
setAvatarClickHandler(recipient, avatarOptions.quickContactEnabled);
} else {
recipientContactPhoto = null;
requestManager.clear(this);
if (fallbackPhotoProvider != null) {
setImageDrawable(fallbackPhotoProvider.getPhotoForRecipientWithoutName().asDrawable(getContext(), AvatarColor.UNKNOWN, inverted));
} else {
setImageDrawable(unknownRecipientDrawable);
}
disableQuickContact();
}
}
use of org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto in project Signal-Android by signalapp.
the class AvatarUtil method request.
private static <T> GlideRequest<T> request(@NonNull GlideRequest<T> glideRequest, @NonNull Context context, @NonNull Recipient recipient, boolean loadSelf, int targetSize) {
final ContactPhoto photo;
if (Recipient.self().equals(recipient) && loadSelf) {
photo = new ProfileContactPhoto(recipient, recipient.getProfileAvatar());
} else {
photo = recipient.getContactPhoto();
}
final GlideRequest<T> request = glideRequest.load(photo).error(getFallback(context, recipient, targetSize)).diskCacheStrategy(DiskCacheStrategy.ALL);
if (recipient.shouldBlurAvatar()) {
return request.transform(new BlurTransformation(context, 0.25f, BlurTransformation.MAX_RADIUS));
} else {
return request;
}
}
use of org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto in project Signal-Android by WhisperSystems.
the class CallParticipantView method setPipAvatar.
private void setPipAvatar(@NonNull Recipient recipient) {
ContactPhoto contactPhoto = recipient.isSelf() ? new ProfileContactPhoto(Recipient.self(), Recipient.self().getProfileAvatar()) : recipient.getContactPhoto();
FallbackContactPhoto fallbackPhoto = recipient.getFallbackContactPhoto(FALLBACK_PHOTO_PROVIDER);
GlideApp.with(this).load(contactPhoto).fallback(fallbackPhoto.asCallCard(getContext())).error(fallbackPhoto.asCallCard(getContext())).diskCacheStrategy(DiskCacheStrategy.ALL).into(pipAvatar);
pipAvatar.setScaleType(contactPhoto == null ? ImageView.ScaleType.CENTER_INSIDE : ImageView.ScaleType.CENTER_CROP);
ChatColors chatColors = recipient.getChatColors();
pipAvatar.setBackground(chatColors.getChatBubbleMask());
}
use of org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto in project Signal-Android by WhisperSystems.
the class AvatarImageView method setAvatar.
private void setAvatar(@NonNull GlideRequests requestManager, @Nullable Recipient recipient, @NonNull AvatarOptions avatarOptions) {
if (recipient != null) {
RecipientContactPhoto photo = (recipient.isSelf() && avatarOptions.useSelfProfileAvatar) ? new RecipientContactPhoto(recipient, new ProfileContactPhoto(Recipient.self(), Recipient.self().getProfileAvatar())) : new RecipientContactPhoto(recipient);
boolean shouldBlur = recipient.shouldBlurAvatar();
ChatColors chatColors = recipient.getChatColors();
if (!photo.equals(recipientContactPhoto) || shouldBlur != blurred || !Objects.equals(chatColors, this.chatColors)) {
requestManager.clear(this);
this.chatColors = chatColors;
recipientContactPhoto = photo;
Drawable fallbackContactPhotoDrawable = size == SIZE_SMALL ? photo.recipient.getSmallFallbackContactPhotoDrawable(getContext(), inverted, fallbackPhotoProvider, ViewUtil.getWidth(this)) : photo.recipient.getFallbackContactPhotoDrawable(getContext(), inverted, fallbackPhotoProvider, ViewUtil.getWidth(this));
if (fixedSizeTarget != null) {
requestManager.clear(fixedSizeTarget);
}
if (photo.contactPhoto != null) {
List<Transformation<Bitmap>> transforms = new ArrayList<>();
if (shouldBlur) {
transforms.add(new BlurTransformation(ApplicationDependencies.getApplication(), 0.25f, BlurTransformation.MAX_RADIUS));
}
transforms.add(new CircleCrop());
blurred = shouldBlur;
GlideRequest<Drawable> request = requestManager.load(photo.contactPhoto).dontAnimate().fallback(fallbackContactPhotoDrawable).error(fallbackContactPhotoDrawable).diskCacheStrategy(DiskCacheStrategy.ALL).downsample(DownsampleStrategy.CENTER_INSIDE).transform(new MultiTransformation<>(transforms));
if (avatarOptions.fixedSize > 0) {
fixedSizeTarget = new FixedSizeTarget(avatarOptions.fixedSize);
request.into(fixedSizeTarget);
} else {
request.into(this);
}
} else {
setImageDrawable(fallbackContactPhotoDrawable);
}
}
setAvatarClickHandler(recipient, avatarOptions.quickContactEnabled);
} else {
recipientContactPhoto = null;
requestManager.clear(this);
if (fallbackPhotoProvider != null) {
setImageDrawable(fallbackPhotoProvider.getPhotoForRecipientWithoutName().asDrawable(getContext(), AvatarColor.UNKNOWN, inverted));
} else {
setImageDrawable(unknownRecipientDrawable);
}
disableQuickContact();
}
}
Aggregations