From a2d4bec70c791b60ff56735be77e05952ee715ba Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 2 Jun 2021 07:54:14 +0200 Subject: [PATCH] Refactoring --- .../java/eu/faircode/email/FragmentCompose.java | 12 +----------- .../main/java/eu/faircode/email/HtmlHelper.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 1a9b68c30c..6d01d90188 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -4262,17 +4262,7 @@ public class FragmentCompose extends FragmentBase { // Limit number of nested block quotes boolean quote_limit = prefs.getBoolean("quote_limit", true); 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("…"); - } + HtmlHelper.quoteLimit(d, MAX_QUOTE_LEVEL); } } else { // Selected text diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 1dd691b2ca..866ae60e70 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -1989,6 +1989,20 @@ public class HtmlHelper { } } + static void quoteLimit(Document d, int maxLevel) { + 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 >= maxLevel) + bq.html("…"); + } + } + static boolean truncate(Document d, int max) { final int[] length = new int[1];