Quote in right direction

This commit is contained in:
M66B 2021-07-07 20:07:11 +02:00
parent e0216a142d
commit 1de051615b
4 changed files with 20 additions and 4 deletions

View File

@ -649,7 +649,7 @@ public class EntityRule {
Element e = answering.body();
if (quote) {
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);
} else
e.tagName("p");

View File

@ -4362,7 +4362,7 @@ public class FragmentCompose extends FragmentBase {
if (quote) {
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);
} else
e.tagName("p");

View File

@ -144,7 +144,8 @@ public class HtmlEx {
for (Object quote : quotes) {
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
out.append("<blockquote>");
}

View File

@ -126,7 +126,6 @@ public class HtmlHelper {
static final float FONT_SMALL = 0.8f;
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_PT = 12; // points
@ -2013,6 +2012,22 @@ public class HtmlHelper {
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) {
return "true".equals(e.attr("x-border"));
}