mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-26 09:47:43 +00:00
New user avatar placeholder for message received notification.
This commit is contained in:
parent
3e82c8f9ea
commit
8f2fc3ab74
@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
|||||||
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
import org.thoughtcrime.securesms.loki.todo.AvatarPlaceholderGenerator;
|
||||||
import org.thoughtcrime.securesms.loki.utilities.NotificationUtilities;
|
import org.thoughtcrime.securesms.loki.utilities.NotificationUtilities;
|
||||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader;
|
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader;
|
||||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||||
@ -80,9 +81,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
addPerson(recipient.getContactUri().toString());
|
addPerson(recipient.getContactUri().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactPhoto contactPhoto = recipient.getContactPhoto();
|
ContactPhoto contactPhoto = recipient.getContactPhoto();
|
||||||
FallbackContactPhoto fallbackContactPhoto = recipient.getFallbackContactPhoto();
|
|
||||||
|
|
||||||
if (contactPhoto != null) {
|
if (contactPhoto != null) {
|
||||||
try {
|
try {
|
||||||
setLargeIcon(GlideApp.with(context.getApplicationContext())
|
setLargeIcon(GlideApp.with(context.getApplicationContext())
|
||||||
@ -94,10 +93,10 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
.get());
|
.get());
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
setLargeIcon(fallbackContactPhoto.asDrawable(context, recipient.getColor().toConversationColor(context)));
|
setLargeIcon(obtainAvatarPlaceholderDrawable(context, recipient));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setLargeIcon(fallbackContactPhoto.asDrawable(context, recipient.getColor().toConversationColor(context)));
|
setLargeIcon(obtainAvatarPlaceholderDrawable(context, recipient));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -321,4 +320,14 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
return content;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user