mirror of https://github.com/M66B/FairEmail.git
Added copy headers
This commit is contained in:
parent
fe12c64f89
commit
aa318743f1
|
@ -430,6 +430,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private TextView tvKeywordsEx;
|
||||
|
||||
private TextView tvHeaders;
|
||||
private ImageButton ibCopyHeaders;
|
||||
private ImageButton ibCloseHeaders;
|
||||
private ContentLoadingProgressBar pbHeaders;
|
||||
private TextView tvNoInternetHeaders;
|
||||
|
@ -637,6 +638,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvKeywordsEx = vsBody.findViewById(R.id.tvKeywordsEx);
|
||||
|
||||
tvHeaders = vsBody.findViewById(R.id.tvHeaders);
|
||||
ibCopyHeaders = vsBody.findViewById(R.id.ibCopyHeaders);
|
||||
ibCloseHeaders = vsBody.findViewById(R.id.ibCloseHeaders);
|
||||
pbHeaders = vsBody.findViewById(R.id.pbHeaders);
|
||||
tvNoInternetHeaders = vsBody.findViewById(R.id.tvNoInternetHeaders);
|
||||
|
@ -766,6 +768,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibPinContact.setOnClickListener(this);
|
||||
ibAddContact.setOnClickListener(this);
|
||||
|
||||
ibCopyHeaders.setOnClickListener(this);
|
||||
ibCloseHeaders.setOnClickListener(this);
|
||||
|
||||
ibSaveAttachments.setOnClickListener(this);
|
||||
|
@ -880,6 +883,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ibPinContact.setOnClickListener(null);
|
||||
ibAddContact.setOnClickListener(null);
|
||||
|
||||
ibCopyHeaders.setOnClickListener(null);
|
||||
ibCloseHeaders.setOnClickListener(null);
|
||||
|
||||
ibSaveAttachments.setOnClickListener(null);
|
||||
|
@ -1335,6 +1339,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvFlags.setVisibility(View.GONE);
|
||||
tvKeywordsEx.setVisibility(View.GONE);
|
||||
|
||||
ibCopyHeaders.setVisibility(View.GONE);
|
||||
|
||||
pbHeaders.setVisibility(View.GONE);
|
||||
tvNoInternetHeaders.setVisibility(View.GONE);
|
||||
|
||||
|
@ -1968,10 +1974,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvNoInternetHeaders.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (show_headers && message.headers != null)
|
||||
if (show_headers && message.headers != null) {
|
||||
tvHeaders.setText(HtmlHelper.highlightHeaders(context, message.headers));
|
||||
else
|
||||
ibCopyHeaders.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
tvHeaders.setText(null);
|
||||
ibCopyHeaders.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (scroll)
|
||||
ApplicationEx.getMainHandler().post(new Runnable() {
|
||||
|
@ -3051,6 +3060,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
int id = view.getId();
|
||||
if (id == R.id.ibExpanderAddress) {
|
||||
onToggleAddresses(message);
|
||||
} else if (id == R.id.ibCopyHeaders) {
|
||||
onCopyHeaders(message);
|
||||
} else if (id == R.id.ibCloseHeaders) {
|
||||
onMenuShowHeaders(message);
|
||||
} else if (id == R.id.ibSaveAttachments) {
|
||||
|
@ -4924,6 +4935,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ask.show(parentFragment.getParentFragmentManager(), "message:print");
|
||||
}
|
||||
|
||||
private void onCopyHeaders(TupleMessageEx message) {
|
||||
ClipboardManager clipboard =
|
||||
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
if (clipboard == null)
|
||||
return;
|
||||
|
||||
ClipData clip = ClipData.newPlainText(context.getString(R.string.title_show_headers), message.headers);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
ToastEx.makeText(context, R.string.title_clipboard_copied, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void onMenuShowHeaders(TupleMessageEx message) {
|
||||
boolean show_headers = !properties.getValue("headers", message.id);
|
||||
properties.setValue("headers", message.id, show_headers);
|
||||
|
|
|
@ -30,6 +30,16 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorHeaders" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibCopyHeaders"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:padding="6dp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ibCloseHeaders"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvHeaders"
|
||||
app:srcCompat="@drawable/twotone_file_copy_24" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibCloseHeaders"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -67,4 +77,4 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="vSeparatorHeaders,tvHeaders,ibCloseHeaders" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
Loading…
Reference in New Issue