From: David A. Velasco Date: Fri, 1 Mar 2013 13:55:59 +0000 (+0100) Subject: File#isImage() considers the name of the file, besides the knowledge from server X-Git-Tag: oc-android-1.4.3~39^2~22 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/a212611a9b3f81667db038745fab08b3059cdd11 File#isImage() considers the name of the file, besides the knowledge from server --- diff --git a/src/com/owncloud/android/datamodel/OCFile.java b/src/com/owncloud/android/datamodel/OCFile.java index c9e2b17a..2ae09a50 100644 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@ -20,9 +20,12 @@ package com.owncloud.android.datamodel; import java.io.File; +import android.content.Intent; +import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; +import android.webkit.MimeTypeMap; public class OCFile implements Parcelable, Comparable { @@ -466,7 +469,18 @@ public class OCFile implements Parcelable, Comparable { /** @return 'True' if the file contains an image */ public boolean isImage() { - return (mMimeType != null && mMimeType.startsWith("image/")); + return ((mMimeType != null && mMimeType.startsWith("image/")) || + getMimeTypeFromName().startsWith("image/")); + } + + public String getMimeTypeFromName() { + String extension = ""; + int pos = mRemotePath.lastIndexOf('.'); + if (pos >= 0) { + extension = mRemotePath.substring(pos + 1); + } + String result = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase()); + return (result != null) ? result : ""; } }