mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
multiple different senders in a chat are now distinguished #128
This commit is contained in:
@@ -84,7 +84,7 @@ public class ConversationUpdateItem extends LinearLayout
|
||||
|
||||
private void bind(@NonNull DcMsg messageRecord, @NonNull Locale locale) {
|
||||
this.messageRecord = messageRecord;
|
||||
this.sender = Recipient.from(DcHelper.getContext(getContext()), messageRecord.getId());
|
||||
this.sender = Recipient.fromMsg(DcHelper.getContext(getContext()), messageRecord.getId());
|
||||
this.locale = locale;
|
||||
|
||||
this.sender.addListener(this);
|
||||
|
||||
@@ -202,10 +202,10 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
} else {
|
||||
messageRecord = dcContext.getMsg(msgId);
|
||||
initialMedia = new MediaItem(Recipient.from(context, msgId), Uri.fromFile(messageRecord.getFileAsFile()),
|
||||
initialMedia = new MediaItem(Recipient.fromChat(context, msgId), Uri.fromFile(messageRecord.getFileAsFile()),
|
||||
messageRecord.getFilemime(), messageRecord.getId(), messageRecord.getDateReceived(),
|
||||
messageRecord.getFilebytes(), messageRecord.isOutgoing());
|
||||
conversationRecipient = Recipient.from(context, msgId);
|
||||
conversationRecipient = Recipient.fromChat(context, msgId);
|
||||
}
|
||||
leftIsRecent = getIntent().getBooleanExtra(LEFT_IS_RECENT_EXTRA, false);
|
||||
restartItem = -1;
|
||||
@@ -564,7 +564,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
if (msg.getFile() == null) throw new AssertionError();
|
||||
|
||||
return new MediaItem(Recipient.from(context, msg.getId()),
|
||||
return new MediaItem(Recipient.fromChat(context, msg.getId()),
|
||||
Uri.fromFile(msg.getFileAsFile()),
|
||||
msg.getFilemime(),
|
||||
msg.getId(),
|
||||
|
||||
@@ -292,7 +292,7 @@ public class MessageNotifier {
|
||||
|
||||
builder.setThread(notifications.get(0).getRecipient());
|
||||
builder.setMessageCount(notificationState.getMessageCount());
|
||||
builder.setPrimaryMessageBody(recipient, notifications.get(0).getRecipient(),
|
||||
builder.setPrimaryMessageBody(recipient, notifications.get(0).getIndividualRecipient(),
|
||||
notifications.get(0).getText(""), notifications.get(0).getSlideDeck());
|
||||
builder.setContentIntent(notifications.get(0).getPendingIntent(context));
|
||||
builder.setGroup(NOTIFICATION_GROUP);
|
||||
@@ -312,12 +312,12 @@ public class MessageNotifier {
|
||||
|
||||
while(iterator.hasPrevious()) {
|
||||
NotificationItem item = iterator.previous();
|
||||
builder.addMessageBody(item.getRecipient(), item.getRecipient(), item.getText());
|
||||
builder.addMessageBody(item.getRecipient(), item.getIndividualRecipient(), item.getText());
|
||||
}
|
||||
|
||||
if (signal) {
|
||||
builder.setAlarms(notificationState.getRingtone(), notificationState.getVibrate());
|
||||
builder.setTicker(notifications.get(0).getRecipient(),
|
||||
builder.setTicker(notifications.get(0).getIndividualRecipient(),
|
||||
notifications.get(0).getText());
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ public class MessageNotifier {
|
||||
List<NotificationItem> notifications = notificationState.getNotifications();
|
||||
|
||||
builder.setMessageCount(notificationState.getMessageCount(), notificationState.getThreadCount());
|
||||
builder.setMostRecentSender(notifications.get(0).getRecipient());
|
||||
builder.setMostRecentSender(notifications.get(0).getIndividualRecipient());
|
||||
builder.setGroup(NOTIFICATION_GROUP);
|
||||
builder.setDeleteIntent(notificationState.getDeleteIntent(context));
|
||||
|
||||
@@ -349,12 +349,12 @@ public class MessageNotifier {
|
||||
|
||||
while(iterator.hasPrevious()) {
|
||||
NotificationItem item = iterator.previous();
|
||||
builder.addMessageBody(item.getRecipient(), item.getText());
|
||||
builder.addMessageBody(item.getIndividualRecipient(), item.getText());
|
||||
}
|
||||
|
||||
if (signal) {
|
||||
builder.setAlarms(notificationState.getRingtone(), notificationState.getVibrate());
|
||||
builder.setTicker(notifications.get(0).getRecipient(),
|
||||
builder.setTicker(notifications.get(0).getIndividualRecipient(),
|
||||
notifications.get(0).getText());
|
||||
}
|
||||
|
||||
@@ -409,7 +409,8 @@ public class MessageNotifier {
|
||||
boolean mms = record.isMms() || record.isMediaPending();
|
||||
int chatId = record.getChatId();
|
||||
CharSequence body = record.getDisplayBody();
|
||||
Recipient threadRecipients = Recipient.from(dcContext, msgId);
|
||||
Recipient threadRecipient = Recipient.fromChat(dcContext, msgId);
|
||||
Recipient individualRecipient = Recipient.fromMsg(dcContext, msgId);
|
||||
SlideDeck slideDeck = new SlideDeck(dcContext.context, record);
|
||||
long timestamp = record.getTimestamp();
|
||||
|
||||
@@ -425,8 +426,8 @@ public class MessageNotifier {
|
||||
body = SpanUtil.italic(message, italicLength);
|
||||
}
|
||||
|
||||
if (!threadRecipients.isMuted()) {
|
||||
notificationState.addNotification(new NotificationItem(id, mms, threadRecipients, chatId, body, timestamp, slideDeck));
|
||||
if (!threadRecipient.isMuted()) {
|
||||
notificationState.addNotification(new NotificationItem(id, mms, threadRecipient, individualRecipient, chatId, body, timestamp, slideDeck));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ public class NotificationItem {
|
||||
|
||||
private final int id;
|
||||
private final boolean mms;
|
||||
private final @Nullable Recipient threadRecipient;
|
||||
private final @NonNull Recipient threadRecipient;
|
||||
private final @Nullable Recipient individualRecipient;
|
||||
private final int chatId;
|
||||
private final @Nullable CharSequence text;
|
||||
private final long timestamp;
|
||||
@@ -24,12 +25,14 @@ public class NotificationItem {
|
||||
|
||||
public NotificationItem(int id, boolean mms,
|
||||
@NonNull Recipient threadRecipient,
|
||||
@Nullable Recipient individualRecipient,
|
||||
int chatId, @Nullable CharSequence text, long timestamp,
|
||||
@Nullable SlideDeck slideDeck)
|
||||
{
|
||||
this.id = id;
|
||||
this.mms = mms;
|
||||
this.threadRecipient = threadRecipient;
|
||||
this.individualRecipient = individualRecipient;
|
||||
this.text = text;
|
||||
this.chatId = chatId;
|
||||
this.timestamp = timestamp;
|
||||
@@ -56,12 +59,8 @@ public class NotificationItem {
|
||||
return chatId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use getThreadRecipient instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public @NonNull Recipient getIndividualRecipient() {
|
||||
return threadRecipient;
|
||||
return individualRecipient;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
||||
@@ -91,15 +91,19 @@ public class Recipient implements RecipientModifiedListener {
|
||||
private @Nullable String profileAvatar;
|
||||
private boolean profileSharing;
|
||||
|
||||
public static @NonNull Recipient from(@NonNull Context context, int dcMsgId) {
|
||||
public static @NonNull Recipient fromChat(@NonNull Context context, int dcMsgId) {
|
||||
ApplicationDcContext dcContext = DcHelper.getContext(context);
|
||||
return from(dcContext, dcMsgId);
|
||||
return fromChat(dcContext, dcMsgId);
|
||||
}
|
||||
|
||||
public static @NonNull Recipient from (@NonNull ApplicationDcContext dcContext, int dcMsgId) {
|
||||
public static @NonNull Recipient fromChat (@NonNull ApplicationDcContext dcContext, int dcMsgId) {
|
||||
return dcContext.getRecipient(dcContext.getChat(dcContext.getMsg(dcMsgId).getChatId()));
|
||||
}
|
||||
|
||||
public static @NonNull Recipient fromMsg (@NonNull ApplicationDcContext dcContext, int dcMsgId) {
|
||||
return dcContext.getRecipient(dcContext.getContact(dcContext.getMsg(dcMsgId).getFromId()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static @NonNull Recipient from(@NonNull Context context, @NonNull Address address, boolean asynchronous) {
|
||||
if (address == null) throw new AssertionError(address);
|
||||
|
||||
Reference in New Issue
Block a user