diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java
index 3fe3037364..df51b197dd 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptions.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java
@@ -85,7 +85,7 @@ 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",
+ "contrast", "monospaced", "monospaced_pre",
"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",
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java
index f8d60df6c8..0c5d4c0f5a 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java
@@ -119,6 +119,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swContrast;
private SwitchCompat swMonospaced;
+ private SwitchCompat swMonospacedPre;
private SwitchCompat swTextColor;
private SwitchCompat swTextSize;
private SwitchCompat swTextFont;
@@ -142,7 +143,7 @@ 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",
+ "message_zoom", "overview_mode", "contrast", "monospaced", "monospaced_pre",
"text_color", "text_size", "text_font", "text_align", "text_separators",
"inline_images", "collapse_quotes", "attachments_alt", "thumbnails",
"parse_classes", "authentication"
@@ -213,6 +214,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swOverviewMode = view.findViewById(R.id.swOverviewMode);
swContrast = view.findViewById(R.id.swContrast);
swMonospaced = view.findViewById(R.id.swMonospaced);
+ swMonospacedPre = view.findViewById(R.id.swMonospacedPre);
swTextColor = view.findViewById(R.id.swTextColor);
swTextSize = view.findViewById(R.id.swTextSize);
swTextFont = view.findViewById(R.id.swTextFont);
@@ -716,6 +718,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
+ swMonospacedPre.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("monospaced_pre", checked).apply();
+ }
+ });
+
swTextColor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -952,6 +961,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swContrast.setChecked(prefs.getBoolean("contrast", false));
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
+ swMonospacedPre.setChecked(prefs.getBoolean("monospaced_pre", false));
swTextColor.setChecked(prefs.getBoolean("text_color", true));
swTextSize.setChecked(prefs.getBoolean("text_size", true));
swTextFont.setChecked(prefs.getBoolean("text_font", true));
diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java
index 1bd1dea900..1ab5efdab1 100644
--- a/app/src/main/java/eu/faircode/email/HtmlHelper.java
+++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java
@@ -1897,6 +1897,7 @@ public class HtmlHelper {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean debug = prefs.getBoolean("debug", false);
boolean text_separators = prefs.getBoolean("text_separators", false);
+ boolean monospaced_pre = prefs.getBoolean("monospaced_pre", false);
final int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
final int colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
@@ -2043,7 +2044,12 @@ public class HtmlHelper {
ssb.append("[" + element.tagName() + ":" + element.attr("style") + "]");
} else if (node instanceof TextNode) {
tnode = (TextNode) node;
- ssb.append(tnode.getWholeText());
+ String text = tnode.getWholeText();
+ ssb.append(text);
+ if (monospaced_pre &&
+ node.parent() instanceof Element &&
+ "true".equals(((Element) node.parent()).attr("x-plain")))
+ setSpan(ssb, new TypefaceSpan("monospace"), ssb.length() - text.length(), ssb.length());
}
}
diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml
index 1cc389d947..9f2145bad6 100644
--- a/app/src/main/res/layout/fragment_options_display.xml
+++ b/app/src/main/res/layout/fragment_options_display.xml
@@ -925,6 +925,17 @@
app:layout_constraintTop_toBottomOf="@id/swContrast"
app:switchPadding="12dp" />
+
+
Zoom original messages to fit the screen
Use high contrast for message text
Use monospaced font for message text by default
+ Use monospaced font for preformatted text
Use text colors
Use text sizes
Use fonts