Show image attachment composer

pull/194/merge
M66B 4 years ago
parent 605d576ecc
commit d9e35e236a

@ -22,6 +22,7 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -63,6 +64,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
private boolean readonly; private boolean readonly;
private boolean debug; private boolean debug;
private int dp12; private int dp12;
private int dp36;
private List<EntityAttachment> items = new ArrayList<>(); private List<EntityAttachment> items = new ArrayList<>();
@ -118,6 +120,18 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
ibDelete.setVisibility(readonly ? View.GONE : View.VISIBLE); ibDelete.setVisibility(readonly ? View.GONE : View.VISIBLE);
if (!readonly && attachment.isImage()) {
if (attachment.available) {
Bitmap bm = ImageHelper.decodeImage(
attachment.getFile(context), attachment.getMimeType(), dp36);
if (bm == null)
ivType.setImageResource(R.drawable.twotone_broken_image_24);
else
ivType.setImageBitmap(bm);
} else
ivType.setImageResource(R.drawable.twotone_hourglass_top_24);
ivDisposition.setVisibility(View.GONE);
} else {
int resid = 0; int resid = 0;
String extension = Helper.guessExtension(attachment.getMimeType()); String extension = Helper.guessExtension(attachment.getMimeType());
if (extension != null) if (extension != null)
@ -132,6 +146,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
Part.ATTACHMENT.equals(attachment.disposition) || Part.ATTACHMENT.equals(attachment.disposition) ||
Part.INLINE.equals(attachment.disposition) Part.INLINE.equals(attachment.disposition)
? View.VISIBLE : View.INVISIBLE); ? View.VISIBLE : View.INVISIBLE);
}
tvName.setText(attachment.name); tvName.setText(attachment.name);
@ -346,6 +361,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.debug = prefs.getBoolean("debug", false); this.debug = prefs.getBoolean("debug", false);
this.dp12 = Helper.dp2pixels(context, 12); this.dp12 = Helper.dp2pixels(context, 12);
this.dp36 = Helper.dp2pixels(context, 36);
setHasStableIds(true); setHasStableIds(true);

Loading…
Cancel
Save