From 97d87289863745c3517e8bf1d91e9e96cae30fc1 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 14 Nov 2020 18:33:30 +0100 Subject: [PATCH] Keep signatures in forwarded messages --- .../eu/faircode/email/FragmentCompose.java | 91 ++++++++++--------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index ff751bf42b..894c8b302b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -3784,59 +3784,60 @@ public class FragmentCompose extends FragmentBase { for (Element e : d.select("[x-plain=true]")) e.removeAttr("x-plain"); - // Remove signature separators - boolean remove_signatures = prefs.getBoolean("remove_signatures", false); - if (remove_signatures) - d.body().filter(new NodeFilter() { - private boolean remove = false; + if ("reply".equals(action) || "reply_all".equals(action)) { + // Remove signature separators + boolean remove_signatures = prefs.getBoolean("remove_signatures", false); + if (remove_signatures) + d.body().filter(new NodeFilter() { + private boolean remove = false; - @Override - public FilterResult head(Node node, int depth) { - if (node instanceof TextNode) { - TextNode tnode = (TextNode) node; - String text = tnode.getWholeText() - .replaceAll("[\r\n]+$", "") - .replaceAll("^[\r\n]+", ""); - if ("-- ".equals(text)) { - if (tnode.getWholeText().endsWith("\n")) - remove = true; - else { - Node next = node.nextSibling(); - if (next == null) { - Node parent = node.parent(); - if (parent != null) - next = parent.nextSibling(); - } - if (next != null && "br".equals(next.nodeName())) + @Override + public FilterResult head(Node node, int depth) { + if (node instanceof TextNode) { + TextNode tnode = (TextNode) node; + String text = tnode.getWholeText() + .replaceAll("[\r\n]+$", "") + .replaceAll("^[\r\n]+", ""); + if ("-- ".equals(text)) { + if (tnode.getWholeText().endsWith("\n")) remove = true; + else { + Node next = node.nextSibling(); + if (next == null) { + Node parent = node.parent(); + if (parent != null) + next = parent.nextSibling(); + } + if (next != null && "br".equals(next.nodeName())) + remove = true; + } } } + + return (remove ? FilterResult.REMOVE : FilterResult.CONTINUE); } - return (remove ? FilterResult.REMOVE : FilterResult.CONTINUE); - } + @Override + public FilterResult tail(Node node, int depth) { + return FilterResult.CONTINUE; + } + }); - @Override - public FilterResult tail(Node node, int depth) { - return FilterResult.CONTINUE; + // Limit number of nested block quotes + boolean quote_limit = prefs.getBoolean("quote_limit", false); + if (quote_limit) + for (Element bq : d.select("blockquote")) { + int level = 1; + Element parent = bq.parent(); + while (parent != null) { + if ("blockquote".equals(parent.tagName())) + level++; + parent = parent.parent(); + } + if (level >= MAX_QUOTE_LEVEL) + bq.html("…"); } - }); - - // Limit number of nested block quotes - boolean quote_limit = prefs.getBoolean("quote_limit", false); - if (quote_limit && - ("reply".equals(action) || "reply_all".equals(action))) - for (Element bq : d.select("blockquote")) { - int level = 1; - Element parent = bq.parent(); - while (parent != null) { - if ("blockquote".equals(parent.tagName())) - level++; - parent = parent.parent(); - } - if (level >= MAX_QUOTE_LEVEL) - bq.html("…"); - } + } } else { // Selected text d = Document.createShell("");