From fe77429da51cf193ed73ca6aa6d56bdf43ee3d55 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 29 Nov 2018 13:15:41 +0100 Subject: [PATCH] Differentiate between external and embedded images --- FAQ.md | 18 ++++-- .../eu/faircode/email/AdapterMessage.java | 55 ++++++++++--------- .../eu/faircode/email/FragmentCompose.java | 4 +- .../res/drawable/baseline_broken_image_24.xml | 10 ++++ ...g_24.xml => baseline_photo_library_24.xml} | 2 +- 5 files changed, 54 insertions(+), 35 deletions(-) create mode 100755 app/src/main/res/drawable/baseline_broken_image_24.xml rename app/src/main/res/drawable/{baseline_warning_24.xml => baseline_photo_library_24.xml} (60%) mode change 100644 => 100755 diff --git a/FAQ.md b/FAQ.md index b72345260a..ae80c52840 100644 --- a/FAQ.md +++ b/FAQ.md @@ -353,15 +353,21 @@ 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) How can I differentiate external and embedded images?** -~~There are two types of images:~~ +External image: -* ~~Images embedded into a message~~ -* ~~Images stored on a remote server~~ +![External image](https://raw.githubusercontent.com/google/material-design-icons/master/image/1x_web/ic_image_black_48dp.png) -~~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 image: + +![Embedded image](https://raw.githubusercontent.com/google/material-design-icons/master/image/1x_web/ic_photo_library_black_48dp.png) + +Broken image: + +![Broken image](https://raw.githubusercontent.com/google/material-design-icons/master/image/1x_web/ic_broken_image_black_48dp.png) + +Note that downloading external 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 3c2e5fe802..c7c3bfb537 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -724,29 +724,34 @@ public class AdapterMessage extends PagedListAdapter 1); 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); - 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 (embedded) { + String cid = "<" + source.split(":")[1] + ">"; + EntityAttachment attachment = DB.getInstance(context).attachment().getAttachment(message.id, cid); + if (attachment == null || !attachment.available) { + Drawable d = context.getResources().getDrawable(R.drawable.baseline_photo_library_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_broken_image_24, context.getTheme()); + d.setBounds(0, 0, px / 2, px / 2); + } else + d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); + return d; } } @@ -767,9 +772,6 @@ public class AdapterMessage extends PagedListAdapter + + diff --git a/app/src/main/res/drawable/baseline_warning_24.xml b/app/src/main/res/drawable/baseline_photo_library_24.xml old mode 100644 new mode 100755 similarity index 60% rename from app/src/main/res/drawable/baseline_warning_24.xml rename to app/src/main/res/drawable/baseline_photo_library_24.xml index c18093a7fc..353577b10c --- a/app/src/main/res/drawable/baseline_warning_24.xml +++ b/app/src/main/res/drawable/baseline_photo_library_24.xml @@ -6,5 +6,5 @@ android:tint="?attr/colorControlNormal"> + android:pathData="M22,16L22,4c0,-1.1 -0.9,-2 -2,-2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zM11,12l2.03,2.71L16,11l4,5L8,16l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6L2,6z"/>