show PDF preview in MediaBrowserActivity

This commit is contained in:
Christian Schneppe 2020-02-12 19:53:45 +01:00
parent e4d3b5ebe8
commit 92b16348f4
No known key found for this signature in database
GPG key ID: F30B8D686B44D87E
2 changed files with 5 additions and 2 deletions

View file

@ -1383,7 +1383,10 @@ public class FileBackend {
if (bitmap != null || cacheOnly) {
return bitmap;
}
if (attachment.getMime() != null && attachment.getMime().startsWith("video/")) {
DownloadableFile file = new DownloadableFile(attachment.getUri().getPath());
if ("application/pdf".equals(attachment.getMime()) && Compatibility.runsTwentyOne()) {
bitmap = cropCenterSquare(getPDFPreview(file, size), size);
} else if (attachment.getMime() != null && attachment.getMime().startsWith("video/")) {
bitmap = cropCenterSquareVideo(attachment.getUri(), size);
drawOverlay(bitmap, R.drawable.play_video, 0.75f);
} else {

View file

@ -158,7 +158,7 @@ public class Attachment implements Parcelable {
}
public boolean renderThumbnail() {
return type == Type.IMAGE || (type == Type.FILE && mime != null && (mime.startsWith("video/") || mime.startsWith("image/")));
return type == Type.IMAGE || (type == Type.FILE && mime != null && (mime.startsWith("video/") || mime.startsWith("image/") || mime.contains("pdf")));
}
public Uri getUri() {