Automatically download inline images on expanding message

This commit is contained in:
M66B 2019-08-20 21:52:01 +02:00
parent 5260162986
commit 348fd3806d
2 changed files with 12 additions and 1 deletions

View File

@ -2017,7 +2017,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id); List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
for (EntityAttachment attachment : attachments) 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); EntityOperation.queue(context, message, EntityOperation.ATTACHMENT, attachment.id);
db.setTransactionSuccessful(); db.setTransactionSuccessful();

View File

@ -3057,6 +3057,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
protected Void onExecute(Context context, Bundle args) { protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id"); long id = args.getLong("id");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean inline_images = prefs.getBoolean("inline_images", false);
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
@ -3072,6 +3075,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (message.uid != null) { if (message.uid != null) {
if (!message.content) if (!message.content)
EntityOperation.queue(context, message, EntityOperation.BODY); EntityOperation.queue(context, message, EntityOperation.BODY);
if (inline_images) {
List<EntityAttachment> 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) if (!message.ui_seen && !folder.read_only)
EntityOperation.queue(context, message, EntityOperation.SEEN, true); EntityOperation.queue(context, message, EntityOperation.SEEN, true);
} }