mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-02 13:14:39 +00:00
Show image attachment composer
This commit is contained in:
parent
605d576ecc
commit
d9e35e236a
1 changed files with 29 additions and 13 deletions
|
@ -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,20 +120,33 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
|
||||||
|
|
||||||
ibDelete.setVisibility(readonly ? View.GONE : View.VISIBLE);
|
ibDelete.setVisibility(readonly ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
int resid = 0;
|
if (!readonly && attachment.isImage()) {
|
||||||
String extension = Helper.guessExtension(attachment.getMimeType());
|
if (attachment.available) {
|
||||||
if (extension != null)
|
Bitmap bm = ImageHelper.decodeImage(
|
||||||
resid = context.getResources().getIdentifier("file_" + extension, "drawable", context.getPackageName());
|
attachment.getFile(context), attachment.getMimeType(), dp36);
|
||||||
if (resid == 0)
|
if (bm == null)
|
||||||
ivType.setImageDrawable(null);
|
ivType.setImageResource(R.drawable.twotone_broken_image_24);
|
||||||
else
|
else
|
||||||
ivType.setImageResource(resid);
|
ivType.setImageBitmap(bm);
|
||||||
|
} else
|
||||||
|
ivType.setImageResource(R.drawable.twotone_hourglass_top_24);
|
||||||
|
ivDisposition.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
int resid = 0;
|
||||||
|
String extension = Helper.guessExtension(attachment.getMimeType());
|
||||||
|
if (extension != null)
|
||||||
|
resid = context.getResources().getIdentifier("file_" + extension, "drawable", context.getPackageName());
|
||||||
|
if (resid == 0)
|
||||||
|
ivType.setImageDrawable(null);
|
||||||
|
else
|
||||||
|
ivType.setImageResource(resid);
|
||||||
|
|
||||||
ivDisposition.setImageLevel(Part.INLINE.equals(attachment.disposition) ? 1 : 0);
|
ivDisposition.setImageLevel(Part.INLINE.equals(attachment.disposition) ? 1 : 0);
|
||||||
ivDisposition.setVisibility(
|
ivDisposition.setVisibility(
|
||||||
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…
Reference in a new issue