Search in sources :

Example 1 with GeneratedContactPhoto

use of org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto in project Signal-Android by signalapp.

the class SingleRecipientNotificationBuilder method setThread.

public void setThread(@NonNull Recipient recipient) {
    if (privacy.isDisplayContact()) {
        setContentTitle(recipient.toShortString());
        if (recipient.getContactUri() != null) {
            addPerson(recipient.getContactUri().toString());
        }
        ContactPhoto contactPhoto = recipient.getContactPhoto();
        FallbackContactPhoto fallbackContactPhoto = recipient.getFallbackContactPhoto();
        if (contactPhoto != null) {
            try {
                setLargeIcon(GlideApp.with(context.getApplicationContext()).load(contactPhoto).diskCacheStrategy(DiskCacheStrategy.ALL).circleCrop().submit(context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width), context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height)).get());
            } catch (InterruptedException | ExecutionException e) {
                Log.w(TAG, e);
                setLargeIcon(fallbackContactPhoto.asDrawable(context, recipient.getColor().toConversationColor(context)));
            }
        } else {
            setLargeIcon(fallbackContactPhoto.asDrawable(context, recipient.getColor().toConversationColor(context)));
        }
    } else {
        setContentTitle(context.getString(R.string.SingleRecipientNotificationBuilder_signal));
        setLargeIcon(new GeneratedContactPhoto("Unknown").asDrawable(context, ContactColors.UNKNOWN_COLOR.toConversationColor(context)));
    }
}
Also used : FallbackContactPhoto(org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto) GeneratedContactPhoto(org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto) ContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ContactPhoto) FallbackContactPhoto(org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto) ExecutionException(java.util.concurrent.ExecutionException) GeneratedContactPhoto(org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto)

Example 2 with GeneratedContactPhoto

use of org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto in project Signal-Android by WhisperSystems.

the class InsightsRepository method getUserAvatar.

@Override
public void getUserAvatar(@NonNull Consumer<InsightsUserAvatar> avatarConsumer) {
    SimpleTask.run(() -> {
        Recipient self = Recipient.self().resolve();
        String name = Optional.fromNullable(self.getDisplayName(context)).or("");
        return new InsightsUserAvatar(new ProfileContactPhoto(self, self.getProfileAvatar()), self.getAvatarColor(), new GeneratedContactPhoto(name, R.drawable.ic_profile_outline_40));
    }, avatarConsumer::accept);
}
Also used : ProfileContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto) Recipient(org.thoughtcrime.securesms.recipients.Recipient) GeneratedContactPhoto(org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto)

Example 3 with GeneratedContactPhoto

use of org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto in project Signal-Android by signalapp.

the class InsightsRepository method getUserAvatar.

@Override
public void getUserAvatar(@NonNull Consumer<InsightsUserAvatar> avatarConsumer) {
    SimpleTask.run(() -> {
        Recipient self = Recipient.self().resolve();
        String name = Optional.fromNullable(self.getDisplayName(context)).or("");
        return new InsightsUserAvatar(new ProfileContactPhoto(self, self.getProfileAvatar()), self.getAvatarColor(), new GeneratedContactPhoto(name, R.drawable.ic_profile_outline_40));
    }, avatarConsumer::accept);
}
Also used : ProfileContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto) Recipient(org.thoughtcrime.securesms.recipients.Recipient) GeneratedContactPhoto(org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto)

Aggregations

GeneratedContactPhoto (org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto)3 ProfileContactPhoto (org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto)2 Recipient (org.thoughtcrime.securesms.recipients.Recipient)2 ExecutionException (java.util.concurrent.ExecutionException)1 ContactPhoto (org.thoughtcrime.securesms.contacts.avatars.ContactPhoto)1 FallbackContactPhoto (org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto)1