From 8f2fc3ab74c0e31c3880b04660eb543841eee009 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Fri, 4 Sep 2020 00:30:14 +1000 Subject: [PATCH] New user avatar placeholder for message received notification. --- .../SingleRecipientNotificationBuilder.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java index bc5f695a35..29fab4e4c3 100644 --- a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java +++ b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java @@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto; import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto; import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto; import org.thoughtcrime.securesms.logging.Log; +import org.thoughtcrime.securesms.loki.todo.AvatarPlaceholderGenerator; import org.thoughtcrime.securesms.loki.utilities.NotificationUtilities; import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader; import org.thoughtcrime.securesms.mms.GlideApp; @@ -80,9 +81,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil addPerson(recipient.getContactUri().toString()); } - ContactPhoto contactPhoto = recipient.getContactPhoto(); - FallbackContactPhoto fallbackContactPhoto = recipient.getFallbackContactPhoto(); - + ContactPhoto contactPhoto = recipient.getContactPhoto(); if (contactPhoto != null) { try { setLargeIcon(GlideApp.with(context.getApplicationContext()) @@ -94,10 +93,10 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil .get()); } catch (InterruptedException | ExecutionException e) { Log.w(TAG, e); - setLargeIcon(fallbackContactPhoto.asDrawable(context, recipient.getColor().toConversationColor(context))); + setLargeIcon(obtainAvatarPlaceholderDrawable(context, recipient)); } } else { - setLargeIcon(fallbackContactPhoto.asDrawable(context, recipient.getColor().toConversationColor(context))); + setLargeIcon(obtainAvatarPlaceholderDrawable(context, recipient)); } } else { @@ -321,4 +320,14 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil return content; } + private static Drawable obtainAvatarPlaceholderDrawable(Context context, Recipient recipient) { + //TODO Copied from ProfilePictureView#setProfilePictureIfNeeded + // Refactor this code to use the same recipient placeholder generator method across the app. + String publicKey = recipient.getAddress().serialize(); + String hepk = (recipient.isLocalNumber() && publicKey != null) + ? TextSecurePreferences.getMasterHexEncodedPublicKey(context) + : publicKey; + String displayName = recipient.getName(); + return AvatarPlaceholderGenerator.INSTANCE.generate(context, 128, hepk, displayName); + } }