diff --git a/app/src/main/java/eu/faircode/email/ActivityEML.java b/app/src/main/java/eu/faircode/email/ActivityEML.java index ff2da43e86..cb147f9bba 100644 --- a/app/src/main/java/eu/faircode/email/ActivityEML.java +++ b/app/src/main/java/eu/faircode/email/ActivityEML.java @@ -139,7 +139,7 @@ public class ActivityEML extends ActivityBase { result.html = parts.getHtml(context); if (result.html != null) { - result.body = HtmlHelper.fromHtml(HtmlHelper.sanitize(context, result.html, false)); + result.body = HtmlHelper.fromHtml(HtmlHelper.sanitize(context, result.html, false, false)); if (result.html.length() > 100 * 1024) result.html = null; } diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 00bb44018c..d02874dc5d 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -2527,6 +2527,10 @@ public class AdapterMessage extends RecyclerView.Adapter 0) { EntityAnswer a = db.answer().getAnswer(answer); @@ -2137,7 +2138,7 @@ public class FragmentCompose extends FragmentBase { data.draft.subject = ref.subject; if (ref.content) { String html = Helper.readText(ref.getFile(context)); - body = HtmlHelper.sanitize(context, html, true); + body = HtmlHelper.sanitize(context, html, text_color, true); } } else if ("list".equals(action)) { data.draft.subject = ref.subject; @@ -2371,7 +2372,7 @@ public class FragmentCompose extends FragmentBase { if (data.draft.content) { File file = data.draft.getFile(context); String html = Helper.readText(file); - html = HtmlHelper.sanitize(context, html, true); + html = HtmlHelper.sanitize(context, html, true, true); Helper.writeText(file, html); } else { if (data.draft.uid == null) @@ -3065,6 +3066,9 @@ public class FragmentCompose extends FragmentBase { final long id = args.getLong("id"); final boolean show_images = args.getBoolean("show_images", false); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean text_color = prefs.getBoolean("text_color", true); + DB db = DB.getInstance(context); EntityMessage draft = db.message().getMessage(id); if (draft == null || !draft.content) @@ -3076,7 +3080,7 @@ public class FragmentCompose extends FragmentBase { Spanned spannedRef = null; File refFile = draft.getRefFile(context); if (refFile.exists()) { - String quote = HtmlHelper.sanitize(context, Helper.readText(refFile), show_images); + String quote = HtmlHelper.sanitize(context, Helper.readText(refFile), text_color, show_images); Spanned spannedQuote = HtmlHelper.fromHtml(quote, new Html.ImageGetter() { @Override diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index de680f2575..24b080133b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -41,7 +41,9 @@ public class FragmentOptions extends FragmentBase { "subscriptions", "startup", "cards", "date", "threading", "highlight_unread", "avatars", "generated_icons", "identicons", "circular", "name_email", "authentication", "subject_top", "subject_italic", "subject_ellipsize", "flags", "preview", "preview_italic", - "addresses", "attachments_alt", "contrast", "monospaced", "inline_images", "collapse_quotes", "autocontent", "seekbar", "actionbar", + "addresses", "attachments_alt", + "contrast", "monospaced", "text_color", + "inline_images", "collapse_quotes", "autocontent", "seekbar", "actionbar", "autoscroll", "swipenav", "autoexpand", "autoclose", "onclose", "experiments", "debug", "biometrics" diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index 02665ba60f..ac5b18dcce 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -66,8 +66,9 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swContrast; private SwitchCompat swMonospaced; - private SwitchCompat swImagesInline; + private SwitchCompat swTextColor; private SwitchCompat swCollapseQuotes; + private SwitchCompat swImagesInline; private SwitchCompat swRemoteContent; private SwitchCompat swSeekbar; private SwitchCompat swActionbar; @@ -77,7 +78,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer "avatars", "generated_icons", "identicons", "circular", "name_email", "authentication", "subject_top", "subject_italic", "subject_ellipsize", "flags", "preview", "preview_italic", "addresses", "attachments_alt", - "contrast", "monospaced", "inline_images", "collapse_quotes", "autocontent", "seekbar", "actionbar", + "contrast", "monospaced", "text_color", + "inline_images", "collapse_quotes", "autocontent", "seekbar", "actionbar", }; @Override @@ -112,8 +114,9 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt); swContrast = view.findViewById(R.id.swContrast); swMonospaced = view.findViewById(R.id.swMonospaced); - swImagesInline = view.findViewById(R.id.swImagesInline); + swTextColor = view.findViewById(R.id.swTextColor); swCollapseQuotes = view.findViewById(R.id.swCollapseQuotes); + swImagesInline = view.findViewById(R.id.swImagesInline); swRemoteContent = view.findViewById(R.id.swRemoteContent); swSeekbar = view.findViewById(R.id.swSeekbar); swActionbar = view.findViewById(R.id.swActionbar); @@ -297,10 +300,10 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); - swImagesInline.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + swTextColor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("inline_images", checked).apply(); + prefs.edit().putBoolean("text_color", checked).apply(); } }); @@ -311,6 +314,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); + swImagesInline.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("inline_images", checked).apply(); + } + }); + swRemoteContent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -416,8 +426,9 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false)); swContrast.setChecked(prefs.getBoolean("contrast", false)); swMonospaced.setChecked(prefs.getBoolean("monospaced", false)); - swImagesInline.setChecked(prefs.getBoolean("inline_images", false)); + swTextColor.setChecked(prefs.getBoolean("text_color", true)); swCollapseQuotes.setChecked(prefs.getBoolean("collapse_quotes", false)); + swImagesInline.setChecked(prefs.getBoolean("inline_images", false)); swRemoteContent.setChecked(prefs.getBoolean("autocontent", false)); swSeekbar.setChecked(prefs.getBoolean("seekbar", false)); swActionbar.setChecked(prefs.getBoolean("actionbar", true)); diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 08b6f4d5a5..73d9623e9a 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -93,7 +93,7 @@ public class HtmlHelper { private static final ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); - static String sanitize(Context context, String html, boolean show_images) { + static String sanitize(Context context, String html, boolean text_color, boolean show_images) { Document parsed = Jsoup.parse(html); // - + app:layout_constraintTop_toBottomOf="@id/swTextColor" + app:switchPadding="12dp" /> + + Show attachments after the message text Use high contrast for message text Use monospaced font for message text - Automatically show inline images + Show text colors Collapse quoted text + Automatically show inline images Automatically show remote content when viewing original messages Show relative conversation position with a dot Show conversation action bar