diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index 0077748d88..cde9f01538 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -146,7 +146,7 @@ public class FragmentOptions extends FragmentBase { "message_zoom", "overview_mode", "override_width", "addresses", "button_extra", "attachments_alt", "thumbnails", "contrast", "hyphenation", "display_font", "monospaced_pre", "list_count", "bundled_fonts", "parse_classes", - "background_color", "text_color", "text_size", "text_font", "text_align", "text_separators", + "background_color", "text_color", "text_size", "text_font", "text_align", "text_titles", "text_separators", "collapse_quotes", "image_placeholders", "inline_images", "seekbar", "actionbar", "actionbar_color", "group_category", "autoscroll", "swipenav", "reversed", "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 64c37a862f..962db7c0af 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -179,6 +179,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swTextSize; private SwitchCompat swTextFont; private SwitchCompat swTextAlign; + private SwitchCompat swTextTitles; private SwitchCompat swAuthentication; private SwitchCompat swAuthenticationIndicator; @@ -209,7 +210,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer "collapse_quotes", "image_placeholders", "inline_images", "button_extra", "unzip", "attachments_alt", "thumbnails", "list_count", "bundled_fonts", "parse_classes", - "background_color", "text_color", "text_size", "text_font", "text_align", + "background_color", "text_color", "text_size", "text_font", "text_align", "text_titles", "authentication", "authentication_indicator" }; @@ -336,6 +337,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); + swTextTitles = view.findViewById(R.id.swTextTitles); swAuthentication = view.findViewById(R.id.swAuthentication); swAuthenticationIndicator = view.findViewById(R.id.swAuthenticationIndicator); @@ -1259,6 +1261,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); + swTextTitles.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("text_titles", checked).apply(); + } + }); + swAuthentication.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -1510,6 +1519,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)); + swTextTitles.setChecked(prefs.getBoolean("text_titles", false)); swAuthentication.setChecked(prefs.getBoolean("authentication", true)); swAuthenticationIndicator.setChecked(prefs.getBoolean("authentication_indicator", false)); swAuthenticationIndicator.setEnabled(swAuthentication.isChecked()); diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 30c4a70259..10ef3f32c1 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -424,6 +424,7 @@ public class HtmlHelper { boolean text_size = (!view || prefs.getBoolean("text_size", true)); boolean text_font = (!view || prefs.getBoolean("text_font", true)); boolean text_align = prefs.getBoolean("text_align", true); + boolean text_titles = prefs.getBoolean("text_titles", false); boolean display_hidden = prefs.getBoolean("display_hidden", false); boolean disable_tracking = prefs.getBoolean("disable_tracking", true); boolean parse_classes = prefs.getBoolean("parse_classes", true); @@ -509,6 +510,7 @@ public class HtmlHelper { .addAttributes("td", "height") .addAttributes("tr", "width") .addAttributes("tr", "height") + .addAttributes(":all", "title") .removeAttributes("td", "colspan", "rowspan", "width") .removeAttributes("th", "colspan", "rowspan", "width") .addProtocols("img", "src", "cid") @@ -1031,6 +1033,14 @@ public class HtmlHelper { element.attr("x-block", "true"); } + // Insert titles + if (text_titles) + for (Element e : document.select("[title]")) { + String title = e.attr("title"); + if (!TextUtils.isEmpty(title)) + e.prependChild(document.createElement("span").text("{" + title + "}")); + } + // Replace headings Elements hs = document.select("h1,h2,h3,h4,h5,h6"); hs.attr("x-line-before", "true"); diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index b757351891..86fdc84e09 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -1910,6 +1910,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="12dp" + android:checked="true" android:text="@string/title_advanced_parse_classes" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -1933,7 +1934,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="12dp" - android:enabled="true" android:text="@string/title_advanced_background_color" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -1945,7 +1945,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="12dp" - android:enabled="true" + android:checked="true" android:text="@string/title_advanced_text_color" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -1957,7 +1957,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="12dp" - android:enabled="true" + android:checked="true" android:text="@string/title_advanced_text_size" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -1969,7 +1969,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="12dp" - android:enabled="true" + android:checked="true" android:text="@string/title_advanced_text_font" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -1981,13 +1981,24 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="12dp" - android:enabled="true" + android:checked="true" android:text="@string/title_advanced_text_align" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swTextFont" app:switchPadding="12dp" /> + + Use text sizes Use fonts Use text alignment + Show {HTML titles} Use separator lines Collapse quoted text Show image placeholders