Quote in right direction

pull/199/head
M66B 4 years ago
parent e0216a142d
commit 1de051615b

@ -649,7 +649,7 @@ public class EntityRule {
Element e = answering.body(); Element e = answering.body();
if (quote) { if (quote) {
String style = e.attr("style"); String style = e.attr("style");
style = HtmlHelper.mergeStyles(style, HtmlHelper.QUOTE_STYLE); style = HtmlHelper.mergeStyles(style, HtmlHelper.getQuoteStyle(e));
e.tagName("blockquote").attr("style", style); e.tagName("blockquote").attr("style", style);
} else } else
e.tagName("p"); e.tagName("p");

@ -4362,7 +4362,7 @@ public class FragmentCompose extends FragmentBase {
if (quote) { if (quote) {
String style = e.attr("style"); String style = e.attr("style");
style = HtmlHelper.mergeStyles(style, HtmlHelper.QUOTE_STYLE); style = HtmlHelper.mergeStyles(style, HtmlHelper.getQuoteStyle(e));
e.tagName("blockquote").attr("style", style); e.tagName("blockquote").attr("style", style);
} else } else
e.tagName("p"); e.tagName("p");

@ -144,7 +144,8 @@ public class HtmlEx {
for (Object quote : quotes) { for (Object quote : quotes) {
if (quote instanceof QuoteSpan) if (quote instanceof QuoteSpan)
out.append("<blockquote style=\"" + eu.faircode.email.HtmlHelper.QUOTE_STYLE +"\">"); out.append("<blockquote style=\"" +
eu.faircode.email.HtmlHelper.getQuoteStyle(text, next, end) + "\">");
else else
out.append("<blockquote>"); out.append("<blockquote>");
} }

@ -126,7 +126,6 @@ public class HtmlHelper {
static final float FONT_SMALL = 0.8f; static final float FONT_SMALL = 0.8f;
static final float FONT_LARGE = 1.25f; static final float FONT_LARGE = 1.25f;
static final String QUOTE_STYLE = "border-left:3px solid #ccc; padding-left:3px;";
private static final int DEFAULT_FONT_SIZE = 16; // pixels private static final int DEFAULT_FONT_SIZE = 16; // pixels
private static final int DEFAULT_FONT_SIZE_PT = 12; // points private static final int DEFAULT_FONT_SIZE_PT = 12; // points
@ -2013,6 +2012,22 @@ public class HtmlHelper {
return d.text(); return d.text();
} }
static String getQuoteStyle(Element e) {
CharSequence text = e.text();
return getQuoteStyle(text, 0, text.length());
}
static String getQuoteStyle(CharSequence quoted, int start, int end) {
try {
if (TextDirectionHeuristics.FIRSTSTRONG_LTR.isRtl(quoted, start, end))
return "border-right:3px solid #ccc; padding-left:3px;";
} catch (Throwable ex) {
Log.e(ex);
}
return "border-left:3px solid #ccc; padding-left:3px;";
}
static boolean hasBorder(Element e) { static boolean hasBorder(Element e) {
return "true".equals(e.attr("x-border")); return "true".equals(e.attr("x-border"));
} }

Loading…
Cancel
Save