diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index ce665ffb8c..8a83f6052a 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -60,6 +60,8 @@ import android.view.TouchDelegate; import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; @@ -190,6 +192,7 @@ public class AdapterMessage extends RecyclerView.Adapter 0 ? View.VISIBLE : View.GONE); + cbInline.setVisibility(View.GONE); btnDownloadAttachments.setVisibility(View.GONE); btnSaveAttachments.setVisibility(View.GONE); tvNoInternetAttachments.setVisibility(View.GONE); @@ -705,24 +711,44 @@ public class AdapterMessage extends RecyclerView.Adapter(); idAttachments.put(message.id, attachments); - adapterAttachment.set(attachments); + boolean show_inline = properties.getValue("inline", message.id); + Log.i("Show inline=" + show_inline); + boolean inline = false; boolean download = false; boolean save = (attachments.size() > 1); boolean downloading = false; + List a = new ArrayList<>(); for (EntityAttachment attachment : attachments) { + if (attachment.isInline()) + inline = true; if (attachment.progress == null && !attachment.available) download = true; if (!attachment.available) save = false; if (attachment.progress != null) downloading = true; + if (show_inline || !attachment.isInline()) + a.add(attachment); } + adapterAttachment.set(a); + cbInline.setOnCheckedChangeListener(null); + cbInline.setChecked(show_inline); + cbInline.setVisibility(inline ? View.VISIBLE : View.GONE); btnDownloadAttachments.setVisibility(download && internet ? View.VISIBLE : View.GONE); btnSaveAttachments.setVisibility(save ? View.VISIBLE : View.GONE); tvNoInternetAttachments.setVisibility(downloading && !internet ? View.VISIBLE : View.GONE); + cbInline.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + properties.setValue("inline", message.id, isChecked); + liveAttachments.removeObserver(observerAttachments); + liveAttachments.observe(owner, observerAttachments); + } + }); + List images = new ArrayList<>(); for (EntityAttachment attachment : attachments) if (attachment.type.startsWith("image/") && !attachment.isInline()) diff --git a/app/src/main/res/layout/item_message_compact.xml b/app/src/main/res/layout/item_message_compact.xml index 3f72f1f7a4..925d76dfbc 100644 --- a/app/src/main/res/layout/item_message_compact.xml +++ b/app/src/main/res/layout/item_message_compact.xml @@ -597,6 +597,15 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" /> + +