mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Start expiration timer when marked read from notification
// FREEBIE
This commit is contained in:
parent
8e1970c398
commit
8d44a145f0
@ -92,6 +92,8 @@ import org.thoughtcrime.securesms.database.DraftDatabase;
|
|||||||
import org.thoughtcrime.securesms.database.DraftDatabase.Draft;
|
import org.thoughtcrime.securesms.database.DraftDatabase.Draft;
|
||||||
import org.thoughtcrime.securesms.database.DraftDatabase.Drafts;
|
import org.thoughtcrime.securesms.database.DraftDatabase.Drafts;
|
||||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||||
|
import org.thoughtcrime.securesms.database.MessagingDatabase;
|
||||||
|
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||||
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
|
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
|
||||||
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
|
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
|
||||||
@ -110,6 +112,7 @@ import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
|||||||
import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage;
|
import org.thoughtcrime.securesms.mms.OutgoingSecureMediaMessage;
|
||||||
import org.thoughtcrime.securesms.mms.Slide;
|
import org.thoughtcrime.securesms.mms.Slide;
|
||||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||||
|
import org.thoughtcrime.securesms.notifications.MarkReadReceiver;
|
||||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||||
import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
|
import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
@ -1305,14 +1308,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
new AsyncTask<Long, Void, Void>() {
|
new AsyncTask<Long, Void, Void>() {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Long... params) {
|
protected Void doInBackground(Long... params) {
|
||||||
Context context = ConversationActivity.this;
|
Context context = ConversationActivity.this;
|
||||||
List<SyncMessageId> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(params[0]);
|
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(params[0]);
|
||||||
|
|
||||||
MessageNotifier.updateNotification(context, masterSecret);
|
MessageNotifier.updateNotification(context, masterSecret);
|
||||||
|
MarkReadReceiver.process(context, messageIds);
|
||||||
if (!messageIds.isEmpty()) {
|
|
||||||
ApplicationContext.getInstance(context).getJobManager().add(new MultiDeviceReadUpdateJob(context, messageIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,11 @@ import org.thoughtcrime.securesms.components.reminder.SystemSmsImportReminder;
|
|||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase;
|
import org.thoughtcrime.securesms.database.MessagingDatabase;
|
||||||
|
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||||
import org.thoughtcrime.securesms.database.loaders.ConversationListLoader;
|
import org.thoughtcrime.securesms.database.loaders.ConversationListLoader;
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
|
||||||
|
import org.thoughtcrime.securesms.notifications.MarkReadReceiver;
|
||||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
@ -472,14 +474,9 @@ public class ConversationListFragment extends Fragment
|
|||||||
DatabaseFactory.getThreadDatabase(getActivity()).archiveConversation(threadId);
|
DatabaseFactory.getThreadDatabase(getActivity()).archiveConversation(threadId);
|
||||||
|
|
||||||
if (!read) {
|
if (!read) {
|
||||||
List<SyncMessageId> messageIds = DatabaseFactory.getThreadDatabase(getActivity()).setRead(threadId);
|
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(getActivity()).setRead(threadId);
|
||||||
MessageNotifier.updateNotification(getActivity(), masterSecret);
|
MessageNotifier.updateNotification(getActivity(), masterSecret);
|
||||||
|
MarkReadReceiver.process(getActivity(), messageIds);
|
||||||
if (!messageIds.isEmpty()) {
|
|
||||||
ApplicationContext.getInstance(getActivity())
|
|
||||||
.getJobManager()
|
|
||||||
.add(new MultiDeviceReadUpdateJob(getActivity(), messageIds));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
|
|||||||
private final long timetamp;
|
private final long timetamp;
|
||||||
|
|
||||||
public SyncMessageId(String address, long timetamp) {
|
public SyncMessageId(String address, long timetamp) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.timetamp = timetamp;
|
this.timetamp = timetamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,4 +184,55 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
|
|||||||
return timetamp;
|
return timetamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ExpirationInfo {
|
||||||
|
|
||||||
|
private final long id;
|
||||||
|
private final long expiresIn;
|
||||||
|
private final long expireStarted;
|
||||||
|
private final boolean mms;
|
||||||
|
|
||||||
|
public ExpirationInfo(long id, long expiresIn, long expireStarted, boolean mms) {
|
||||||
|
this.id = id;
|
||||||
|
this.expiresIn = expiresIn;
|
||||||
|
this.expireStarted = expireStarted;
|
||||||
|
this.mms = mms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpiresIn() {
|
||||||
|
return expiresIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpireStarted() {
|
||||||
|
return expireStarted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMms() {
|
||||||
|
return mms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MarkedMessageInfo {
|
||||||
|
|
||||||
|
private final SyncMessageId syncMessageId;
|
||||||
|
private final ExpirationInfo expirationInfo;
|
||||||
|
|
||||||
|
public MarkedMessageInfo(SyncMessageId syncMessageId, ExpirationInfo expirationInfo) {
|
||||||
|
this.syncMessageId = syncMessageId;
|
||||||
|
this.expirationInfo = expirationInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SyncMessageId getSyncMessageId() {
|
||||||
|
return syncMessageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpirationInfo getExpirationInfo() {
|
||||||
|
return expirationInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -455,21 +455,24 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
notifyConversationListeners(threadId);
|
notifyConversationListeners(threadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SyncMessageId> setMessagesRead(long threadId) {
|
public List<MarkedMessageInfo> setMessagesRead(long threadId) {
|
||||||
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
||||||
String where = THREAD_ID + " = ? AND " + READ + " = 0";
|
String where = THREAD_ID + " = ? AND " + READ + " = 0";
|
||||||
String[] selection = new String[]{String.valueOf(threadId)};
|
String[] selection = new String[]{String.valueOf(threadId)};
|
||||||
List<SyncMessageId> result = new LinkedList<>();
|
List<MarkedMessageInfo> result = new LinkedList<>();
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
|
|
||||||
database.beginTransaction();
|
database.beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cursor = database.query(TABLE_NAME, new String[] {ADDRESS, DATE_SENT, MESSAGE_BOX}, where, selection, null, null, null);
|
cursor = database.query(TABLE_NAME, new String[] {ID, ADDRESS, DATE_SENT, MESSAGE_BOX, EXPIRES_IN, EXPIRE_STARTED}, where, selection, null, null, null);
|
||||||
|
|
||||||
while(cursor != null && cursor.moveToNext()) {
|
while(cursor != null && cursor.moveToNext()) {
|
||||||
if (Types.isSecureType(cursor.getLong(2))) {
|
if (Types.isSecureType(cursor.getLong(3))) {
|
||||||
result.add(new SyncMessageId(cursor.getString(0), cursor.getLong(1)));
|
SyncMessageId syncMessageId = new SyncMessageId(cursor.getString(1), cursor.getLong(2));
|
||||||
|
ExpirationInfo expirationInfo = new ExpirationInfo(cursor.getLong(0), cursor.getLong(4), cursor.getLong(5), true);
|
||||||
|
|
||||||
|
result.add(new MarkedMessageInfo(syncMessageId, expirationInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,20 +318,23 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SyncMessageId> setMessagesRead(long threadId) {
|
public List<MarkedMessageInfo> setMessagesRead(long threadId) {
|
||||||
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
||||||
String where = THREAD_ID + " = ? AND " + READ + " = 0";
|
String where = THREAD_ID + " = ? AND " + READ + " = 0";
|
||||||
String[] selection = new String[]{String.valueOf(threadId)};
|
String[] selection = new String[]{String.valueOf(threadId)};
|
||||||
List<SyncMessageId> results = new LinkedList<>();
|
List<MarkedMessageInfo> results = new LinkedList<>();
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
|
|
||||||
database.beginTransaction();
|
database.beginTransaction();
|
||||||
try {
|
try {
|
||||||
cursor = database.query(TABLE_NAME, new String[] {ADDRESS, DATE_SENT, TYPE}, where, selection, null, null, null);
|
cursor = database.query(TABLE_NAME, new String[] {ID, ADDRESS, DATE_SENT, TYPE, EXPIRES_IN, EXPIRE_STARTED}, where, selection, null, null, null);
|
||||||
|
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
if (Types.isSecureType(cursor.getLong(2))) {
|
if (Types.isSecureType(cursor.getLong(3))) {
|
||||||
results.add(new SyncMessageId(cursor.getString(0), cursor.getLong(1)));
|
SyncMessageId syncMessageId = new SyncMessageId(cursor.getString(1), cursor.getLong(2));
|
||||||
|
ExpirationInfo expirationInfo = new ExpirationInfo(cursor.getLong(0), cursor.getLong(4), cursor.getLong(5), false);
|
||||||
|
|
||||||
|
results.add(new MarkedMessageInfo(syncMessageId, expirationInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
||||||
|
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||||
import org.thoughtcrime.securesms.database.model.DisplayRecord;
|
import org.thoughtcrime.securesms.database.model.DisplayRecord;
|
||||||
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
||||||
@ -261,19 +262,19 @@ public class ThreadDatabase extends Database {
|
|||||||
notifyConversationListListeners();
|
notifyConversationListListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SyncMessageId> setRead(long threadId) {
|
public List<MarkedMessageInfo> setRead(long threadId) {
|
||||||
ContentValues contentValues = new ContentValues(1);
|
ContentValues contentValues = new ContentValues(1);
|
||||||
contentValues.put(READ, 1);
|
contentValues.put(READ, 1);
|
||||||
|
|
||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||||
db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] {threadId+""});
|
db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] {threadId+""});
|
||||||
|
|
||||||
final List<SyncMessageId> smsRecords = DatabaseFactory.getSmsDatabase(context).setMessagesRead(threadId);
|
final List<MarkedMessageInfo> smsRecords = DatabaseFactory.getSmsDatabase(context).setMessagesRead(threadId);
|
||||||
final List<SyncMessageId> mmsRecords = DatabaseFactory.getMmsDatabase(context).setMessagesRead(threadId);
|
final List<MarkedMessageInfo> mmsRecords = DatabaseFactory.getMmsDatabase(context).setMessagesRead(threadId);
|
||||||
|
|
||||||
notifyConversationListListeners();
|
notifyConversationListListeners();
|
||||||
|
|
||||||
return new LinkedList<SyncMessageId>() {{
|
return new LinkedList<MarkedMessageInfo>() {{
|
||||||
addAll(smsRecords);
|
addAll(smsRecords);
|
||||||
addAll(mmsRecords);
|
addAll(mmsRecords);
|
||||||
}};
|
}};
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package org.thoughtcrime.securesms.jobs;
|
package org.thoughtcrime.securesms.jobs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.dependencies.TextSecureCommunicationModule;
|
import org.thoughtcrime.securesms.dependencies.TextSecureCommunicationModule;
|
||||||
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.whispersystems.jobqueue.JobParameters;
|
import org.whispersystems.jobqueue.JobParameters;
|
||||||
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
||||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||||
@ -49,6 +51,11 @@ public class MultiDeviceReadUpdateJob extends MasterSecretJob implements Injecta
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun(MasterSecret masterSecret) throws IOException, UntrustedIdentityException {
|
public void onRun(MasterSecret masterSecret) throws IOException, UntrustedIdentityException {
|
||||||
|
if (!TextSecurePreferences.isMultiDevice(context)) {
|
||||||
|
Log.w(TAG, "Not multi device...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<ReadMessage> readMessages = new LinkedList<>();
|
List<ReadMessage> readMessages = new LinkedList<>();
|
||||||
|
|
||||||
for (SerializableSyncMessageId messageId : messageIds) {
|
for (SerializableSyncMessageId messageId : messageIds) {
|
||||||
|
@ -4,14 +4,20 @@ import android.app.NotificationManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.annotation.UiThread;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
|
import org.thoughtcrime.securesms.database.MessagingDatabase;
|
||||||
|
import org.thoughtcrime.securesms.database.MessagingDatabase.ExpirationInfo;
|
||||||
|
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
|
||||||
|
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,8 +29,7 @@ public class MarkReadReceiver extends MasterSecretBroadcastReceiver {
|
|||||||
public static final String THREAD_IDS_EXTRA = "thread_ids";
|
public static final String THREAD_IDS_EXTRA = "thread_ids";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onReceive(final Context context, Intent intent,
|
protected void onReceive(final Context context, Intent intent, @Nullable final MasterSecret masterSecret)
|
||||||
@Nullable final MasterSecret masterSecret)
|
|
||||||
{
|
{
|
||||||
if (!CLEAR_ACTION.equals(intent.getAction()))
|
if (!CLEAR_ACTION.equals(intent.getAction()))
|
||||||
return;
|
return;
|
||||||
@ -40,25 +45,47 @@ public class MarkReadReceiver extends MasterSecretBroadcastReceiver {
|
|||||||
new AsyncTask<Void, Void, Void>() {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
List<SyncMessageId> messageIdsCollection = new LinkedList<>();
|
List<MarkedMessageInfo> messageIdsCollection = new LinkedList<>();
|
||||||
|
|
||||||
for (long threadId : threadIds) {
|
for (long threadId : threadIds) {
|
||||||
Log.w(TAG, "Marking as read: " + threadId);
|
Log.w(TAG, "Marking as read: " + threadId);
|
||||||
List<SyncMessageId> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId);
|
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId);
|
||||||
messageIdsCollection.addAll(messageIds);
|
messageIdsCollection.addAll(messageIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageNotifier.updateNotification(context, masterSecret);
|
process(context, messageIdsCollection);
|
||||||
|
|
||||||
if (!messageIdsCollection.isEmpty()) {
|
MessageNotifier.updateNotification(context, masterSecret);
|
||||||
ApplicationContext.getInstance(context)
|
|
||||||
.getJobManager()
|
|
||||||
.add(new MultiDeviceReadUpdateJob(context, messageIdsCollection));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void process(@NonNull Context context, @NonNull List<MarkedMessageInfo> markedReadMessages) {
|
||||||
|
if (markedReadMessages.isEmpty()) return;
|
||||||
|
|
||||||
|
List<SyncMessageId> syncMessageIds = new LinkedList<>();
|
||||||
|
|
||||||
|
for (MarkedMessageInfo messageInfo : markedReadMessages) {
|
||||||
|
scheduleDeletion(context, messageInfo.getExpirationInfo());
|
||||||
|
syncMessageIds.add(messageInfo.getSyncMessageId());
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplicationContext.getInstance(context)
|
||||||
|
.getJobManager()
|
||||||
|
.add(new MultiDeviceReadUpdateJob(context, syncMessageIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void scheduleDeletion(Context context, ExpirationInfo expirationInfo) {
|
||||||
|
if (expirationInfo.getExpiresIn() > 0 && expirationInfo.getExpireStarted() <= 0) {
|
||||||
|
ExpiringMessageManager expirationManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
|
||||||
|
|
||||||
|
if (expirationInfo.isMms()) DatabaseFactory.getMmsDatabase(context).markExpireStarted(expirationInfo.getId());
|
||||||
|
else DatabaseFactory.getSmsDatabase(context).markExpireStarted(expirationInfo.getId());
|
||||||
|
|
||||||
|
expirationManager.scheduleDeletion(expirationInfo.getId(), expirationInfo.isMms(), expirationInfo.getExpiresIn());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,8 @@ import org.thoughtcrime.securesms.ConversationActivity;
|
|||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
|
import org.thoughtcrime.securesms.database.MessagingDatabase;
|
||||||
|
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||||
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
||||||
import org.thoughtcrime.securesms.database.PushDatabase;
|
import org.thoughtcrime.securesms.database.PushDatabase;
|
||||||
@ -140,13 +142,8 @@ public class MessageNotifier {
|
|||||||
.getRecipientsForThreadId(threadId);
|
.getRecipientsForThreadId(threadId);
|
||||||
|
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
List<SyncMessageId> messageIds = threads.setRead(threadId);
|
List<MarkedMessageInfo> messageIds = threads.setRead(threadId);
|
||||||
|
MarkReadReceiver.process(context, messageIds);
|
||||||
if (!messageIds.isEmpty()) {
|
|
||||||
ApplicationContext.getInstance(context)
|
|
||||||
.getJobManager()
|
|
||||||
.add(new MultiDeviceReadUpdateJob(context, messageIds));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TextSecurePreferences.isNotificationsEnabled(context) ||
|
if (!TextSecurePreferences.isNotificationsEnabled(context) ||
|
||||||
|
@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.attachments.Attachment;
|
|||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase;
|
import org.thoughtcrime.securesms.database.MessagingDatabase;
|
||||||
|
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||||
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
|
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
|
||||||
@ -83,14 +84,9 @@ public class WearReplyReceiver extends MasterSecretBroadcastReceiver {
|
|||||||
threadId = MessageSender.send(context, masterSecret, reply, -1, false);
|
threadId = MessageSender.send(context, masterSecret, reply, -1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SyncMessageId> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId);
|
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId);
|
||||||
MessageNotifier.updateNotification(context, masterSecret);
|
MessageNotifier.updateNotification(context, masterSecret);
|
||||||
|
MarkReadReceiver.process(context, messageIds);
|
||||||
if (!messageIds.isEmpty()) {
|
|
||||||
ApplicationContext.getInstance(context)
|
|
||||||
.getJobManager()
|
|
||||||
.add(new MultiDeviceReadUpdateJob(context, messageIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user