1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 02:07:12 +00:00

Improved inline attachment selection

This commit is contained in:
M66B 2019-02-17 12:05:58 +00:00
parent ecb815d085
commit e4c2adaa5b

View file

@ -891,28 +891,30 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean show_inline = properties.getValue("inline", message.id); boolean show_inline = properties.getValue("inline", message.id);
Log.i("Show inline=" + show_inline); Log.i("Show inline=" + show_inline);
boolean inline = false; boolean has_inline = false;
boolean download = false; boolean download = false;
boolean save = (attachments.size() > 1); boolean save = (attachments.size() > 1);
boolean downloading = false; boolean downloading = false;
List<EntityAttachment> a = new ArrayList<>(); List<EntityAttachment> a = new ArrayList<>();
for (EntityAttachment attachment : attachments) { for (EntityAttachment attachment : attachments) {
if (attachment.isInline() || TextUtils.isEmpty(attachment.name)) boolean inline = (TextUtils.isEmpty(attachment.name) ||
inline = true; (attachment.isInline() && attachment.type.startsWith("image/")));
if (inline)
has_inline = true;
if (attachment.progress == null && !attachment.available) if (attachment.progress == null && !attachment.available)
download = true; download = true;
if (!attachment.available) if (!attachment.available)
save = false; save = false;
if (attachment.progress != null) if (attachment.progress != null)
downloading = true; downloading = true;
if (show_inline || !attachment.isInline()) if (show_inline || !inline)
a.add(attachment); a.add(attachment);
} }
adapterAttachment.set(a); adapterAttachment.set(a);
cbInline.setOnCheckedChangeListener(null); cbInline.setOnCheckedChangeListener(null);
cbInline.setChecked(show_inline); cbInline.setChecked(show_inline);
cbInline.setVisibility(inline ? View.VISIBLE : View.GONE); cbInline.setVisibility(has_inline ? View.VISIBLE : View.GONE);
btnDownloadAttachments.setVisibility(download && internet ? View.VISIBLE : View.GONE); btnDownloadAttachments.setVisibility(download && internet ? View.VISIBLE : View.GONE);
btnSaveAttachments.setVisibility(save ? View.VISIBLE : View.GONE); btnSaveAttachments.setVisibility(save ? View.VISIBLE : View.GONE);
tvNoInternetAttachments.setVisibility(downloading && !internet ? View.VISIBLE : View.GONE); tvNoInternetAttachments.setVisibility(downloading && !internet ? View.VISIBLE : View.GONE);
@ -928,7 +930,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
List<EntityAttachment> images = new ArrayList<>(); List<EntityAttachment> images = new ArrayList<>();
for (EntityAttachment attachment : attachments) for (EntityAttachment attachment : attachments)
if (attachment.type.startsWith("image/") && !attachment.isInline()) if (attachment.type.startsWith("image/"))
images.add(attachment); images.add(attachment);
adapterImage.set(images); adapterImage.set(images);
rvImage.setVisibility(images.size() > 0 ? View.VISIBLE : View.GONE); rvImage.setVisibility(images.size() > 0 ? View.VISIBLE : View.GONE);