show message timestamp in the notification

Fixes #2632

Closes #2635
master
agrajaghh 2015-03-09 22:27:50 +01:00 committed by Moxie Marlinspike
parent c6a4877391
commit bcd9aa84d6
2 changed files with 19 additions and 3 deletions

View File

@ -195,6 +195,9 @@ public class MessageNotifier {
builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0));
if (recipient.getContactUri() != null) builder.addPerson(recipient.getContactUri().toString());
long timestamp = notifications.get(0).getTimestamp();
if (timestamp != 0) builder.setWhen(timestamp);
if (masterSecret != null) {
builder.addAction(R.drawable.check, context.getString(R.string.MessageNotifier_mark_as_read),
notificationState.getMarkAsReadIntent(context, masterSecret));
@ -243,6 +246,9 @@ public class MessageNotifier {
builder.setNumber(notificationState.getMessageCount());
builder.setCategory(NotificationCompat.CATEGORY_MESSAGE);
long timestamp = notifications.get(0).getTimestamp();
if (timestamp != 0) builder.setWhen(timestamp);
builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0));
if (masterSecret != null) {
@ -330,7 +336,7 @@ public class MessageNotifier {
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, null, threadId, body, null));
notificationState.addNotification(new NotificationItem(recipient, recipients, null, threadId, body, null, 0));
}
} finally {
if (reader != null)
@ -356,6 +362,10 @@ public class MessageNotifier {
CharSequence body = record.getDisplayBody();
Uri image = null;
Recipients threadRecipients = null;
long timestamp;
if (record.isPush()) timestamp = record.getDateSent();
else timestamp = record.getDateReceived();
if (threadId != -1) {
threadRecipients = DatabaseFactory.getThreadDatabase(context).getRecipientsForThreadId(threadId);
@ -371,7 +381,7 @@ public class MessageNotifier {
body = SpanUtil.italic(message, italicLength);
}
notificationState.addNotification(new NotificationItem(recipient, recipients, threadRecipients, threadId, body, image));
notificationState.addNotification(new NotificationItem(recipient, recipients, threadRecipients, threadId, body, image, timestamp));
}
reader.close();

View File

@ -19,10 +19,11 @@ public class NotificationItem {
private final long threadId;
private final CharSequence text;
private final Uri image;
private final long timestamp;
public NotificationItem(Recipient individualRecipient, Recipients recipients,
Recipients threadRecipients, long threadId,
CharSequence text, Uri image)
CharSequence text, Uri image, long timestamp)
{
this.individualRecipient = individualRecipient;
this.recipients = recipients;
@ -30,6 +31,7 @@ public class NotificationItem {
this.text = text;
this.image = image;
this.threadId = threadId;
this.timestamp = timestamp;
}
public Recipient getIndividualRecipient() {
@ -44,6 +46,10 @@ public class NotificationItem {
return text;
}
public long getTimestamp() {
return timestamp;
}
public Uri getImage() {
return image;
}