Update last seen state on desktop sync send

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-02-22 15:05:35 -08:00
parent 2395b79bfc
commit 8cd50d1e82
9 changed files with 13 additions and 14 deletions

View File

@ -1443,7 +1443,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override
protected Void doInBackground(Long... params) {
Context context = ConversationActivity.this;
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(params[0]);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(params[0], false);
MessageNotifier.updateNotification(context, masterSecret);
MarkReadReceiver.process(context, messageIds);

View File

@ -476,7 +476,7 @@ public class ConversationListFragment extends Fragment
DatabaseFactory.getThreadDatabase(getActivity()).archiveConversation(threadId);
if (!read) {
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(getActivity()).setRead(threadId);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(getActivity()).setRead(threadId, false);
MessageNotifier.updateNotification(getActivity(), masterSecret);
MarkReadReceiver.process(getActivity(), messageIds);
}

View File

@ -264,10 +264,14 @@ public class ThreadDatabase extends Database {
notifyConversationListListeners();
}
public List<MarkedMessageInfo> setRead(long threadId) {
public List<MarkedMessageInfo> setRead(long threadId, boolean lastSeen) {
ContentValues contentValues = new ContentValues(1);
contentValues.put(READ, 1);
if (lastSeen) {
contentValues.put(LAST_SEEN, System.currentTimeMillis());
}
SQLiteDatabase db = databaseHelper.getWritableDatabase();
db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] {threadId+""});

View File

@ -373,7 +373,7 @@ public class PushDecryptJob extends ContextJob {
}
if (threadId != null) {
DatabaseFactory.getThreadDatabase(getContext()).setRead(threadId);
DatabaseFactory.getThreadDatabase(getContext()).setRead(threadId, true);
MessageNotifier.updateNotification(getContext(), masterSecret.getMasterSecret().orNull());
}

View File

@ -61,8 +61,7 @@ public class AndroidAutoHeardReceiver extends MasterSecretBroadcastReceiver {
for (long threadId : threadIds) {
Log.i(TAG, "Marking meassage as read: " + threadId);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId);
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId, true);
messageIdsCollection.addAll(messageIds);
}

View File

@ -90,8 +90,7 @@ public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver {
replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false);
}
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(replyThreadId);
DatabaseFactory.getThreadDatabase(context).setLastSeen(replyThreadId);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(replyThreadId, true);
MessageNotifier.updateNotification(context, masterSecret);
MarkReadReceiver.process(context, messageIds);

View File

@ -45,10 +45,8 @@ public class MarkReadReceiver extends MasterSecretBroadcastReceiver {
for (long threadId : threadIds) {
Log.w(TAG, "Marking as read: " + threadId);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId, true);
messageIdsCollection.addAll(messageIds);
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
}
process(context, messageIdsCollection);

View File

@ -223,7 +223,7 @@ public class MessageNotifier {
.getRecipientsForThreadId(threadId);
if (isVisible) {
List<MarkedMessageInfo> messageIds = threads.setRead(threadId);
List<MarkedMessageInfo> messageIds = threads.setRead(threadId, false);
MarkReadReceiver.process(context, messageIds);
}

View File

@ -80,8 +80,7 @@ public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver {
threadId = MessageSender.send(context, masterSecret, reply, -1, false);
}
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId);
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId, true);
MessageNotifier.updateNotification(context, masterSecret);
MarkReadReceiver.process(context, messageIds);