mirror of https://github.com/M66B/FairEmail.git
Apply styles to referenced message
This commit is contained in:
parent
346b4487a5
commit
c53d1d87cb
|
@ -141,6 +141,7 @@ import org.jsoup.select.NodeFilter;
|
||||||
import org.openintents.openpgp.OpenPgpError;
|
import org.openintents.openpgp.OpenPgpError;
|
||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
import org.openintents.openpgp.util.OpenPgpServiceConnection;
|
import org.openintents.openpgp.util.OpenPgpServiceConnection;
|
||||||
|
import org.w3c.dom.css.CSSStyleSheet;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -3567,8 +3568,19 @@ public class FragmentCompose extends FragmentBase {
|
||||||
d.body().appendChild(div);
|
d.body().appendChild(div);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quote referenced message body
|
|
||||||
Element e = d.body();
|
Element e = d.body();
|
||||||
|
|
||||||
|
// Apply styles
|
||||||
|
List<CSSStyleSheet> sheets = HtmlHelper.parseStyles(d.head().select("style"));
|
||||||
|
for (Element element : e.select("*")) {
|
||||||
|
String tag = element.tagName();
|
||||||
|
String clazz = element.attr("class");
|
||||||
|
String style = HtmlHelper.processStyles(tag, clazz, null, sheets);
|
||||||
|
style = HtmlHelper.mergeStyles(style, element.attr("style"));
|
||||||
|
element.attr("style", style);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quote referenced message body
|
||||||
boolean quote_reply = prefs.getBoolean("quote_reply", true);
|
boolean quote_reply = prefs.getBoolean("quote_reply", true);
|
||||||
boolean quote = (quote_reply &&
|
boolean quote = (quote_reply &&
|
||||||
("reply".equals(action) || "reply_all".equals(action) || "list".equals(action)));
|
("reply".equals(action) || "reply_all".equals(action) || "list".equals(action)));
|
||||||
|
|
|
@ -485,11 +485,10 @@ public class HtmlHelper {
|
||||||
|
|
||||||
// Sanitize styles
|
// Sanitize styles
|
||||||
for (Element element : document.select("*")) {
|
for (Element element : document.select("*")) {
|
||||||
String style = null;
|
|
||||||
String clazz = element.attr("class");
|
|
||||||
|
|
||||||
// Class style
|
// Class style
|
||||||
style = processStyles(element.tagName(), clazz, style, sheets);
|
String tag = element.tagName();
|
||||||
|
String clazz = element.attr("class");
|
||||||
|
String style = processStyles(tag, clazz, null, sheets);
|
||||||
|
|
||||||
// Element style
|
// Element style
|
||||||
style = mergeStyles(style, element.attr("style"));
|
style = mergeStyles(style, element.attr("style"));
|
||||||
|
@ -1027,7 +1026,7 @@ public class HtmlHelper {
|
||||||
return sheets;
|
return sheets;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String processStyles(String tag, String clazz, String style, List<CSSStyleSheet> sheets) {
|
static String processStyles(String tag, String clazz, String style, List<CSSStyleSheet> sheets) {
|
||||||
for (CSSStyleSheet sheet : sheets)
|
for (CSSStyleSheet sheet : sheets)
|
||||||
if (isScreenMedia(sheet.getMedia())) {
|
if (isScreenMedia(sheet.getMedia())) {
|
||||||
style = processStyles(null, clazz, style, sheet.getCssRules(), Selector.SAC_ELEMENT_NODE_SELECTOR);
|
style = processStyles(null, clazz, style, sheet.getCssRules(), Selector.SAC_ELEMENT_NODE_SELECTOR);
|
||||||
|
@ -1093,7 +1092,7 @@ public class HtmlHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String mergeStyles(String base, String style) {
|
static String mergeStyles(String base, String style) {
|
||||||
return mergeStyles(base, style, null);
|
return mergeStyles(base, style, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue