mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 07:59:14 +00:00
Start expiration timer when marked read from notification
// FREEBIE
This commit is contained in:
@@ -172,7 +172,7 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
|
||||
private final long timetamp;
|
||||
|
||||
public SyncMessageId(String address, long timetamp) {
|
||||
this.address = address;
|
||||
this.address = address;
|
||||
this.timetamp = timetamp;
|
||||
}
|
||||
|
||||
@@ -184,4 +184,55 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
|
||||
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);
|
||||
}
|
||||
|
||||
public List<SyncMessageId> setMessagesRead(long threadId) {
|
||||
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
||||
String where = THREAD_ID + " = ? AND " + READ + " = 0";
|
||||
String[] selection = new String[]{String.valueOf(threadId)};
|
||||
List<SyncMessageId> result = new LinkedList<>();
|
||||
Cursor cursor = null;
|
||||
public List<MarkedMessageInfo> setMessagesRead(long threadId) {
|
||||
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
||||
String where = THREAD_ID + " = ? AND " + READ + " = 0";
|
||||
String[] selection = new String[]{String.valueOf(threadId)};
|
||||
List<MarkedMessageInfo> result = new LinkedList<>();
|
||||
Cursor cursor = null;
|
||||
|
||||
database.beginTransaction();
|
||||
|
||||
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()) {
|
||||
if (Types.isSecureType(cursor.getLong(2))) {
|
||||
result.add(new SyncMessageId(cursor.getString(0), cursor.getLong(1)));
|
||||
if (Types.isSecureType(cursor.getLong(3))) {
|
||||
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) {
|
||||
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
||||
String where = THREAD_ID + " = ? AND " + READ + " = 0";
|
||||
String[] selection = new String[]{String.valueOf(threadId)};
|
||||
List<SyncMessageId> results = new LinkedList<>();
|
||||
Cursor cursor = null;
|
||||
public List<MarkedMessageInfo> setMessagesRead(long threadId) {
|
||||
SQLiteDatabase database = databaseHelper.getWritableDatabase();
|
||||
String where = THREAD_ID + " = ? AND " + READ + " = 0";
|
||||
String[] selection = new String[]{String.valueOf(threadId)};
|
||||
List<MarkedMessageInfo> results = new LinkedList<>();
|
||||
Cursor cursor = null;
|
||||
|
||||
database.beginTransaction();
|
||||
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()) {
|
||||
if (Types.isSecureType(cursor.getLong(2))) {
|
||||
results.add(new SyncMessageId(cursor.getString(0), cursor.getLong(1)));
|
||||
if (Types.isSecureType(cursor.getLong(3))) {
|
||||
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.crypto.MasterCipher;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||
import org.thoughtcrime.securesms.database.model.DisplayRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
||||
@@ -261,19 +262,19 @@ public class ThreadDatabase extends Database {
|
||||
notifyConversationListListeners();
|
||||
}
|
||||
|
||||
public List<SyncMessageId> setRead(long threadId) {
|
||||
public List<MarkedMessageInfo> setRead(long threadId) {
|
||||
ContentValues contentValues = new ContentValues(1);
|
||||
contentValues.put(READ, 1);
|
||||
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] {threadId+""});
|
||||
|
||||
final List<SyncMessageId> smsRecords = DatabaseFactory.getSmsDatabase(context).setMessagesRead(threadId);
|
||||
final List<SyncMessageId> mmsRecords = DatabaseFactory.getMmsDatabase(context).setMessagesRead(threadId);
|
||||
final List<MarkedMessageInfo> smsRecords = DatabaseFactory.getSmsDatabase(context).setMessagesRead(threadId);
|
||||
final List<MarkedMessageInfo> mmsRecords = DatabaseFactory.getMmsDatabase(context).setMessagesRead(threadId);
|
||||
|
||||
notifyConversationListListeners();
|
||||
|
||||
return new LinkedList<SyncMessageId>() {{
|
||||
return new LinkedList<MarkedMessageInfo>() {{
|
||||
addAll(smsRecords);
|
||||
addAll(mmsRecords);
|
||||
}};
|
||||
|
||||
Reference in New Issue
Block a user