New user avatar placeholder for message received notification.

This commit is contained in:
Anton Chekulaev 2020-09-04 00:30:14 +10:00
parent 3e82c8f9ea
commit 8f2fc3ab74

View File

@ -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;
@ -81,8 +82,6 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
}
ContactPhoto contactPhoto = recipient.getContactPhoto();
FallbackContactPhoto fallbackContactPhoto = recipient.getFallbackContactPhoto();
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);
}
}