Added copy notes to clipboard

This commit is contained in:
M66B 2021-03-06 08:04:00 +01:00
parent f8541f9d7e
commit 815a6c4927
1 changed files with 15 additions and 0 deletions

View File

@ -782,6 +782,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibSeen.setOnClickListener(this);
ibAnswer.setOnClickListener(this);
ibNotes.setOnClickListener(this);
ibNotes.setOnLongClickListener(this);
ibLabels.setOnClickListener(this);
ibKeywords.setOnClickListener(this);
ibCopy.setOnClickListener(this);
@ -893,6 +894,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibSeen.setOnClickListener(null);
ibAnswer.setOnClickListener(null);
ibNotes.setOnClickListener(null);
ibNotes.setOnLongClickListener(null);
ibLabels.setOnClickListener(null);
ibKeywords.setOnClickListener(null);
ibCopy.setOnClickListener(null);
@ -3212,6 +3214,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (id == R.id.ibFlagged) {
onMenuColoredStar(message);
return true;
} else if (id == R.id.ibNotes) {
onActionCopyNote(message);
return true;
} else if (id == R.id.ibFull) {
onActionOpenFull(message);
return true;
@ -3703,6 +3708,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.putExtra("id", message.id));
}
private void onActionCopyNote(TupleMessageEx message) {
ClipboardManager clipboard =
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null && !TextUtils.isEmpty(message.notes)) {
ClipData clip = ClipData.newPlainText(context.getString(R.string.app_name), message.notes);
clipboard.setPrimaryClip(clip);
ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
}
}
private void onShow(final TupleMessageEx message, boolean full) {
if (full && tvReformatted.getVisibility() == View.VISIBLE) {
prefs.edit().putBoolean("reformatted_hint", false).apply();