mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 06:49:35 +00:00
Migrate from SQLite and ciphertext blobs to SQLCipher + KeyStore
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (C) 2011 Whisper Systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.thoughtcrime.securesms.notifications;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
@@ -41,6 +42,7 @@ public class AndroidAutoHeardReceiver extends MasterSecretBroadcastReceiver {
|
||||
public static final String THREAD_IDS_EXTRA = "car_heard_thread_ids";
|
||||
public static final String NOTIFICATION_ID_EXTRA = "car_notification_id";
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Override
|
||||
protected void onReceive(final Context context, Intent intent,
|
||||
@Nullable final MasterSecret masterSecret)
|
||||
@@ -66,7 +68,7 @@ public class AndroidAutoHeardReceiver extends MasterSecretBroadcastReceiver {
|
||||
messageIdsCollection.addAll(messageIds);
|
||||
}
|
||||
|
||||
MessageNotifier.updateNotification(context, masterSecret);
|
||||
MessageNotifier.updateNotification(context);
|
||||
MarkReadReceiver.process(context, messageIdsCollection);
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (C) 2011 Whisper Systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.thoughtcrime.securesms.notifications;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
@@ -24,18 +25,15 @@ import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.RemoteInput;
|
||||
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
||||
import org.whispersystems.libsignal.logging.Log;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -51,6 +49,7 @@ public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
public static final String VOICE_REPLY_KEY = "car_voice_reply_key";
|
||||
public static final String THREAD_ID_EXTRA = "car_reply_thread_id";
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Override
|
||||
protected void onReceive(final Context context, Intent intent,
|
||||
final @Nullable MasterSecret masterSecret)
|
||||
@@ -78,17 +77,17 @@ public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
|
||||
if (recipient.isGroupRecipient()) {
|
||||
Log.w("AndroidAutoReplyReceiver", "GroupRecipient, Sending media message");
|
||||
OutgoingMediaMessage reply = new OutgoingMediaMessage(recipient, responseText.toString(), new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0);
|
||||
replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false, null);
|
||||
OutgoingMediaMessage reply = new OutgoingMediaMessage(recipient, responseText.toString(), new LinkedList<>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0);
|
||||
replyThreadId = MessageSender.send(context, reply, threadId, false, null);
|
||||
} else {
|
||||
Log.w("AndroidAutoReplyReceiver", "Sending regular message ");
|
||||
OutgoingTextMessage reply = new OutgoingTextMessage(recipient, responseText.toString(), expiresIn, subscriptionId);
|
||||
replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false, null);
|
||||
replyThreadId = MessageSender.send(context, reply, threadId, false, null);
|
||||
}
|
||||
|
||||
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(replyThreadId, true);
|
||||
|
||||
MessageNotifier.updateNotification(context, masterSecret);
|
||||
MessageNotifier.updateNotification(context);
|
||||
MarkReadReceiver.process(context, messageIds);
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.notifications;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
@@ -33,6 +34,7 @@ public class MarkReadReceiver extends MasterSecretBroadcastReceiver {
|
||||
public static final String THREAD_IDS_EXTRA = "thread_ids";
|
||||
public static final String NOTIFICATION_ID_EXTRA = "notification_id";
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Override
|
||||
protected void onReceive(final Context context, Intent intent, @Nullable final MasterSecret masterSecret)
|
||||
{
|
||||
@@ -57,7 +59,7 @@ public class MarkReadReceiver extends MasterSecretBroadcastReceiver {
|
||||
|
||||
process(context, messageIdsCollection);
|
||||
|
||||
MessageNotifier.updateNotification(context, masterSecret);
|
||||
MessageNotifier.updateNotification(context);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (C) 2011 Whisper Systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms.notifications;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
@@ -32,14 +33,12 @@ import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.ConversationActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
||||
@@ -184,28 +183,25 @@ public class MessageNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateNotification(@NonNull Context context, @Nullable MasterSecret masterSecret) {
|
||||
public static void updateNotification(@NonNull Context context) {
|
||||
if (!TextSecurePreferences.isNotificationsEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateNotification(context, masterSecret, false, 0);
|
||||
updateNotification(context, false, 0);
|
||||
}
|
||||
|
||||
public static void updateNotification(@NonNull Context context,
|
||||
@Nullable MasterSecret masterSecret,
|
||||
long threadId)
|
||||
public static void updateNotification(@NonNull Context context, long threadId)
|
||||
{
|
||||
if (System.currentTimeMillis() - lastDesktopActivityTimestamp < DESKTOP_ACTIVITY_PERIOD) {
|
||||
Log.w(TAG, "Scheduling delayed notification...");
|
||||
executor.execute(new DelayedNotification(context, masterSecret, threadId));
|
||||
executor.execute(new DelayedNotification(context, threadId));
|
||||
} else {
|
||||
updateNotification(context, masterSecret, threadId, true);
|
||||
updateNotification(context, threadId, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateNotification(@NonNull Context context,
|
||||
@Nullable MasterSecret masterSecret,
|
||||
long threadId,
|
||||
boolean signal)
|
||||
{
|
||||
@@ -229,12 +225,11 @@ public class MessageNotifier {
|
||||
if (isVisible) {
|
||||
sendInThreadNotification(context, threads.getRecipientForThreadId(threadId));
|
||||
} else {
|
||||
updateNotification(context, masterSecret, signal, 0);
|
||||
updateNotification(context, signal, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateNotification(@NonNull Context context,
|
||||
@Nullable MasterSecret masterSecret,
|
||||
private static void updateNotification(@NonNull Context context,
|
||||
boolean signal,
|
||||
int reminderCount)
|
||||
{
|
||||
@@ -254,7 +249,7 @@ public class MessageNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
NotificationState notificationState = constructNotificationState(context, masterSecret, telcoCursor);
|
||||
NotificationState notificationState = constructNotificationState(context, telcoCursor);
|
||||
|
||||
if (signal && (System.currentTimeMillis() - lastAudibleNotification) < MIN_AUDIBLE_PERIOD_MILLIS) {
|
||||
signal = false;
|
||||
@@ -265,13 +260,13 @@ public class MessageNotifier {
|
||||
if (notificationState.hasMultipleThreads()) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
for (long threadId : notificationState.getThreads()) {
|
||||
sendSingleThreadNotification(context, masterSecret, new NotificationState(notificationState.getNotificationsForThread(threadId)), false, true);
|
||||
sendSingleThreadNotification(context, new NotificationState(notificationState.getNotificationsForThread(threadId)), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
sendMultipleThreadNotification(context, notificationState, signal);
|
||||
} else {
|
||||
sendSingleThreadNotification(context, masterSecret, notificationState, signal, false);
|
||||
sendSingleThreadNotification(context, notificationState, signal, false);
|
||||
}
|
||||
|
||||
cancelOrphanedNotifications(context, notificationState);
|
||||
@@ -287,7 +282,6 @@ public class MessageNotifier {
|
||||
}
|
||||
|
||||
private static void sendSingleThreadNotification(@NonNull Context context,
|
||||
@Nullable MasterSecret masterSecret,
|
||||
@NonNull NotificationState notificationState,
|
||||
boolean signal, boolean bundled)
|
||||
{
|
||||
@@ -296,7 +290,7 @@ public class MessageNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder(context, masterSecret, TextSecurePreferences.getNotificationPrivacy(context));
|
||||
SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context));
|
||||
List<NotificationItem> notifications = notificationState.getNotifications();
|
||||
Recipient recipient = notifications.get(0).getRecipient();
|
||||
int notificationId = (int) (SUMMARY_NOTIFICATION_ID + (bundled ? notifications.get(0).getThreadId() : 0));
|
||||
@@ -313,8 +307,7 @@ public class MessageNotifier {
|
||||
long timestamp = notifications.get(0).getTimestamp();
|
||||
if (timestamp != 0) builder.setWhen(timestamp);
|
||||
|
||||
builder.addActions(masterSecret,
|
||||
notificationState.getMarkAsReadIntent(context, notificationId),
|
||||
builder.addActions(notificationState.getMarkAsReadIntent(context, notificationId),
|
||||
notificationState.getQuickReplyIntent(context, notifications.get(0).getRecipient()),
|
||||
notificationState.getRemoteReplyIntent(context, notifications.get(0).getRecipient()));
|
||||
|
||||
@@ -411,15 +404,12 @@ public class MessageNotifier {
|
||||
}
|
||||
|
||||
private static NotificationState constructNotificationState(@NonNull Context context,
|
||||
@Nullable MasterSecret masterSecret,
|
||||
@NonNull Cursor cursor)
|
||||
{
|
||||
NotificationState notificationState = new NotificationState();
|
||||
MessageRecord record;
|
||||
MmsSmsDatabase.Reader reader;
|
||||
NotificationState notificationState = new NotificationState();
|
||||
MmsSmsDatabase.Reader reader = DatabaseFactory.getMmsSmsDatabase(context).readerFor(cursor);
|
||||
|
||||
if (masterSecret == null) reader = DatabaseFactory.getMmsSmsDatabase(context).readerFor(cursor);
|
||||
else reader = DatabaseFactory.getMmsSmsDatabase(context).readerFor(cursor, masterSecret);
|
||||
MessageRecord record;
|
||||
|
||||
while ((record = reader.getNext()) != null) {
|
||||
long id = record.getId();
|
||||
@@ -495,14 +485,14 @@ public class MessageNotifier {
|
||||
|
||||
public static final String REMINDER_ACTION = "org.thoughtcrime.securesms.MessageNotifier.REMINDER_ACTION";
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);
|
||||
int reminderCount = intent.getIntExtra("reminder_count", 0);
|
||||
MessageNotifier.updateNotification(context, masterSecret, true, reminderCount + 1);
|
||||
int reminderCount = intent.getIntExtra("reminder_count", 0);
|
||||
MessageNotifier.updateNotification(context, true, reminderCount + 1);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -516,22 +506,19 @@ public class MessageNotifier {
|
||||
|
||||
private final AtomicBoolean canceled = new AtomicBoolean(false);
|
||||
|
||||
private final Context context;
|
||||
private final MasterSecret masterSecret;
|
||||
private final Context context;
|
||||
private final long threadId;
|
||||
private final long delayUntil;
|
||||
|
||||
private final long threadId;
|
||||
private final long delayUntil;
|
||||
|
||||
private DelayedNotification(Context context, MasterSecret masterSecret, long threadId) {
|
||||
this.context = context;
|
||||
this.masterSecret = masterSecret;
|
||||
this.threadId = threadId;
|
||||
this.delayUntil = System.currentTimeMillis() + DELAY;
|
||||
private DelayedNotification(Context context, long threadId) {
|
||||
this.context = context;
|
||||
this.threadId = threadId;
|
||||
this.delayUntil = System.currentTimeMillis() + DELAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
MessageNotifier.updateNotification(context, masterSecret);
|
||||
MessageNotifier.updateNotification(context);
|
||||
|
||||
long delayMillis = delayUntil - System.currentTimeMillis();
|
||||
Log.w(TAG, "Waiting to notify: " + delayMillis);
|
||||
@@ -542,7 +529,7 @@ public class MessageNotifier {
|
||||
|
||||
if (!canceled.get()) {
|
||||
Log.w(TAG, "Not canceled, notifying...");
|
||||
MessageNotifier.updateNotification(context, masterSecret, threadId, true);
|
||||
MessageNotifier.updateNotification(context, threadId, true);
|
||||
MessageNotifier.cancelDelayedNotifications();
|
||||
} else {
|
||||
Log.w(TAG, "Canceled, not notifying...");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (C) 2016 Open Whisper Systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.thoughtcrime.securesms.notifications;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
@@ -24,17 +25,14 @@ import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.RemoteInput;
|
||||
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -48,6 +46,7 @@ public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
public static final String REPLY_ACTION = "org.thoughtcrime.securesms.notifications.WEAR_REPLY";
|
||||
public static final String ADDRESS_EXTRA = "address";
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Override
|
||||
protected void onReceive(final Context context, Intent intent,
|
||||
final @Nullable MasterSecret masterSecret)
|
||||
@@ -72,16 +71,16 @@ public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
long expiresIn = recipient.getExpireMessages() * 1000;
|
||||
|
||||
if (recipient.isGroupRecipient()) {
|
||||
OutgoingMediaMessage reply = new OutgoingMediaMessage(recipient, responseText.toString(), new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0);
|
||||
threadId = MessageSender.send(context, masterSecret, reply, -1, false, null);
|
||||
OutgoingMediaMessage reply = new OutgoingMediaMessage(recipient, responseText.toString(), new LinkedList<>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0);
|
||||
threadId = MessageSender.send(context, reply, -1, false, null);
|
||||
} else {
|
||||
OutgoingTextMessage reply = new OutgoingTextMessage(recipient, responseText.toString(), expiresIn, subscriptionId);
|
||||
threadId = MessageSender.send(context, masterSecret, reply, -1, false, null);
|
||||
threadId = MessageSender.send(context, reply, -1, false, null);
|
||||
}
|
||||
|
||||
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId, true);
|
||||
|
||||
MessageNotifier.updateNotification(context, masterSecret);
|
||||
MessageNotifier.updateNotification(context);
|
||||
MarkReadReceiver.process(context, messageIds);
|
||||
|
||||
return null;
|
||||
|
||||
@@ -43,18 +43,13 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
|
||||
private final List<CharSequence> messageBodies = new LinkedList<>();
|
||||
|
||||
private SlideDeck slideDeck;
|
||||
private final MasterSecret masterSecret;
|
||||
|
||||
private SlideDeck slideDeck;
|
||||
private CharSequence contentTitle;
|
||||
private CharSequence contentText;
|
||||
|
||||
public SingleRecipientNotificationBuilder(@NonNull Context context,
|
||||
@Nullable MasterSecret masterSecret,
|
||||
@NonNull NotificationPrivacyPreference privacy)
|
||||
public SingleRecipientNotificationBuilder(@NonNull Context context, @NonNull NotificationPrivacyPreference privacy)
|
||||
{
|
||||
super(context, privacy);
|
||||
this.masterSecret = masterSecret;
|
||||
|
||||
setSmallIcon(R.drawable.icon_notification);
|
||||
setColor(context.getResources().getColor(R.color.textsecure_primary));
|
||||
@@ -141,8 +136,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
extend(new NotificationCompat.CarExtender().setUnreadConversation(unreadConversationBuilder.build()));
|
||||
}
|
||||
|
||||
public void addActions(@Nullable MasterSecret masterSecret,
|
||||
@NonNull PendingIntent markReadIntent,
|
||||
public void addActions(@NonNull PendingIntent markReadIntent,
|
||||
@NonNull PendingIntent quickReplyIntent,
|
||||
@NonNull PendingIntent wearableReplyIntent)
|
||||
{
|
||||
@@ -150,37 +144,31 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
context.getString(R.string.MessageNotifier_mark_read),
|
||||
markReadIntent);
|
||||
|
||||
if (masterSecret != null) {
|
||||
Action replyAction = new Action(R.drawable.ic_reply_white_36dp,
|
||||
context.getString(R.string.MessageNotifier_reply),
|
||||
quickReplyIntent);
|
||||
Action replyAction = new Action(R.drawable.ic_reply_white_36dp,
|
||||
context.getString(R.string.MessageNotifier_reply),
|
||||
quickReplyIntent);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
replyAction = new Action.Builder(R.drawable.ic_reply_white_36dp,
|
||||
context.getString(R.string.MessageNotifier_reply),
|
||||
wearableReplyIntent)
|
||||
.addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY)
|
||||
.setLabel(context.getString(R.string.MessageNotifier_reply)).build())
|
||||
.build();
|
||||
}
|
||||
|
||||
Action wearableReplyAction = new Action.Builder(R.drawable.ic_reply,
|
||||
context.getString(R.string.MessageNotifier_reply),
|
||||
wearableReplyIntent)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
replyAction = new Action.Builder(R.drawable.ic_reply_white_36dp,
|
||||
context.getString(R.string.MessageNotifier_reply),
|
||||
wearableReplyIntent)
|
||||
.addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY)
|
||||
.setLabel(context.getString(R.string.MessageNotifier_reply)).build())
|
||||
.build();
|
||||
|
||||
addAction(markAsReadAction);
|
||||
addAction(replyAction);
|
||||
|
||||
extend(new NotificationCompat.WearableExtender().addAction(markAsReadAction)
|
||||
.addAction(wearableReplyAction));
|
||||
} else {
|
||||
addAction(markAsReadAction);
|
||||
|
||||
extend(new NotificationCompat.WearableExtender().addAction(markAsReadAction));
|
||||
}
|
||||
|
||||
Action wearableReplyAction = new Action.Builder(R.drawable.ic_reply,
|
||||
context.getString(R.string.MessageNotifier_reply),
|
||||
wearableReplyIntent)
|
||||
.addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY)
|
||||
.setLabel(context.getString(R.string.MessageNotifier_reply)).build())
|
||||
.build();
|
||||
|
||||
addAction(markAsReadAction);
|
||||
addAction(replyAction);
|
||||
|
||||
extend(new NotificationCompat.WearableExtender().addAction(markAsReadAction)
|
||||
.addAction(wearableReplyAction));
|
||||
}
|
||||
|
||||
public void addMessageBody(@NonNull Recipient threadRecipient,
|
||||
@@ -204,9 +192,8 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
public Notification build() {
|
||||
if (privacy.isDisplayMessage()) {
|
||||
if (messageBodies.size() == 1 && hasBigPictureSlide(slideDeck)) {
|
||||
assert masterSecret != null;
|
||||
setStyle(new NotificationCompat.BigPictureStyle()
|
||||
.bigPicture(getBigPicture(masterSecret, slideDeck))
|
||||
.bigPicture(getBigPicture(slideDeck))
|
||||
.setSummaryText(getBigText(messageBodies)));
|
||||
} else {
|
||||
setStyle(new NotificationCompat.BigTextStyle().bigText(getBigText(messageBodies)));
|
||||
@@ -228,7 +215,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
}
|
||||
|
||||
private boolean hasBigPictureSlide(@Nullable SlideDeck slideDeck) {
|
||||
if (masterSecret == null || slideDeck == null || Build.VERSION.SDK_INT < 16) {
|
||||
if (slideDeck == null || Build.VERSION.SDK_INT < 16) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -240,8 +227,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
thumbnailSlide.getThumbnailUri() != null;
|
||||
}
|
||||
|
||||
private Bitmap getBigPicture(@NonNull MasterSecret masterSecret,
|
||||
@NonNull SlideDeck slideDeck)
|
||||
private Bitmap getBigPicture(@NonNull SlideDeck slideDeck)
|
||||
{
|
||||
try {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@@ -249,7 +235,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
||||
|
||||
return GlideApp.with(context.getApplicationContext())
|
||||
.asBitmap()
|
||||
.load(new DecryptableStreamUriLoader.DecryptableUri(masterSecret, uri))
|
||||
.load(new DecryptableStreamUriLoader.DecryptableUri(uri))
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.submit(500, 500)
|
||||
.get();
|
||||
|
||||
Reference in New Issue
Block a user