Simplified quote/html

pull/199/head
M66B 4 years ago
parent 7a3ee41f41
commit eb110a581c

@ -29,6 +29,7 @@ import android.text.style.BulletSpan;
import android.text.style.CharacterStyle; import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan; import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan; import android.text.style.ImageSpan;
import android.text.style.LeadingMarginSpan;
import android.text.style.ParagraphStyle; import android.text.style.ParagraphStyle;
import android.text.style.QuoteSpan; import android.text.style.QuoteSpan;
import android.text.style.RelativeSizeSpan; import android.text.style.RelativeSizeSpan;
@ -136,23 +137,25 @@ public class HtmlEx {
int option) { int option) {
int next; int next;
for (int i = start; i < end; i = next) { for (int i = start; i < end; i = next) {
int n1 = text.nextSpanTransition(i, end, QuoteSpan.class); next = text.nextSpanTransition(i, end, LeadingMarginSpan.class);
int n2 = text.nextSpanTransition(i, end, eu.faircode.email.IndentSpan.class); List<Object> spans = new ArrayList<>();
Class type = (n1 < n2 ? QuoteSpan.class : eu.faircode.email.IndentSpan.class); for (Object span : text.getSpans(i, next, LeadingMarginSpan.class))
next = Math.min(n1, n2); if (span instanceof QuoteSpan ||
Object[] quotes = text.getSpans(i, next, type); span instanceof eu.faircode.email.IndentSpan)
spans.add(span);
for (Object quote : quotes) {
if (quote instanceof QuoteSpan) for (Object span : spans) {
out.append("<blockquote style=\"" + if (span instanceof QuoteSpan)
eu.faircode.email.HtmlHelper.getQuoteStyle(text, next, end) + "\">"); out.append("<blockquote style=\"")
else .append(eu.faircode.email.HtmlHelper.getQuoteStyle(text, next, end))
.append("\">");
else if (span instanceof eu.faircode.email.IndentSpan)
out.append("<blockquote>"); out.append("<blockquote>");
} }
withinBlockquote(out, text, i, next, option); withinBlockquote(out, text, i, next, option);
for (Object quote : quotes) { for (Object span : spans) {
out.append("</blockquote>\n"); out.append("</blockquote>\n");
} }
} }

Loading…
Cancel
Save