From d5012408512c030a816a946e30239c9f834f473c Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 29 Nov 2018 12:16:59 +0100 Subject: [PATCH] Show embedded images after confirmation only --- FAQ.md | 12 +++--- .../eu/faircode/email/AdapterMessage.java | 39 ++++++++++--------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/FAQ.md b/FAQ.md index 007655d667..b72345260a 100644 --- a/FAQ.md +++ b/FAQ.md @@ -353,15 +353,15 @@ Yes, you can translate the texts of FairEmail in your own language [here](https: Registration is free. -**(27) Why are images shown without tapping 'Show images' ?** +**(27) ~~Why are images shown without tapping 'Show images' ?~~** -There are two types of images: +~~There are two types of images:~~ -* Images embedded into a message -* Images stored on a remote server +* ~~Images embedded into a message~~ +* ~~Images stored on a remote server~~ -Embedded images, also visible as an attachment, are always shown, but images stored on a remote server need to be downloaded by tapping *Show images*. -Note that downloading images from a remote server can be used to record you did see a message, which you likely don't want if the message is spam or malicious. +~~Embedded images, also visible as an attachment, are always shown, but images stored on a remote server need to be downloaded by tapping *Show images*.~~ +~~Note that downloading images from a remote server can be used to record you did see a message, which you likely don't want if the message is spam or malicious.~~ **(28) How can I manage status bar notifications?** diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index e508850dba..3c2e5fe802 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -726,29 +726,30 @@ public class AdapterMessage extends PagedListAdapter 1) { - String cid = "<" + cids[1] + ">"; - EntityAttachment attachment = DB.getInstance(context).attachment().getAttachment(message.id, cid); - if (attachment == null || !attachment.available) { - Drawable d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme()); - d.setBounds(0, 0, px, px); - return d; - } else { - File file = EntityAttachment.getFile(context, attachment.id); - Drawable d = Drawable.createFromPath(file.getAbsolutePath()); - if (d == null) { - d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme()); + if (properties.showImages(message.id)) { + // Embedded images + if (source != null && source.startsWith("cid")) { + String[] cids = source.split(":"); + if (cids.length > 1) { + String cid = "<" + cids[1] + ">"; + EntityAttachment attachment = DB.getInstance(context).attachment().getAttachment(message.id, cid); + if (attachment == null || !attachment.available) { + Drawable d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme()); d.setBounds(0, 0, px, px); - } else - d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); - return d; + return d; + } else { + File file = EntityAttachment.getFile(context, attachment.id); + Drawable d = Drawable.createFromPath(file.getAbsolutePath()); + if (d == null) { + d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme()); + d.setBounds(0, 0, px, px); + } else + d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); + return d; + } } } - } - if (properties.showImages(message.id)) { // Get cache folder File dir = new File(context.getCacheDir(), "images"); dir.mkdir();