mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 15:31:46 +00:00
First cut at group messaging refactor.
This commit is contained in:
@@ -46,6 +46,7 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -137,13 +138,13 @@ public class MessageNotifier {
|
||||
NotificationState notificationState,
|
||||
boolean signal)
|
||||
{
|
||||
List<NotificationItem> notifications = notificationState.getNotifications();
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
|
||||
Recipients recipients = notifications.get(0).getRecipients();
|
||||
List<NotificationItem>notifications = notificationState.getNotifications();
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
|
||||
Recipient recipient = notifications.get(0).getIndividualRecipient();
|
||||
|
||||
builder.setSmallIcon(R.drawable.icon_notification);
|
||||
builder.setLargeIcon(recipients.getPrimaryRecipient().getContactPhoto());
|
||||
builder.setContentTitle(recipients.getPrimaryRecipient().toShortString());
|
||||
builder.setLargeIcon(recipient.getContactPhoto());
|
||||
builder.setContentTitle(recipient.toShortString());
|
||||
builder.setContentText(notifications.get(0).getText());
|
||||
builder.setContentIntent(notifications.get(0).getPendingIntent(context));
|
||||
|
||||
@@ -179,7 +180,7 @@ public class MessageNotifier {
|
||||
builder.setContentTitle(String.format(context.getString(R.string.MessageNotifier_d_new_messages),
|
||||
notificationState.getMessageCount()));
|
||||
builder.setContentText(String.format(context.getString(R.string.MessageNotifier_most_recent_from_s),
|
||||
notifications.get(0).getRecipientName()));
|
||||
notifications.get(0).getIndividualRecipientName()));
|
||||
builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, RoutingActivity.class), 0));
|
||||
|
||||
InboxStyle style = new InboxStyle();
|
||||
@@ -246,6 +247,7 @@ public class MessageNotifier {
|
||||
else reader = DatabaseFactory.getMmsSmsDatabase(context).readerFor(cursor, masterSecret);
|
||||
|
||||
while ((record = reader.getNext()) != null) {
|
||||
Recipient recipient = record.getIndividualRecipient();
|
||||
Recipients recipients = record.getRecipients();
|
||||
long threadId = record.getThreadId();
|
||||
SpannableString body = record.getDisplayBody();
|
||||
@@ -257,7 +259,7 @@ public class MessageNotifier {
|
||||
body.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
notificationState.addNotification(new NotificationItem(recipients, threadId, body, image));
|
||||
notificationState.addNotification(new NotificationItem(recipient, recipients, threadId, body, image));
|
||||
}
|
||||
|
||||
return notificationState;
|
||||
|
||||
@@ -7,29 +7,34 @@ import android.net.Uri;
|
||||
import android.text.SpannableStringBuilder;
|
||||
|
||||
import org.thoughtcrime.securesms.RoutingActivity;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
public class NotificationItem {
|
||||
|
||||
private final Recipients recipients;
|
||||
private final Recipient individualRecipient;
|
||||
private final long threadId;
|
||||
private final CharSequence text;
|
||||
private final Uri image;
|
||||
|
||||
public NotificationItem(Recipients recipients, long threadId, CharSequence text, Uri image) {
|
||||
this.recipients = recipients;
|
||||
this.text = text;
|
||||
this.image = image;
|
||||
this.threadId = threadId;
|
||||
public NotificationItem(Recipient individualRecipient, Recipients recipients, long threadId,
|
||||
CharSequence text, Uri image)
|
||||
{
|
||||
this.individualRecipient = individualRecipient;
|
||||
this.recipients = recipients;
|
||||
this.text = text;
|
||||
this.image = image;
|
||||
this.threadId = threadId;
|
||||
}
|
||||
|
||||
public Recipients getRecipients() {
|
||||
return recipients;
|
||||
public Recipient getIndividualRecipient() {
|
||||
return individualRecipient;
|
||||
}
|
||||
|
||||
public String getRecipientName() {
|
||||
return recipients.getPrimaryRecipient().toShortString();
|
||||
public String getIndividualRecipientName() {
|
||||
return individualRecipient.toShortString();
|
||||
}
|
||||
|
||||
public CharSequence getText() {
|
||||
@@ -54,7 +59,7 @@ public class NotificationItem {
|
||||
|
||||
public CharSequence getTickerText() {
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
builder.append(Util.getBoldedString(getRecipientName()));
|
||||
builder.append(Util.getBoldedString(getIndividualRecipientName()));
|
||||
builder.append(": ");
|
||||
builder.append(getText());
|
||||
|
||||
@@ -65,7 +70,7 @@ public class NotificationItem {
|
||||
Intent intent = new Intent(context, RoutingActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
|
||||
if (recipients.getPrimaryRecipient() != null) {
|
||||
if (recipients != null) {
|
||||
intent.putExtra("recipients", recipients);
|
||||
intent.putExtra("thread_id", threadId);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class NotificationState {
|
||||
}
|
||||
|
||||
public Bitmap getContactPhoto() {
|
||||
return notifications.get(0).getRecipients().getPrimaryRecipient().getContactPhoto();
|
||||
return notifications.get(0).getIndividualRecipient().getContactPhoto();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user