mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-04 15:35:19 +00:00
parent
677c7732cf
commit
9a876a3672
@ -74,7 +74,6 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
|||||||
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
|
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
|
||||||
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
||||||
import org.thoughtcrime.securesms.util.DateUtils;
|
import org.thoughtcrime.securesms.util.DateUtils;
|
||||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
|
||||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||||
import org.thoughtcrime.securesms.util.LongClickCopySpan;
|
import org.thoughtcrime.securesms.util.LongClickCopySpan;
|
||||||
import org.thoughtcrime.securesms.util.LongClickMovementMethod;
|
import org.thoughtcrime.securesms.util.LongClickMovementMethod;
|
||||||
@ -606,6 +605,7 @@ public class ConversationItem extends LinearLayout
|
|||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
intent.setDataAndType(slide.getUri(), slide.getContentType());
|
intent.setDataAndType(slide.getUri(), slide.getContentType());
|
||||||
intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, conversationRecipient.getAddress());
|
intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, conversationRecipient.getAddress());
|
||||||
|
intent.putExtra(MediaPreviewActivity.OUTGOING_EXTRA, messageRecord.isOutgoing());
|
||||||
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, messageRecord.getTimestamp());
|
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, messageRecord.getTimestamp());
|
||||||
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, slide.asAttachment().getSize());
|
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, slide.asAttachment().getSize());
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ public class MediaGalleryAdapter extends StickyHeaderGridAdapter {
|
|||||||
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, mediaRecord.getDate());
|
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, mediaRecord.getDate());
|
||||||
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, mediaRecord.getAttachment().getSize());
|
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, mediaRecord.getAttachment().getSize());
|
||||||
intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, address);
|
intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, address);
|
||||||
|
intent.putExtra(MediaPreviewActivity.OUTGOING_EXTRA, mediaRecord.isOutgoing());
|
||||||
|
|
||||||
if (mediaRecord.getAddress() != null) {
|
if (mediaRecord.getAddress() != null) {
|
||||||
intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, mediaRecord.getAddress());
|
intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, mediaRecord.getAddress());
|
||||||
|
@ -56,6 +56,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
public static final String ADDRESS_EXTRA = "address";
|
public static final String ADDRESS_EXTRA = "address";
|
||||||
public static final String DATE_EXTRA = "date";
|
public static final String DATE_EXTRA = "date";
|
||||||
public static final String SIZE_EXTRA = "size";
|
public static final String SIZE_EXTRA = "size";
|
||||||
|
public static final String OUTGOING_EXTRA = "outgoing";
|
||||||
|
|
||||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
private Recipient recipient;
|
private Recipient recipient;
|
||||||
private long date;
|
private long date;
|
||||||
private long size;
|
private long size;
|
||||||
|
private boolean outgoing;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle bundle, @NonNull MasterSecret masterSecret) {
|
protected void onCreate(Bundle bundle, @NonNull MasterSecret masterSecret) {
|
||||||
@ -102,13 +104,16 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
|
|
||||||
private void initializeActionBar() {
|
private void initializeActionBar() {
|
||||||
final CharSequence relativeTimeSpan;
|
final CharSequence relativeTimeSpan;
|
||||||
|
|
||||||
if (date > 0) {
|
if (date > 0) {
|
||||||
relativeTimeSpan = DateUtils.getExtendedRelativeTimeSpanString(this,dynamicLanguage.getCurrentLocale(),date);
|
relativeTimeSpan = DateUtils.getExtendedRelativeTimeSpanString(this,dynamicLanguage.getCurrentLocale(),date);
|
||||||
} else {
|
} else {
|
||||||
relativeTimeSpan = getString(R.string.MediaPreviewActivity_draft);
|
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);
|
getSupportActionBar().setSubtitle(relativeTimeSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,6 +153,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
|
|||||||
mediaType = getIntent().getType();
|
mediaType = getIntent().getType();
|
||||||
date = getIntent().getLongExtra(DATE_EXTRA, -1);
|
date = getIntent().getLongExtra(DATE_EXTRA, -1);
|
||||||
size = getIntent().getLongExtra(SIZE_EXTRA, 0);
|
size = getIntent().getLongExtra(SIZE_EXTRA, 0);
|
||||||
|
outgoing = getIntent().getBooleanExtra(OUTGOING_EXTRA, false);
|
||||||
|
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
recipient = Recipient.from(this, address, true);
|
recipient = Recipient.from(this, address, true);
|
||||||
|
@ -161,6 +161,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
|||||||
this.threadPhotoRailView.setListener(mediaRecord -> {
|
this.threadPhotoRailView.setListener(mediaRecord -> {
|
||||||
Intent intent = new Intent(RecipientPreferenceActivity.this, MediaPreviewActivity.class);
|
Intent intent = new Intent(RecipientPreferenceActivity.this, MediaPreviewActivity.class);
|
||||||
intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, address);
|
intent.putExtra(MediaPreviewActivity.ADDRESS_EXTRA, address);
|
||||||
|
intent.putExtra(MediaPreviewActivity.OUTGOING_EXTRA, mediaRecord.isOutgoing());
|
||||||
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, mediaRecord.getDate());
|
intent.putExtra(MediaPreviewActivity.DATE_EXTRA, mediaRecord.getDate());
|
||||||
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, mediaRecord.getAttachment().getSize());
|
intent.putExtra(MediaPreviewActivity.SIZE_EXTRA, mediaRecord.getAttachment().getSize());
|
||||||
intent.setDataAndType(mediaRecord.getAttachment().getDataUri(), mediaRecord.getContentType());
|
intent.setDataAndType(mediaRecord.getAttachment().getDataUri(), mediaRecord.getContentType());
|
||||||
|
@ -67,17 +67,20 @@ public class MediaDatabase extends Database {
|
|||||||
private final DatabaseAttachment attachment;
|
private final DatabaseAttachment attachment;
|
||||||
private final Address address;
|
private final Address address;
|
||||||
private final long date;
|
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.attachment = attachment;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.date = date;
|
this.date = date;
|
||||||
|
this.outgoing = outgoing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MediaRecord from(@NonNull Context context, @NonNull MasterSecret masterSecret, @NonNull Cursor cursor) {
|
public static MediaRecord from(@NonNull Context context, @NonNull MasterSecret masterSecret, @NonNull Cursor cursor) {
|
||||||
AttachmentDatabase attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context);
|
AttachmentDatabase attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context);
|
||||||
DatabaseAttachment attachment = attachmentDatabase.getAttachment(masterSecret, cursor);
|
DatabaseAttachment attachment = attachmentDatabase.getAttachment(masterSecret, cursor);
|
||||||
String serializedAddress = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS));
|
String serializedAddress = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS));
|
||||||
|
boolean outgoing = MessagingDatabase.Types.isOutgoingMessageType(cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX)));
|
||||||
Address address = null;
|
Address address = null;
|
||||||
|
|
||||||
if (serializedAddress != null) {
|
if (serializedAddress != null) {
|
||||||
@ -92,7 +95,7 @@ public class MediaDatabase extends Database {
|
|||||||
date = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.DATE_RECEIVED));
|
date = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.DATE_RECEIVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MediaRecord(attachment, address, date);
|
return new MediaRecord(attachment, address, date, outgoing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Attachment getAttachment() {
|
public Attachment getAttachment() {
|
||||||
@ -111,6 +114,10 @@ public class MediaDatabase extends Database {
|
|||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOutgoing() {
|
||||||
|
return outgoing;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user