From 6c1f50dcda57fc40d79d2c383deef21a37302ba9 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 21 Feb 2021 21:48:59 +0100 Subject: [PATCH] Added option to disable printing images --- .../main/java/eu/faircode/email/AdapterMessage.java | 9 +++++++++ .../java/eu/faircode/email/FragmentMessages.java | 13 ++++++++++--- .../java/eu/faircode/email/FragmentOptionsMisc.java | 4 +++- app/src/main/res/layout/dialog_print.xml | 12 +++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index c0c9a2950c..f13b912d87 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -6923,6 +6923,7 @@ public class AdapterMessage extends RecyclerView.Adapter() { @Override protected String[] onExecute(Context context, Bundle args) throws IOException { long id = args.getLong("id"); boolean headers = args.getBoolean("headers"); + boolean print_html_header = args.getBoolean("print_html_header"); DB db = DB.getInstance(context); EntityMessage message = db.message().getMessage(id); @@ -7372,8 +7380,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. element.removeClass(clazz); } - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - boolean print_html_header = prefs.getBoolean("print_html_header", true); if (print_html_header) { Element header = document.createElement("p"); @@ -7469,12 +7475,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. } final Context context = activity.getOriginalContext(); + boolean print_html_images = args.getBoolean("print_html_images"); // https://developer.android.com/training/printing/html-docs.html printWebView = new WebView(context); WebSettings settings = printWebView.getSettings(); - settings.setLoadsImagesAutomatically(true); + settings.setLoadsImagesAutomatically(print_html_images); settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); settings.setAllowFileAccess(false); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index d511c79899..2223b6d8b8 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -140,7 +140,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private final static String[] RESET_QUESTIONS = new String[]{ "first", "app_support", "notify_archive", "message_swipe", "message_select", "folder_actions", "folder_sync", "crash_reports_asked", "review_asked", "review_later", "why", - "reply_hint", "html_always_images", "open_full_confirmed", "print_html_confirmed", "reformatted_hint", + "reply_hint", "html_always_images", "open_full_confirmed", + "print_html_confirmed", "print_html_header", "print_html_images", + "reformatted_hint", "selected_folders", "move_1_confirmed", "move_n_confirmed", "last_search_senders", "last_search_recipients", "last_search_subject", "last_search_keywords", "last_search_message", "last_search", "identities_asked", "identities_primary_hint", diff --git a/app/src/main/res/layout/dialog_print.xml b/app/src/main/res/layout/dialog_print.xml index 3334e2351e..21fd97c722 100644 --- a/app/src/main/res/layout/dialog_print.xml +++ b/app/src/main/res/layout/dialog_print.xml @@ -41,6 +41,16 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvRemark" /> + + + app:layout_constraintTop_toBottomOf="@id/cbImages" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0d3ef77714..4c0d24150d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -856,6 +856,7 @@ Add shortcut Print Print header + Print images Show headers Save raw message Send as attachment