mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
fix: Show message sender in push notifications for groups
This commit is contained in:
parent
fbd1721eaf
commit
c537da6acd
@ -52,8 +52,8 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
|
|||||||
|
|
||||||
public void setMostRecentSender(Recipient recipient, Recipient threadRecipient) {
|
public void setMostRecentSender(Recipient recipient, Recipient threadRecipient) {
|
||||||
String displayName = recipient.toShortString();
|
String displayName = recipient.toShortString();
|
||||||
if (threadRecipient.isOpenGroupRecipient()) {
|
if (threadRecipient.isGroupRecipient()) {
|
||||||
displayName = getOpenGroupDisplayName(recipient);
|
displayName = getGroupDisplayName(recipient, threadRecipient.isOpenGroupRecipient());
|
||||||
}
|
}
|
||||||
if (privacy.isDisplayContact()) {
|
if (privacy.isDisplayContact()) {
|
||||||
setContentText(context.getString(R.string.MessageNotifier_most_recent_from_s, displayName));
|
setContentText(context.getString(R.string.MessageNotifier_most_recent_from_s, displayName));
|
||||||
@ -78,8 +78,8 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
|
|||||||
|
|
||||||
public void addMessageBody(@NonNull Recipient sender, Recipient threadRecipient, @Nullable CharSequence body) {
|
public void addMessageBody(@NonNull Recipient sender, Recipient threadRecipient, @Nullable CharSequence body) {
|
||||||
String displayName = sender.toShortString();
|
String displayName = sender.toShortString();
|
||||||
if (threadRecipient.isOpenGroupRecipient()) {
|
if (threadRecipient.isGroupRecipient()) {
|
||||||
displayName = getOpenGroupDisplayName(sender);
|
displayName = getGroupDisplayName(sender, threadRecipient.isOpenGroupRecipient());
|
||||||
}
|
}
|
||||||
if (privacy.isDisplayMessage()) {
|
if (privacy.isDisplayMessage()) {
|
||||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||||
@ -113,14 +113,15 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param recipient the * individual * recipient for which to get the open group display name.
|
* @param recipient the * individual * recipient for which to get the display name.
|
||||||
|
* @param openGroupRecipient whether in an open group context
|
||||||
*/
|
*/
|
||||||
private String getOpenGroupDisplayName(Recipient recipient) {
|
private String getGroupDisplayName(Recipient recipient, boolean openGroupRecipient) {
|
||||||
SessionContactDatabase contactDB = DatabaseComponent.get(context).sessionContactDatabase();
|
SessionContactDatabase contactDB = DatabaseComponent.get(context).sessionContactDatabase();
|
||||||
String sessionID = recipient.getAddress().serialize();
|
String sessionID = recipient.getAddress().serialize();
|
||||||
Contact contact = contactDB.getContactWithSessionID(sessionID);
|
Contact contact = contactDB.getContactWithSessionID(sessionID);
|
||||||
if (contact == null) { return sessionID; }
|
if (contact == null) { return sessionID; }
|
||||||
String displayName = contact.displayName(Contact.ContactContext.OPEN_GROUP);
|
String displayName = contact.displayName(openGroupRecipient ? Contact.ContactContext.OPEN_GROUP : Contact.ContactContext.REGULAR);
|
||||||
if (displayName == null) { return sessionID; }
|
if (displayName == null) { return sessionID; }
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
@ -117,15 +117,15 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
setNumber(messageCount);
|
setNumber(messageCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrimaryMessageBody(@NonNull Recipient threadRecipients,
|
public void setPrimaryMessageBody(@NonNull Recipient threadRecipient,
|
||||||
@NonNull Recipient individualRecipient,
|
@NonNull Recipient individualRecipient,
|
||||||
@NonNull CharSequence message,
|
@NonNull CharSequence message,
|
||||||
@Nullable SlideDeck slideDeck)
|
@Nullable SlideDeck slideDeck)
|
||||||
{
|
{
|
||||||
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
||||||
|
|
||||||
if (privacy.isDisplayContact() && threadRecipients.isOpenGroupRecipient()) {
|
if (privacy.isDisplayContact() && threadRecipient.isGroupRecipient()) {
|
||||||
String displayName = getOpenGroupDisplayName(individualRecipient);
|
String displayName = getGroupDisplayName(individualRecipient, threadRecipient.isOpenGroupRecipient());
|
||||||
stringBuilder.append(Util.getBoldedString(displayName + ": "));
|
stringBuilder.append(Util.getBoldedString(displayName + ": "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,8 +214,8 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
{
|
{
|
||||||
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
||||||
|
|
||||||
if (privacy.isDisplayContact() && threadRecipient.isOpenGroupRecipient()) {
|
if (privacy.isDisplayContact() && threadRecipient.isGroupRecipient()) {
|
||||||
String displayName = getOpenGroupDisplayName(individualRecipient);
|
String displayName = getGroupDisplayName(individualRecipient, threadRecipient.isOpenGroupRecipient());
|
||||||
stringBuilder.append(Util.getBoldedString(displayName + ": "));
|
stringBuilder.append(Util.getBoldedString(displayName + ": "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,14 +334,15 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param recipient the * individual * recipient for which to get the open group display name.
|
* @param recipient the * individual * recipient for which to get the display name.
|
||||||
|
* @param openGroupRecipient whether in an open group context
|
||||||
*/
|
*/
|
||||||
private String getOpenGroupDisplayName(Recipient recipient) {
|
private String getGroupDisplayName(Recipient recipient, boolean openGroupRecipient) {
|
||||||
SessionContactDatabase contactDB = DatabaseComponent.get(context).sessionContactDatabase();
|
SessionContactDatabase contactDB = DatabaseComponent.get(context).sessionContactDatabase();
|
||||||
String sessionID = recipient.getAddress().serialize();
|
String sessionID = recipient.getAddress().serialize();
|
||||||
Contact contact = contactDB.getContactWithSessionID(sessionID);
|
Contact contact = contactDB.getContactWithSessionID(sessionID);
|
||||||
if (contact == null) { return sessionID; }
|
if (contact == null) { return sessionID; }
|
||||||
String displayName = contact.displayName(Contact.ContactContext.OPEN_GROUP);
|
String displayName = contact.displayName(openGroupRecipient ? Contact.ContactContext.OPEN_GROUP : Contact.ContactContext.REGULAR);
|
||||||
if (displayName == null) { return sessionID; }
|
if (displayName == null) { return sessionID; }
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user