diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index f9cf9cd4f8..0f52df6e6b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -277,6 +277,8 @@ public class FragmentCompose extends FragmentBase { private static final int RECIPIENTS_WARNING = 10; + private static final int MAX_QUOTE_LEVEL = 5; + private static final int REQUEST_CONTACT_TO = 1; private static final int REQUEST_CONTACT_CC = 2; private static final int REQUEST_CONTACT_BCC = 3; @@ -3825,6 +3827,21 @@ public class FragmentCompose extends FragmentBase { Element e = d.body(); + // Limit number of nested block quotes + boolean quote_limit = prefs.getBoolean("quote_limit", true); + if (quote_limit) + for (Element bq : e.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("…"); + } + // Apply styles List sheets = HtmlHelper.parseStyles(d.head().select("style")); for (Element element : e.select("*")) { diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java index 89f0d11587..ccef1b0738 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java @@ -55,6 +55,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private SwitchCompat swSeparateReply; private SwitchCompat swExtendedReply; private SwitchCompat swQuoteReply; + private SwitchCompat swQuoteLimit; private SwitchCompat swResizeReply; private Spinner spSignatureLocation; private SwitchCompat swSignatureReply; @@ -72,7 +73,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private final static String[] RESET_OPTIONS = new String[]{ "keyboard", "suggest_sent", "suggested_received", "suggest_frequently", "send_reminders", "send_delayed", - "compose_font", "prefix_once", "separate_reply", "extended_reply", "quote_reply", "resize_reply", + "compose_font", "prefix_once", "separate_reply", "extended_reply", "quote_reply", "quote_limit", "resize_reply", "signature_location", "signature_reply", "signature_forward", "discard_delete", "plain_only", "format_flowed", "usenet_signature", "remove_signatures", @@ -102,6 +103,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc swSeparateReply = view.findViewById(R.id.swSeparateReply); swExtendedReply = view.findViewById(R.id.swExtendedReply); swQuoteReply = view.findViewById(R.id.swQuoteReply); + swQuoteLimit = view.findViewById(R.id.swQuoteLimit); swResizeReply = view.findViewById(R.id.swResizeReply); spSignatureLocation = view.findViewById(R.id.spSignatureLocation); swSignatureReply = view.findViewById(R.id.swSignatureReply); @@ -230,6 +232,14 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("quote_reply", checked).apply(); + swQuoteLimit.setEnabled(checked); + } + }); + + swQuoteLimit.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("quote_limit", checked).apply(); } }); @@ -401,6 +411,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc swSeparateReply.setChecked(prefs.getBoolean("separate_reply", false)); swExtendedReply.setChecked(prefs.getBoolean("extended_reply", false)); swQuoteReply.setChecked(prefs.getBoolean("quote_reply", true)); + swQuoteLimit.setChecked(prefs.getBoolean("quote_limit", true)); + swQuoteLimit.setEnabled(swQuoteReply.isChecked()); swResizeReply.setChecked(prefs.getBoolean("resize_reply", true)); int signature_location = prefs.getInt("signature_location", 1); diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index f11d80f30b..b24b6a9071 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -570,9 +570,6 @@ public class MessageHelper { // Build html body Document document = JsoupEx.parse(message.getFile(context)); - Element ref = null; - if (BuildConfig.DEBUG) - ref = document.select("div[fairemail=reference]").first(); // When sending message if (identity != null && send) { @@ -656,14 +653,6 @@ public class MessageHelper { String htmlContent = document.html(); String htmlContentType = "text/html; charset=" + Charset.defaultCharset().name(); - // Limit alternative plain content - if (ref != null && - (message.plain_only == null || !message.plain_only)) { - Element first = ref.select("blockquote").first(); - if (first != null) - first.children().select("blockquote").remove(); - } - String plainContent = HtmlHelper.getText(context, document.html()); String plainContentType = "text/plain; charset=" + Charset.defaultCharset().name(); diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index 77d5a2e5cd..c1e2b26b47 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -237,6 +237,18 @@ app:layout_constraintTop_toBottomOf="@id/swExtendedReply" app:switchPadding="12dp" /> + + Insert a horizontal line before a reply/forward header Use extended reply/forward header Quote replied text + Limit the number of nested quotes Resize images in replied text Signature position Use signature when replying