Switched to QuoteSpan

There is special processing for QuoteSpans in Android that doesn't work on extended QuoteSpans
This commit is contained in:
M66B
2020-05-03 14:11:38 +02:00
parent f03717a25c
commit c1eacc2c80
5 changed files with 66 additions and 117 deletions

View File

@@ -77,20 +77,27 @@ public class EditTextCompose extends FixedEditText {
return false;
html = "<div>" + HtmlHelper.formatPre(text.toString()) + "</div>";
}
Document document = HtmlHelper.sanitizeCompose(context, html, false);
Spanned paste = HtmlHelper.fromDocument(context, document);
Spanned paste = HtmlHelper.fromHtml(document.html());
int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
int dp3 = Helper.dp2pixels(context, 3);
int dp6 = Helper.dp2pixels(context, 6);
SpannableStringBuilder ssb = new SpannableStringBuilder(paste);
QuoteSpan[] spans = ssb.getSpans(0, ssb.length(), QuoteSpan.class);
for (QuoteSpan span : spans) {
ssb.setSpan(
new StyledQuoteSpan(context, colorPrimary),
ssb.getSpanStart(span),
ssb.getSpanEnd(span),
for (QuoteSpan quoteSpan : spans) {
QuoteSpan q;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
q = new QuoteSpan(colorPrimary);
else
q = new QuoteSpan(colorPrimary, dp3, dp6);
ssb.setSpan(q,
ssb.getSpanStart(quoteSpan),
ssb.getSpanEnd(quoteSpan),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.removeSpan(span);
ssb.removeSpan(quoteSpan);
}
int start = getSelectionStart();