From 815d57a193a23b11cd4f90d7d3fdeba83f1b8497 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 22 May 2020 07:54:56 +0200 Subject: [PATCH] Copy signature to clipboard --- .../eu/faircode/email/FragmentCompose.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index cde2e7fa37..beb3b8b30a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -573,17 +573,20 @@ public class FragmentCompose extends FragmentBase { @Override public void onClick(View v) { EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem(); - if (identity == null && TextUtils.isEmpty(identity.signature)) + if (identity == null || TextUtils.isEmpty(identity.signature)) return; - Spanned sig = HtmlHelper.fromHtml(identity.signature, new Html.ImageGetter() { - @Override - public Drawable getDrawable(String source) { - return ImageHelper.decodeImage(getContext(), working, source, true, zoom, etBody); - } - }, null); + ClipboardManager clipboard = + (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); + if (clipboard != null) { + ClipData clip = ClipData.newHtmlText( + getContext().getString(R.string.title_edit_signature_text), + HtmlHelper.getText(getContext(), identity.signature), + identity.signature); + clipboard.setPrimaryClip(clip); - etBody.getText().insert(etBody.getSelectionStart(), sig); + ToastEx.makeText(getContext(), R.string.title_clipboard_copied, Toast.LENGTH_LONG).show(); + } } });