Skip to content

Commit

Permalink
Fix bug that broke notifications for group messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
moxie0 committed Feb 26, 2014
1 parent d3148b6 commit 37a52df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
19 changes: 12 additions & 7 deletions src/org/thoughtcrime/securesms/notifications/MessageNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ private static void appendPushNotificationState(Context context,
SpannableString body = new SpannableString(context.getString(R.string.MessageNotifier_encrypted_message));
body.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

notificationState.addNotification(new NotificationItem(recipient, recipients, threadId, body, null));
notificationState.addNotification(new NotificationItem(recipient, recipients, null, threadId, body, null));
}
} finally {
if (reader != null)
Expand All @@ -324,19 +324,24 @@ private static NotificationState constructNotificationState(Context context,
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();
Uri image = null;
Recipient recipient = record.getIndividualRecipient();
Recipients recipients = record.getRecipients();
long threadId = record.getThreadId();
SpannableString body = record.getDisplayBody();
Uri image = null;
Recipients threadRecipients = null;

if (threadId != -1) {
threadRecipients = DatabaseFactory.getThreadDatabase(context).getRecipientsForThreadId(threadId);
}

// XXXX This is so fucked up. FIX ME!
if (body.toString().equals(context.getString(R.string.MessageDisplayHelper_decrypting_please_wait))) {
body = new SpannableString(context.getString(R.string.MessageNotifier_encrypted_message));
body.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}

notificationState.addNotification(new NotificationItem(recipient, recipients, threadId, body, image));
notificationState.addNotification(new NotificationItem(recipient, recipients, threadRecipients, threadId, body, image));
}

reader.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ public class NotificationItem {

private final Recipients recipients;
private final Recipient individualRecipient;
private final Recipients threadRecipients;
private final long threadId;
private final CharSequence text;
private final Uri image;

public NotificationItem(Recipient individualRecipient, Recipients recipients, long threadId,
public NotificationItem(Recipient individualRecipient, Recipients recipients,
Recipients threadRecipients, long threadId,
CharSequence text, Uri image)
{
this.individualRecipient = individualRecipient;
this.recipients = recipients;
this.threadRecipients = threadRecipients;
this.text = text;
this.image = image;
this.threadId = threadId;
Expand Down Expand Up @@ -70,8 +73,10 @@ public PendingIntent getPendingIntent(Context context) {
Intent intent = new Intent(context, RoutingActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

if (recipients != null) {
intent.putExtra("recipients", recipients);
if (recipients != null || threadRecipients != null) {
if (threadRecipients != null) intent.putExtra("recipients", threadRecipients);
else intent.putExtra("recipients", recipients);

intent.putExtra("thread_id", threadId);
}

Expand Down

1 comment on commit 37a52df

@WhisperBTC
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! BitHub has sent payment of $88.28USD for this commit.

Please sign in to comment.