From 7267e33a0f77cf408ad1d2059664c32458e7e107 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 13 Sep 2020 08:34:48 +0200 Subject: [PATCH] Added text separator option --- .../java/eu/faircode/email/FragmentOptions.java | 3 ++- .../eu/faircode/email/FragmentOptionsDisplay.java | 13 ++++++++++++- .../main/java/eu/faircode/email/HtmlHelper.java | 8 ++++---- .../main/res/layout/fragment_options_display.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index a4e19a7558..6236cb9c16 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -85,7 +85,8 @@ public class FragmentOptions extends FragmentBase { "subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize", "keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines", "message_zoom", "overview_mode", "addresses", "attachments_alt", "thumbnails", - "contrast", "monospaced", "text_color", "text_size", "text_font", "text_align", + "contrast", "monospaced", + "text_color", "text_size", "text_font", "text_align", "text_separators", "inline_images", "collapse_quotes", "seekbar", "actionbar", "actionbar_color", "navbar_colorize", "autoscroll", "swipenav", "swipe_close", "swipe_move", "autoexpand", "autoclose", "onclose", "language_detection", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index 146e6e54be..577dfaa98a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -117,6 +117,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swTextSize; private SwitchCompat swTextFont; private SwitchCompat swTextAlign; + private SwitchCompat swTextSeparators; private SwitchCompat swCollapseQuotes; private SwitchCompat swImagesInline; private SwitchCompat swAttachmentsAlt; @@ -135,7 +136,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer "keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines", "addresses", - "message_zoom", "overview_mode", "contrast", "monospaced", "text_color", "text_size", "text_font", "text_align", + "message_zoom", "overview_mode", "contrast", "monospaced", + "text_color", "text_size", "text_font", "text_align", "text_separators", "inline_images", "collapse_quotes", "attachments_alt", "thumbnails", "parse_classes", "authentication" }; @@ -207,6 +209,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swTextSize = view.findViewById(R.id.swTextSize); swTextFont = view.findViewById(R.id.swTextFont); swTextAlign = view.findViewById(R.id.swTextAlign); + swTextSeparators = view.findViewById(R.id.swTextSeparators); swCollapseQuotes = view.findViewById(R.id.swCollapseQuotes); swImagesInline = view.findViewById(R.id.swImagesInline); swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt); @@ -693,6 +696,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); + swTextSeparators.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("text_separators", checked).apply(); + } + }); + swCollapseQuotes.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -889,6 +899,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swTextSize.setChecked(prefs.getBoolean("text_size", true)); swTextFont.setChecked(prefs.getBoolean("text_font", true)); swTextAlign.setChecked(prefs.getBoolean("text_align", true)); + swTextSeparators.setChecked(prefs.getBoolean("text_separators", true)); swCollapseQuotes.setChecked(prefs.getBoolean("collapse_quotes", false)); swImagesInline.setChecked(prefs.getBoolean("inline_images", false)); swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false)); diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 28628c5fb4..ef24f6ebe0 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -329,7 +329,7 @@ public class HtmlHelper { boolean disable_tracking = prefs.getBoolean("disable_tracking", true); boolean parse_classes = prefs.getBoolean("parse_classes", false); boolean inline_images = prefs.getBoolean("inline_images", false); - boolean experiments = prefs.getBoolean("experiments", false); + boolean text_separators = prefs.getBoolean("text_separators", true); int textColorPrimary = Helper.resolveColor(context, android.R.attr.textColorPrimary); @@ -795,7 +795,7 @@ public class HtmlHelper { if (hasVisibleContent(row.childNodes())) { Element next = row.nextElementSibling(); if (next != null && "tr".equals(next.tagName())) - if (experiments) + if (text_separators) row.appendElement("hr") .attr("x-dashed", "true"); else @@ -1816,7 +1816,7 @@ public class HtmlHelper { @Nullable Html.ImageGetter imageGetter, @Nullable Html.TagHandler tagHandler) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean debug = prefs.getBoolean("debug", false); - boolean experiments = prefs.getBoolean("experiments", false); + boolean text_separators = prefs.getBoolean("text_separators", true); final int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary); final int colorAccent = Helper.resolveColor(context, R.attr.colorAccent); @@ -2107,7 +2107,7 @@ public class HtmlHelper { newline(ssb.length()); break; case "hr": - if (experiments) { + if (text_separators) { int lhr = 0; for (LineSpan ls : ssb.getSpans(0, ssb.length(), LineSpan.class)) { int end = ssb.getSpanEnd(ls); diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index 1ce5e6b59e..761e548bef 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -950,6 +950,18 @@ app:layout_constraintTop_toBottomOf="@id/swTextFont" app:switchPadding="12dp" /> + + Use text sizes Use fonts Use text alignment + Use separator lines Collapse quoted text Automatically show inline images Show relative conversation position with a dot