Copy signature to clipboard

This commit is contained in:
M66B 2020-05-22 07:54:56 +02:00
parent 79603c5cfe
commit 815d57a193
1 changed files with 11 additions and 8 deletions

View File

@ -573,17 +573,20 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem(); EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem();
if (identity == null && TextUtils.isEmpty(identity.signature)) if (identity == null || TextUtils.isEmpty(identity.signature))
return; return;
Spanned sig = HtmlHelper.fromHtml(identity.signature, new Html.ImageGetter() { ClipboardManager clipboard =
@Override (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
public Drawable getDrawable(String source) { if (clipboard != null) {
return ImageHelper.decodeImage(getContext(), working, source, true, zoom, etBody); ClipData clip = ClipData.newHtmlText(
} getContext().getString(R.string.title_edit_signature_text),
}, null); 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();
}
} }
}); });