mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Long-press timestamps in message details to copy.
This commit is contained in:
parent
12d9d7741b
commit
bd38b96095
@ -17,6 +17,8 @@
|
|||||||
package org.thoughtcrime.securesms;
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
@ -203,6 +205,9 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateTime(MessageRecord messageRecord) {
|
private void updateTime(MessageRecord messageRecord) {
|
||||||
|
sentDate.setOnLongClickListener(null);
|
||||||
|
receivedDate.setOnLongClickListener(null);
|
||||||
|
|
||||||
if (messageRecord.isPending() || messageRecord.isFailed()) {
|
if (messageRecord.isPending() || messageRecord.isFailed()) {
|
||||||
sentDate.setText("-");
|
sentDate.setText("-");
|
||||||
receivedContainer.setVisibility(View.GONE);
|
receivedContainer.setVisibility(View.GONE);
|
||||||
@ -210,9 +215,17 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
|
|||||||
Locale dateLocale = dynamicLanguage.getCurrentLocale();
|
Locale dateLocale = dynamicLanguage.getCurrentLocale();
|
||||||
SimpleDateFormat dateFormatter = DateUtils.getDetailedDateFormatter(this, dateLocale);
|
SimpleDateFormat dateFormatter = DateUtils.getDetailedDateFormatter(this, dateLocale);
|
||||||
sentDate.setText(dateFormatter.format(new Date(messageRecord.getDateSent())));
|
sentDate.setText(dateFormatter.format(new Date(messageRecord.getDateSent())));
|
||||||
|
sentDate.setOnLongClickListener(v -> {
|
||||||
|
copyToClipboard(String.valueOf(messageRecord.getDateSent()));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
if (messageRecord.getDateReceived() != messageRecord.getDateSent() && !messageRecord.isOutgoing()) {
|
if (messageRecord.getDateReceived() != messageRecord.getDateSent() && !messageRecord.isOutgoing()) {
|
||||||
receivedDate.setText(dateFormatter.format(new Date(messageRecord.getDateReceived())));
|
receivedDate.setText(dateFormatter.format(new Date(messageRecord.getDateReceived())));
|
||||||
|
receivedDate.setOnLongClickListener(v -> {
|
||||||
|
copyToClipboard(String.valueOf(messageRecord.getDateReceived()));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
receivedContainer.setVisibility(View.VISIBLE);
|
receivedContainer.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
receivedContainer.setVisibility(View.GONE);
|
receivedContainer.setVisibility(View.GONE);
|
||||||
@ -285,6 +298,9 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void copyToClipboard(@NonNull String text) {
|
||||||
|
((ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("text", text));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
|
Loading…
Reference in New Issue
Block a user