mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 11:19:19 +00:00
bump sdk to 22, update notifications
Notification updates include: 1) Setting theme colors 2) Using high-res contact photos 3) Updating the notification icon to latest Closes #2935 Fixes #2923 Fixes #2732 Fixes #2548 // FREEBIE
This commit is contained in:
committed by
Moxie Marlinspike
parent
c1af7557b5
commit
64fc83326f
@@ -53,6 +53,7 @@ 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.BitmapUtil;
|
||||
import org.thoughtcrime.securesms.util.SpanUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.textsecure.api.messages.TextSecureEnvelope;
|
||||
@@ -181,14 +182,18 @@ public class MessageNotifier {
|
||||
Recipient recipient = notifications.get(0).getIndividualRecipient();
|
||||
Bitmap recipientPhoto = recipient.getContactPhoto();
|
||||
|
||||
if (recipientPhoto != null) builder.setLargeIcon(BitmapUtil.getCircleBitmap(recipientPhoto));
|
||||
builder.setSmallIcon(R.drawable.icon_notification);
|
||||
if (recipientPhoto != null) builder.setLargeIcon(recipientPhoto);
|
||||
builder.setColor(context.getResources().getColor(R.color.textsecure_primary));
|
||||
builder.setContentTitle(recipient.toShortString());
|
||||
builder.setContentText(notifications.get(0).getText());
|
||||
builder.setContentIntent(notifications.get(0).getPendingIntent(context));
|
||||
builder.setContentInfo(String.valueOf(notificationState.getMessageCount()));
|
||||
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||
builder.setNumber(notificationState.getMessageCount());
|
||||
builder.setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
||||
builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0));
|
||||
if (recipient.getContactUri() != null) builder.addPerson(recipient.getContactUri().toString());
|
||||
|
||||
if (masterSecret != null) {
|
||||
builder.addAction(R.drawable.check, context.getString(R.string.MessageNotifier_mark_as_read),
|
||||
@@ -224,17 +229,19 @@ public class MessageNotifier {
|
||||
List<NotificationItem> notifications = notificationState.getNotifications();
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
|
||||
|
||||
builder.setColor(context.getResources().getColor(R.color.textsecure_primary));
|
||||
builder.setSmallIcon(R.drawable.icon_notification);
|
||||
builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
|
||||
R.drawable.icon_notification));
|
||||
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).getIndividualRecipientName()));
|
||||
builder.setContentTitle(context.getString(R.string.app_name));
|
||||
builder.setSubText(context.getString(R.string.MessageNotifier_d_messages_in_d_conversations,
|
||||
notificationState.getMessageCount(),
|
||||
notificationState.getThreadCount()));
|
||||
builder.setContentText(context.getString(R.string.MessageNotifier_most_recent_from_s,
|
||||
notifications.get(0).getIndividualRecipientName()));
|
||||
builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, ConversationListActivity.class), 0));
|
||||
|
||||
builder.setContentInfo(String.valueOf(notificationState.getMessageCount()));
|
||||
builder.setNumber(notificationState.getMessageCount());
|
||||
builder.setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
||||
|
||||
builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0));
|
||||
|
||||
@@ -249,6 +256,9 @@ public class MessageNotifier {
|
||||
while(iterator.hasPrevious()) {
|
||||
NotificationItem item = iterator.previous();
|
||||
style.addLine(item.getTickerText());
|
||||
if (item.getIndividualRecipient().getContactUri() != null) {
|
||||
builder.addPerson(item.getIndividualRecipient().getContactUri().toString());
|
||||
}
|
||||
}
|
||||
|
||||
builder.setStyle(style);
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.thoughtcrime.securesms.notifications;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
@@ -30,6 +29,10 @@ public class NotificationState {
|
||||
return threads.size() > 1;
|
||||
}
|
||||
|
||||
public int getThreadCount() {
|
||||
return threads.size();
|
||||
}
|
||||
|
||||
public int getMessageCount() {
|
||||
return notificationCount;
|
||||
}
|
||||
@@ -38,10 +41,6 @@ public class NotificationState {
|
||||
return notifications;
|
||||
}
|
||||
|
||||
public Bitmap getContactPhoto() {
|
||||
return notifications.get(0).getIndividualRecipient().getContactPhoto();
|
||||
}
|
||||
|
||||
public PendingIntent getMarkAsReadIntent(Context context, MasterSecret masterSecret) {
|
||||
long[] threadArray = new long[threads.size()];
|
||||
int index = 0;
|
||||
|
||||
Reference in New Issue
Block a user