diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java
index 15ed002db2..af5d8de82a 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",
"addresses", "attachments_alt",
- "contrast", "monospaced", "text_color", "text_size",
+ "contrast", "monospaced", "text_color", "text_size", "text_font", "text_align",
"inline_images", "collapse_quotes", "seekbar", "actionbar", "actionbar_color", "navbar_colorize",
"autoscroll", "swipenav", "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 9848547723..b4249f1b09 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java
@@ -108,6 +108,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swMonospaced;
private SwitchCompat swTextColor;
private SwitchCompat swTextSize;
+ private SwitchCompat swTextFont;
private SwitchCompat swTextAlign;
private SwitchCompat swCollapseQuotes;
private SwitchCompat swImagesInline;
@@ -126,7 +127,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"keywords_header", "labels_header", "flags", "flags_background",
"preview", "preview_italic", "preview_lines",
"addresses",
- "contrast", "monospaced", "text_color", "text_size", "text_align",
+ "contrast", "monospaced", "text_color", "text_size", "text_font", "text_align",
"inline_images", "collapse_quotes", "attachments_alt",
"parse_classes", "authentication"
};
@@ -192,6 +193,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swMonospaced = view.findViewById(R.id.swMonospaced);
swTextColor = view.findViewById(R.id.swTextColor);
swTextSize = view.findViewById(R.id.swTextSize);
+ swTextFont = view.findViewById(R.id.swTextFont);
swTextAlign = view.findViewById(R.id.swTextAlign);
swCollapseQuotes = view.findViewById(R.id.swCollapseQuotes);
swImagesInline = view.findViewById(R.id.swImagesInline);
@@ -615,6 +617,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
+ swTextFont.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("text_font", checked).apply();
+ }
+ });
+
swTextAlign.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -798,6 +807,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
swTextColor.setChecked(prefs.getBoolean("text_color", true));
swTextSize.setChecked(prefs.getBoolean("text_size", true));
+ swTextFont.setChecked(prefs.getBoolean("text_font", true));
swTextAlign.setChecked(prefs.getBoolean("text_align", true));
swCollapseQuotes.setChecked(prefs.getBoolean("collapse_quotes", false));
swImagesInline.setChecked(prefs.getBoolean("inline_images", false));
diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java
index a9b275a74b..5e07707903 100644
--- a/app/src/main/java/eu/faircode/email/HtmlHelper.java
+++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java
@@ -319,6 +319,7 @@ public class HtmlHelper {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean text_color = prefs.getBoolean("text_color", true);
boolean text_size = prefs.getBoolean("text_size", true);
+ boolean text_font = prefs.getBoolean("text_font", true);
boolean text_align = prefs.getBoolean("text_align", true);
boolean display_hidden = prefs.getBoolean("display_hidden", false);
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
@@ -448,7 +449,6 @@ public class HtmlHelper {
.addTags("hr", "abbr", "big", "font", "dfn", "del", "s", "tt")
.addAttributes(":all", "class")
.addAttributes(":all", "style")
- .addAttributes("font", "size")
.addAttributes("div", "x-plain")
.removeTags("col", "colgroup", "thead", "tbody")
.removeAttributes("table", "width")
@@ -460,6 +460,10 @@ public class HtmlHelper {
.addProtocols("a", "href", "full", "xmpp", "geo", "tel");
if (text_color)
whitelist.addAttributes("font", "color");
+ if (text_size)
+ whitelist.addAttributes("font", "size");
+ if (text_font)
+ whitelist.addAttributes("font", "face");
if (text_align)
whitelist.addTags("center").addAttributes(":all", "align");
if (!view)
@@ -475,6 +479,7 @@ public class HtmlHelper {
String style = font.attr("style");
String color = font.attr("color");
String size = font.attr("size");
+ String face = font.attr("face");
style = style.trim();
if (!TextUtils.isEmpty(style) && !style.endsWith(";"))
@@ -482,6 +487,7 @@ public class HtmlHelper {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
font.removeAttr("color");
font.removeAttr("size");
+ font.removeAttr("face");
StringBuilder sb = new StringBuilder(style);
@@ -503,6 +509,9 @@ public class HtmlHelper {
}
}
+ if (!TextUtils.isEmpty(face))
+ sb.append("font-family:").append(face).append(";");
+
font.attr("style", sb.toString());
font.tagName("span");
@@ -600,6 +609,14 @@ public class HtmlHelper {
}
break;
+ case "font-family":
+ if (!text_font)
+ continue;
+
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/font-family
+ sb.append(key).append(":").append(value).append(";");
+ break;
+
case "text-decoration":
// https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration
if (value.contains("line-through"))
@@ -1975,6 +1992,9 @@ public class HtmlHelper {
Log.i(ex);
}
break;
+ case "font-family":
+ ssb.setSpan(new TypefaceSpan(value), start, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ break;
case "text-decoration":
if ("line-through".equals(value))
ssb.setSpan(new StrikethroughSpan(), start, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml
index ade1a484dd..70b52c3afe 100644
--- a/app/src/main/res/layout/fragment_options_display.xml
+++ b/app/src/main/res/layout/fragment_options_display.xml
@@ -833,6 +833,18 @@
app:layout_constraintTop_toBottomOf="@id/swTextColor"
app:switchPadding="12dp" />
+
+
Expand address details by default
Show attachments after the message text
Use high contrast for message text
- Use monospaced font for message text
- Show text colors
- Show small and large texts
- Show left/center/right aligned texts
+ Use monospaced font for message text by default
+ Use text colors
+ Use text sizes
+ Use fonts
+ Use text alignment
Collapse quoted text
Automatically show inline images
Show relative conversation position with a dot