Insert raw signature image

This commit is contained in:
M66B 2020-02-27 18:17:14 +01:00
parent 423343c8f2
commit ec6c99bd86
1 changed files with 10 additions and 6 deletions

View File

@ -274,12 +274,16 @@ public class ActivitySignature extends ActivityBase {
getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
int start = etText.getSelectionStart();
SpannableStringBuilder ssb = new SpannableStringBuilder(etText.getText());
ssb.insert(start, " ");
ImageSpan is = new ImageSpan(getDrawableByUri(this, uri), uri.toString(), ImageSpan.ALIGN_BASELINE);
ssb.setSpan(is, start, start + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
etText.setText(ssb);
etText.setSelection(start + 1);
if (raw)
etText.getText().insert(start, "<img src=\"" + Html.escapeHtml(uri.toString()) + "\" />");
else {
SpannableStringBuilder ssb = new SpannableStringBuilder(etText.getText());
ssb.insert(start, " ");
ImageSpan is = new ImageSpan(getDrawableByUri(this, uri), uri.toString(), ImageSpan.ALIGN_BASELINE);
ssb.setSpan(is, start, start + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
etText.setText(ssb);
etText.setSelection(start + 1);
}
} catch (Throwable ex) {
Log.unexpectedError(getSupportFragmentManager(), ex);
}