mirror of https://github.com/M66B/FairEmail.git
Media improvements
This commit is contained in:
parent
41464507e0
commit
a35fcd876e
|
@ -123,7 +123,7 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Drawable onExecute(Context context, Bundle args) throws Throwable {
|
||||
protected Drawable onExecute(Context context, Bundle args) {
|
||||
File file = (File) args.getSerializable("file");
|
||||
String type = args.getString("type");
|
||||
int max = args.getInt("max");
|
||||
|
@ -147,18 +147,21 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|||
return null;
|
||||
}
|
||||
} else if (type != null && type.startsWith("video/")) {
|
||||
Bitmap bm = ThumbnailUtils.createVideoThumbnail(file, new Size(max, max), null);
|
||||
if (bm == null)
|
||||
return null;
|
||||
return new BitmapDrawable(context.getResources(), bm);
|
||||
try {
|
||||
Bitmap bm = ThumbnailUtils.createVideoThumbnail(file, new Size(max, max), null);
|
||||
if (bm == null)
|
||||
return null;
|
||||
return new BitmapDrawable(context.getResources(), bm);
|
||||
} catch (Throwable ex) {
|
||||
Log.i(ex);
|
||||
return context.getDrawable(R.drawable.twotone_ondemand_video_24);
|
||||
}
|
||||
} else {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean webp = prefs.getBoolean("webp", true);
|
||||
|
||||
if ("image/webp".equalsIgnoreCase(type) && !webp) {
|
||||
args.putBoolean("nowebp", true);
|
||||
return null;
|
||||
}
|
||||
if ("image/webp".equalsIgnoreCase(type) && !webp)
|
||||
return context.getDrawable(R.drawable.twotone_image_not_supported_24);
|
||||
|
||||
args.putLong("size", file.length());
|
||||
|
||||
|
@ -196,15 +199,18 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Drawable image) {
|
||||
if (image == null)
|
||||
if (args.getBoolean("nowebp"))
|
||||
ivImage.setImageResource(R.drawable.twotone_warning_24);
|
||||
if (image == null) {
|
||||
String type = args.getString("type");
|
||||
if ("application/pdf".equals(type))
|
||||
ivImage.setImageResource(R.drawable.twotone_article_24);
|
||||
else if (attachment.isVideo())
|
||||
ivImage.setImageResource(R.drawable.twotone_ondemand_video_24);
|
||||
else
|
||||
ivImage.setImageResource(R.drawable.twotone_broken_image_24);
|
||||
else
|
||||
} else {
|
||||
ivImage.setImageDrawable(image);
|
||||
|
||||
ImageHelper.animate(context, image);
|
||||
ImageHelper.animate(context, image);
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
@ -248,7 +254,7 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
|
|||
protected void onException(Bundle args, Throwable ex) {
|
||||
tvCaption.setText(Log.formatThrowable(ex));
|
||||
tvCaption.setVisibility(View.VISIBLE);
|
||||
ivImage.setImageResource(R.drawable.twotone_broken_image_24);
|
||||
ivImage.setImageResource(R.drawable.twotone_warning_24);
|
||||
}
|
||||
}.execute(context, owner, args, "image:load");
|
||||
} else
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M7.83,5H19v11.17L7.83,5zM16.17,19l-2,-2H6l3,-4l2,2.72l0.84,-1.05L5,7.83V19H16.17z"
|
||||
android:strokeAlpha="0.3"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M5.83,3H19c1.1,0 2,0.9 2,2v13.17l-2,-2V5H7.83L5.83,3zM20.49,23.31L18.17,21H5c-1.1,0 -2,-0.9 -2,-2V5.83L0.69,3.51L2.1,2.1l1.49,1.49L5,5l8.11,8.11l2.69,2.69L19,19l1.41,1.41l1.49,1.49L20.49,23.31zM16.17,19l-2,-2H6l3,-4l2,2.72l0.84,-1.05L5,7.83V19H16.17z"/>
|
||||
</vector>
|
|
@ -0,0 +1,15 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,17h18V5H3v12zM9,7l7,4 -7,4V7z"
|
||||
android:strokeAlpha="0.3"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M9,7v8l7,-4zM21,3L3,3c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h5v2h8v-2h5c1.1,0 2,-0.9 2,-2L23,5c0,-1.1 -0.9,-2 -2,-2zM21,17L3,17L3,5h18v12z"/>
|
||||
</vector>
|
Loading…
Reference in New Issue