diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index d47d7158ee..d66ff12700 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -74,7 +74,6 @@ import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.RecipientModifiedListener; import org.thoughtcrime.securesms.service.ExpiringMessageManager; import org.thoughtcrime.securesms.util.DateUtils; -import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicTheme; import org.thoughtcrime.securesms.util.LongClickCopySpan; import org.thoughtcrime.securesms.util.LongClickMovementMethod; @@ -606,6 +605,7 @@ public class ConversationItem extends LinearLayout intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(slide.getUri(), slide.getContentType()); intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, conversationRecipient.getAddress()); + intent.putExtra(MediaPreviewActivity.OUTGOING_EXTRA, messageRecord.isOutgoing()); intent.putExtra(MediaPreviewActivity.DATE_EXTRA, messageRecord.getTimestamp()); intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, slide.asAttachment().getSize()); diff --git a/src/org/thoughtcrime/securesms/MediaGalleryAdapter.java b/src/org/thoughtcrime/securesms/MediaGalleryAdapter.java index 9352b267b0..cff52c73e7 100644 --- a/src/org/thoughtcrime/securesms/MediaGalleryAdapter.java +++ b/src/org/thoughtcrime/securesms/MediaGalleryAdapter.java @@ -129,6 +129,7 @@ public class MediaGalleryAdapter extends StickyHeaderGridAdapter { intent.putExtra(MediaPreviewActivity.DATE_EXTRA, mediaRecord.getDate()); intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, mediaRecord.getAttachment().getSize()); intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, address); + intent.putExtra(MediaPreviewActivity.OUTGOING_EXTRA, mediaRecord.isOutgoing()); if (mediaRecord.getAddress() != null) { intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, mediaRecord.getAddress()); diff --git a/src/org/thoughtcrime/securesms/MediaPreviewActivity.java b/src/org/thoughtcrime/securesms/MediaPreviewActivity.java index 244f422dd7..f2205a9c92 100644 --- a/src/org/thoughtcrime/securesms/MediaPreviewActivity.java +++ b/src/org/thoughtcrime/securesms/MediaPreviewActivity.java @@ -53,9 +53,10 @@ import java.io.IOException; public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity implements RecipientModifiedListener { private final static String TAG = MediaPreviewActivity.class.getSimpleName(); - public static final String ADDRESS_EXTRA = "address"; - public static final String DATE_EXTRA = "date"; - public static final String SIZE_EXTRA = "size"; + public static final String ADDRESS_EXTRA = "address"; + public static final String DATE_EXTRA = "date"; + public static final String SIZE_EXTRA = "size"; + public static final String OUTGOING_EXTRA = "outgoing"; private final DynamicLanguage dynamicLanguage = new DynamicLanguage(); @@ -69,6 +70,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im private Recipient recipient; private long date; private long size; + private boolean outgoing; @Override protected void onCreate(Bundle bundle, @NonNull MasterSecret masterSecret) { @@ -102,13 +104,16 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im private void initializeActionBar() { final CharSequence relativeTimeSpan; + if (date > 0) { relativeTimeSpan = DateUtils.getExtendedRelativeTimeSpanString(this,dynamicLanguage.getCurrentLocale(),date); } else { relativeTimeSpan = getString(R.string.MediaPreviewActivity_draft); } - getSupportActionBar().setTitle(recipient == null ? getString(R.string.MediaPreviewActivity_you) - : recipient.toShortString()); + + if (outgoing) getSupportActionBar().setTitle(getString(R.string.MediaPreviewActivity_you)); + else getSupportActionBar().setTitle(recipient.toShortString()); + getSupportActionBar().setSubtitle(relativeTimeSpan); } @@ -144,10 +149,11 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im private void initializeResources() { Address address = getIntent().getParcelableExtra(ADDRESS_EXTRA); - mediaUri = getIntent().getData(); - mediaType = getIntent().getType(); - date = getIntent().getLongExtra(DATE_EXTRA, -1); - size = getIntent().getLongExtra(SIZE_EXTRA, 0); + mediaUri = getIntent().getData(); + mediaType = getIntent().getType(); + date = getIntent().getLongExtra(DATE_EXTRA, -1); + size = getIntent().getLongExtra(SIZE_EXTRA, 0); + outgoing = getIntent().getBooleanExtra(OUTGOING_EXTRA, false); if (address != null) { recipient = Recipient.from(this, address, true); diff --git a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java index aa08982a66..f7ca9423dc 100644 --- a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java +++ b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java @@ -161,6 +161,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi this.threadPhotoRailView.setListener(mediaRecord -> { Intent intent = new Intent(RecipientPreferenceActivity.this, MediaPreviewActivity.class); intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, address); + intent.putExtra(MediaPreviewActivity.OUTGOING_EXTRA, mediaRecord.isOutgoing()); intent.putExtra(MediaPreviewActivity.DATE_EXTRA, mediaRecord.getDate()); intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, mediaRecord.getAttachment().getSize()); intent.setDataAndType(mediaRecord.getAttachment().getDataUri(), mediaRecord.getContentType()); diff --git a/src/org/thoughtcrime/securesms/database/MediaDatabase.java b/src/org/thoughtcrime/securesms/database/MediaDatabase.java index 2d6a7acb56..267f9494c0 100644 --- a/src/org/thoughtcrime/securesms/database/MediaDatabase.java +++ b/src/org/thoughtcrime/securesms/database/MediaDatabase.java @@ -67,17 +67,20 @@ public class MediaDatabase extends Database { private final DatabaseAttachment attachment; private final Address address; private final long date; + private final boolean outgoing; - private MediaRecord(DatabaseAttachment attachment, @Nullable Address address, long date) { + private MediaRecord(DatabaseAttachment attachment, @Nullable Address address, long date, boolean outgoing) { this.attachment = attachment; this.address = address; this.date = date; + this.outgoing = outgoing; } public static MediaRecord from(@NonNull Context context, @NonNull MasterSecret masterSecret, @NonNull Cursor cursor) { AttachmentDatabase attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context); DatabaseAttachment attachment = attachmentDatabase.getAttachment(masterSecret, cursor); String serializedAddress = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS)); + boolean outgoing = MessagingDatabase.Types.isOutgoingMessageType(cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX))); Address address = null; if (serializedAddress != null) { @@ -92,7 +95,7 @@ public class MediaDatabase extends Database { date = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.DATE_RECEIVED)); } - return new MediaRecord(attachment, address, date); + return new MediaRecord(attachment, address, date, outgoing); } public Attachment getAttachment() { @@ -111,6 +114,10 @@ public class MediaDatabase extends Database { return date; } + public boolean isOutgoing() { + return outgoing; + } + }