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
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();
}
}
});