Skip to content

Commit 4d36f9e

Browse files
committed
fix(thumbnail): generation for zip file
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
1 parent 0186a3b commit 4d36f9e

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

app/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,9 @@ private Bitmap doThumbnailFromOCFileInBackground() {
578578
String imageKey = PREFIX_THUMBNAIL + file.getRemoteId();
579579

580580
boolean updateEnforced = (file instanceof OCFile && ((OCFile) file).isUpdateThumbnailNeeded());
581+
if (MimeTypeUtil.isZip(file)) {
582+
return null;
583+
}
581584

582585
// Try to load thumbnail from disk cache
583586
if (!updateEnforced) {

app/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,27 @@ public static boolean isPDF(OCFile file) {
330330
return isPDF(file.getMimeType()) || isPDF(getMimeTypeFromPath(file.getRemotePath()));
331331
}
332332

333+
public static boolean isZip(String mimeType) {
334+
if (mimeType == null) {
335+
return false;
336+
}
337+
String lower = mimeType.toLowerCase(Locale.ROOT);
338+
return lower.equals("application/zip")
339+
|| lower.equals("application/x-7z-compressed")
340+
|| lower.equals("application/x-bzip2")
341+
|| lower.equals("application/x-compressed")
342+
|| lower.equals("application/x-deb")
343+
|| lower.equals("application/gzip")
344+
|| lower.equals("application/x-gzip")
345+
|| lower.equals("application/x-rar-compressed")
346+
|| lower.equals("application/x-tar")
347+
|| lower.equals("application/vnd.android.package-archive");
348+
}
349+
350+
public static boolean isZip(ServerFileInterface file) {
351+
return isZip(file.getMimeType());
352+
}
353+
333354
/**
334355
* Extracts the mime type for the given file.
335356
*

0 commit comments

Comments
 (0)