From 348fd3806d1b6101af6e8648d8f69f0cfa31265b Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 20 Aug 2019 21:52:01 +0200 Subject: [PATCH] Automatically download inline images on expanding message --- .../main/java/eu/faircode/email/AdapterMessage.java | 2 +- .../main/java/eu/faircode/email/FragmentMessages.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 56927f58f4..c35e9205e5 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -2017,7 +2017,7 @@ public class AdapterMessage extends RecyclerView.Adapter attachments = db.attachment().getAttachments(message.id); for (EntityAttachment attachment : attachments) - if (!attachment.available && !TextUtils.isEmpty(attachment.cid)) + if (!attachment.available && attachment.isInline() && attachment.isImage()) EntityOperation.queue(context, message, EntityOperation.ATTACHMENT, attachment.id); db.setTransactionSuccessful(); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 4664479235..e230b19ae4 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -3057,6 +3057,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. protected Void onExecute(Context context, Bundle args) { long id = args.getLong("id"); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean inline_images = prefs.getBoolean("inline_images", false); + DB db = DB.getInstance(context); try { db.beginTransaction(); @@ -3072,6 +3075,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (message.uid != null) { if (!message.content) EntityOperation.queue(context, message, EntityOperation.BODY); + + if (inline_images) { + List attachments = db.attachment().getAttachments(message.id); + for (EntityAttachment attachment : attachments) + if (!attachment.available && attachment.isInline() && attachment.isImage()) + EntityOperation.queue(context, message, EntityOperation.ATTACHMENT, attachment.id); + } + if (!message.ui_seen && !folder.read_only) EntityOperation.queue(context, message, EntityOperation.SEEN, true); }