|
|
|
@ -42,13 +42,17 @@ import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
|
|
|
|
import org.thoughtcrime.securesms.database.PushDatabase;
|
|
|
|
|
import org.thoughtcrime.securesms.database.SmsDatabase;
|
|
|
|
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
|
|
|
|
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
|
|
|
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
|
|
|
|
import org.thoughtcrime.securesms.mms.SlideDeck;
|
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
|
|
|
|
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
|
|
|
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
|
|
|
|
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
|
|
|
|
import org.thoughtcrime.securesms.util.SpanUtil;
|
|
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
|
|
|
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
|
|
|
|
|
import org.whispersystems.textsecure.api.messages.TextSecureEnvelope;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
@ -187,12 +191,12 @@ public class MessageNotifier {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context));
|
|
|
|
|
SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder(context, masterSecret, TextSecurePreferences.getNotificationPrivacy(context));
|
|
|
|
|
List<NotificationItem> notifications = notificationState.getNotifications();
|
|
|
|
|
|
|
|
|
|
builder.setSender(notifications.get(0).getIndividualRecipient());
|
|
|
|
|
builder.setMessageCount(notificationState.getMessageCount());
|
|
|
|
|
builder.setPrimaryMessageBody(notifications.get(0).getText());
|
|
|
|
|
builder.setPrimaryMessageBody(notifications.get(0).getText(), notifications.get(0).getSlideDeck());
|
|
|
|
|
builder.setContentIntent(notifications.get(0).getPendingIntent(context));
|
|
|
|
|
|
|
|
|
|
long timestamp = notifications.get(0).getTimestamp();
|
|
|
|
@ -318,7 +322,7 @@ public class MessageNotifier {
|
|
|
|
|
body.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
|
|
|
|
if (!recipients.isMuted()) {
|
|
|
|
|
notificationState.addNotification(new NotificationItem(recipient, recipients, null, threadId, body, 0));
|
|
|
|
|
notificationState.addNotification(new NotificationItem(recipient, recipients, null, threadId, body, 0, null));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
@ -339,11 +343,12 @@ 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();
|
|
|
|
|
CharSequence body = record.getDisplayBody();
|
|
|
|
|
Recipients threadRecipients = null;
|
|
|
|
|
Recipient recipient = record.getIndividualRecipient();
|
|
|
|
|
Recipients recipients = record.getRecipients();
|
|
|
|
|
long threadId = record.getThreadId();
|
|
|
|
|
CharSequence body = record.getDisplayBody();
|
|
|
|
|
Recipients threadRecipients = null;
|
|
|
|
|
ListenableFutureTask<SlideDeck> slideDeck = null;
|
|
|
|
|
long timestamp;
|
|
|
|
|
|
|
|
|
|
if (record.isPush()) timestamp = record.getDateSent();
|
|
|
|
@ -357,14 +362,16 @@ public class MessageNotifier {
|
|
|
|
|
body = SpanUtil.italic(context.getString(R.string.MessageNotifier_locked_message));
|
|
|
|
|
} else if (record.isMms() && TextUtils.isEmpty(body)) {
|
|
|
|
|
body = SpanUtil.italic(context.getString(R.string.MessageNotifier_media_message));
|
|
|
|
|
slideDeck = ((MediaMmsMessageRecord)record).getSlideDeckFuture();
|
|
|
|
|
} else if (record.isMms() && !record.isMmsNotification()) {
|
|
|
|
|
String message = context.getString(R.string.MessageNotifier_media_message_with_text, body);
|
|
|
|
|
int italicLength = message.length() - body.length();
|
|
|
|
|
body = SpanUtil.italic(message, italicLength);
|
|
|
|
|
slideDeck = ((MediaMmsMessageRecord)record).getSlideDeckFuture();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (threadRecipients == null || !threadRecipients.isMuted()) {
|
|
|
|
|
notificationState.addNotification(new NotificationItem(recipient, recipients, threadRecipients, threadId, body, timestamp));
|
|
|
|
|
notificationState.addNotification(new NotificationItem(recipient, recipients, threadRecipients, threadId, body, timestamp, slideDeck));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|