diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java
index c8427d5481..d845a90991 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java
@@ -38,10 +38,11 @@ import androidx.preference.PreferenceManager;
public class FragmentOptionsPrivacy extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swDisableTracking;
+ private SwitchCompat swDisplayHidden;
private SwitchCompat swNoHistory;
private final static String[] RESET_OPTIONS = new String[]{
- "disable_tracking", "no_history"
+ "disable_tracking", "display_hidden", "no_history"
};
@Override
@@ -55,6 +56,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
// Get controls
swDisableTracking = view.findViewById(R.id.swDisableTracking);
+ swDisplayHidden = view.findViewById(R.id.swDisplayHidden);
swNoHistory = view.findViewById(R.id.swNoHistory);
setOptions();
@@ -70,6 +72,13 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
}
});
+ swDisplayHidden.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("display_hidden", checked).apply();
+ }
+ });
+
swNoHistory.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -125,6 +134,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", true));
+ swDisplayHidden.setChecked(prefs.getBoolean("display_hidden", false));
swNoHistory.setChecked(prefs.getBoolean("no_history", false));
}
}
diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java
index ef5e57c31a..f1dc6c6255 100644
--- a/app/src/main/java/eu/faircode/email/HtmlHelper.java
+++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java
@@ -82,6 +82,7 @@ public class HtmlHelper {
static String sanitize(Context context, String html, boolean show_images) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean text_color = prefs.getBoolean("text_color", true);
+ boolean display_hidden = prefs.getBoolean("display_hidden", false);
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
Document parsed = JsoupEx.parse(html);
@@ -148,21 +149,22 @@ public class HtmlHelper {
font.tagName("span");
}
- // Sanitize span styles
- for (Element span : document.select("*")) {
- String style = span.attr("style");
+ // Sanitize styles
+ for (Element element : document.select("*")) {
+ String style = element.attr("style");
if (!TextUtils.isEmpty(style)) {
StringBuilder sb = new StringBuilder();
String[] params = style.split(";");
for (String param : params) {
String[] kv = param.split(":");
- if (kv.length == 2)
- switch (kv[0].trim().toLowerCase(Locale.ROOT)) {
+ if (kv.length == 2) {
+ String key = kv[0].trim().toLowerCase(Locale.ROOT);
+ String value = kv[1].toLowerCase(Locale.ROOT)
+ .replace(" ", "");
+ switch (key) {
case "color":
- String c = kv[1]
- .toLowerCase(Locale.ROOT)
- .replace(" ", "")
+ String c = value
.replace("inherit", "")
.replace("initial", "")
.replace("windowtext", "")
@@ -201,7 +203,7 @@ public class HtmlHelper {
sb.append("color:").append(c).append(";");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
- span.attr("color", c);
+ element.attr("color", c);
}
break;
@@ -212,13 +214,21 @@ public class HtmlHelper {
case "line-through":
sb.append(param).append(";");
break;
+
+ case "display":
+ if ("none".equals(value) && !display_hidden) {
+ Log.i("Removing element " + element.tagName());
+ element.remove();
+ }
+ break;
}
+ }
}
if (sb.length() == 0)
- span.removeAttr("style");
+ element.removeAttr("style");
else
- span.attr("style", sb.toString());
+ element.attr("style", sb.toString());
}
}
diff --git a/app/src/main/res/layout/fragment_options_privacy.xml b/app/src/main/res/layout/fragment_options_privacy.xml
index ae8a1d405f..042b1b6913 100644
--- a/app/src/main/res/layout/fragment_options_privacy.xml
+++ b/app/src/main/res/layout/fragment_options_privacy.xml
@@ -23,6 +23,29 @@
app:layout_constraintTop_toTopOf="parent"
app:switchPadding="12dp" />
+
+
+
+
MIUI notification sound workaround
Automatically recognize and disable tracking images
+ Display hidden message texts
Hide FairEmail from screen with recent apps
Only available on supported launchers
@@ -362,6 +363,8 @@
Automatically close conversations when all messages are archived, sent or trashed
Most providers do not allow modified sender addresses
+ This can result in odd looking and double texts
+
Enabling this will delete all local folders without subscription
This will restart the app
List of current experimental features