From 156c5c6e09c1de9f585f892af43c27d9cb5a7fd1 Mon Sep 17 00:00:00 2001 From: haffenloher Date: Mon, 15 Feb 2016 02:22:16 +0100 Subject: [PATCH] Use sent time as timestamp for push image records Use received time for non-push messages only. This makes the displayed date for images accessed through "All images" consistent with the date displayed everywhere else. Related: #3535 Closes #5230 // FREEBIE --- .../securesms/database/ImageDatabase.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/database/ImageDatabase.java b/src/org/thoughtcrime/securesms/database/ImageDatabase.java index 2f644f54ee..5e7bb25179 100644 --- a/src/org/thoughtcrime/securesms/database/ImageDatabase.java +++ b/src/org/thoughtcrime/securesms/database/ImageDatabase.java @@ -19,7 +19,9 @@ public class ImageDatabase extends Database { + AttachmentDatabase.TABLE_NAME + "." + AttachmentDatabase.TRANSFER_STATE + ", " + AttachmentDatabase.TABLE_NAME + "." + AttachmentDatabase.SIZE + ", " + AttachmentDatabase.TABLE_NAME + "." + AttachmentDatabase.DATA + ", " - + MmsDatabase.TABLE_NAME + "." + MmsDatabase.NORMALIZED_DATE_RECEIVED + ", " + + MmsDatabase.TABLE_NAME + "." + MmsDatabase.MESSAGE_BOX + ", " + + MmsDatabase.TABLE_NAME + "." + MmsDatabase.DATE_SENT + ", " + + MmsDatabase.TABLE_NAME + "." + MmsDatabase.DATE_RECEIVED + ", " + MmsDatabase.TABLE_NAME + "." + MmsDatabase.ADDRESS + " " + "FROM " + AttachmentDatabase.TABLE_NAME + " LEFT JOIN " + MmsDatabase.TABLE_NAME + " ON " + AttachmentDatabase.TABLE_NAME + "." + AttachmentDatabase.MMS_ID + " = " + MmsDatabase.TABLE_NAME + "." + MmsDatabase.ID + " " @@ -69,12 +71,20 @@ public class ImageDatabase extends Database { AttachmentId attachmentId = new AttachmentId(cursor.getLong(cursor.getColumnIndexOrThrow(AttachmentDatabase.ROW_ID)), cursor.getLong(cursor.getColumnIndexOrThrow(AttachmentDatabase.UNIQUE_ID))); + long date; + + if (MmsDatabase.Types.isPushType(cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX)))) { + date = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.DATE_SENT)); + } else { + date = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.DATE_RECEIVED)); + } + return new ImageRecord(attachmentId, cursor.getLong(cursor.getColumnIndexOrThrow(AttachmentDatabase.MMS_ID)), !cursor.isNull(cursor.getColumnIndexOrThrow(AttachmentDatabase.DATA)), cursor.getString(cursor.getColumnIndexOrThrow(AttachmentDatabase.CONTENT_TYPE)), cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS)), - cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.NORMALIZED_DATE_RECEIVED)), + date, cursor.getInt(cursor.getColumnIndexOrThrow(AttachmentDatabase.TRANSFER_STATE)), cursor.getLong(cursor.getColumnIndexOrThrow(AttachmentDatabase.SIZE))); }