From 0cb8d46337981c6de1baa8d4745475a6b3286539 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 28 Aug 2019 18:54:43 +0200 Subject: [PATCH 1/4] update to Nc17 defined mimetype list Signed-off-by: Andy Scherzinger --- drawable_resources/link.svg | 1 + drawable_resources/location.svg | 1 + .../owncloud/android/utils/MimeTypeUtil.java | 59 +++++++++++++++++++ src/main/res/drawable/file_link.xml | 4 ++ src/main/res/drawable/file_location.xml | 7 +++ 5 files changed, 72 insertions(+) create mode 100644 drawable_resources/link.svg create mode 100644 drawable_resources/location.svg create mode 100644 src/main/res/drawable/file_link.xml create mode 100644 src/main/res/drawable/file_location.xml diff --git a/drawable_resources/link.svg b/drawable_resources/link.svg new file mode 100644 index 0000000000..7bfbe1eb2d --- /dev/null +++ b/drawable_resources/link.svg @@ -0,0 +1 @@ + diff --git a/drawable_resources/location.svg b/drawable_resources/location.svg new file mode 100644 index 0000000000..5e63f7563c --- /dev/null +++ b/drawable_resources/location.svg @@ -0,0 +1 @@ + diff --git a/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java b/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java index 0771c2cd22..db1272fb1c 100644 --- a/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java +++ b/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java @@ -417,11 +417,15 @@ public final class MimeTypeUtil { MIMETYPE_TO_ICON_MAPPING.put("application/epub+zip", R.drawable.file_text); MIMETYPE_TO_ICON_MAPPING.put("application/font-sfnt", R.drawable.file_image); MIMETYPE_TO_ICON_MAPPING.put("application/font-woff", R.drawable.file_image); + MIMETYPE_TO_ICON_MAPPING.put("application/gpx+xml", R.drawable.file_location); MIMETYPE_TO_ICON_MAPPING.put("application/illustrator", R.drawable.file_image); + MIMETYPE_TO_ICON_MAPPING.put("application/internet-shortcut", R.drawable.file_link); + MIMETYPE_TO_ICON_MAPPING.put("application/java", R.drawable.file_application); MIMETYPE_TO_ICON_MAPPING.put("application/javascript", R.drawable.file_code); MIMETYPE_TO_ICON_MAPPING.put("application/json", R.drawable.file_code); MIMETYPE_TO_ICON_MAPPING.put("application/msaccess", R.drawable.file); MIMETYPE_TO_ICON_MAPPING.put("application/msexcel", R.drawable.file_xls); + MIMETYPE_TO_ICON_MAPPING.put("application/msonenote", R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/mspowerpoint", R.drawable.file_ppt); MIMETYPE_TO_ICON_MAPPING.put("application/msword", R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/octet-stream", R.drawable.file); @@ -430,6 +434,10 @@ public final class MimeTypeUtil { MIMETYPE_TO_ICON_MAPPING.put("application/rss+xml", R.drawable.file_code); MIMETYPE_TO_ICON_MAPPING.put("application/rtf", R.drawable.file); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.android.package-archive", R.drawable.file_zip); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.garmin.tcx+xml", R.drawable.file_location); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.google-earth.kml+xml", R.drawable.file_location); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.google-earth.kmz", R.drawable.file_location); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.lotus-wordpro", R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-excel", R.drawable.file_xls); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-excel.addin.macroEnabled.12", R.drawable.file_xls); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-excel.sheet.binary.macroEnabled.12", R.drawable.file_xls); @@ -441,6 +449,12 @@ public final class MimeTypeUtil { MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-powerpoint.presentation.macroEnabled.12", R.drawable.file_ppt); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-powerpoint.slideshow.macroEnabled.12", R.drawable.file_ppt); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-powerpoint.template.macroEnabled.12", R.drawable.file_ppt); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-visio.drawing.macroEnabled.12", R.drawable.file_doc); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-visio.drawing", R.drawable.file_doc); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-visio.stencil.macroEnabled.12", R.drawable.file_doc); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-visio.stencil", R.drawable.file_doc); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-visio.template.macroEnabled.12", R.drawable.file_doc); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-visio.template", R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-word.document.macroEnabled.12", R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.ms-word.template.macroEnabled.12", R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.oasis.opendocument.presentation", R.drawable.file_ppt); @@ -458,16 +472,22 @@ public final class MimeTypeUtil { MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.spreadsheetml.template", R.drawable.file_xls); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.wordprocessingml.document", R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/vnd.openxmlformats-officedocument.wordprocessingml.template", R.drawable.file_doc); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.visio", R.drawable.file_doc); + MIMETYPE_TO_ICON_MAPPING.put("application/vnd.wordperfect", R.drawable.file_doc); MIMETYPE_TO_ICON_MAPPING.put("application/x-7z-compressed", R.drawable.file_zip); MIMETYPE_TO_ICON_MAPPING.put("application/x-bin", R.drawable.file_application); + MIMETYPE_TO_ICON_MAPPING.put("application/x-bzip2", R.drawable.file_zip); MIMETYPE_TO_ICON_MAPPING.put("application/x-cbr", R.drawable.file_text); MIMETYPE_TO_ICON_MAPPING.put("application/x-compressed", R.drawable.file_zip); MIMETYPE_TO_ICON_MAPPING.put("application/x-dcraw", R.drawable.file_image); MIMETYPE_TO_ICON_MAPPING.put("application/x-deb", R.drawable.file_zip); + MIMETYPE_TO_ICON_MAPPING.put("application/x-fictionbook+xml", R.drawable.file_text); MIMETYPE_TO_ICON_MAPPING.put("application/x-font", R.drawable.file_image); MIMETYPE_TO_ICON_MAPPING.put("application/x-gimp", R.drawable.file_image); MIMETYPE_TO_ICON_MAPPING.put("application/x-gzip", R.drawable.file_zip); + MIMETYPE_TO_ICON_MAPPING.put("application/x-mobipocket-ebook", R.drawable.file_text); MIMETYPE_TO_ICON_MAPPING.put("application/x-ms-dos-executable", R.drawable.file_application); + MIMETYPE_TO_ICON_MAPPING.put("application/x-msdos-program", R.drawable.file_application); MIMETYPE_TO_ICON_MAPPING.put("application/x-msi", R.drawable.file_application); MIMETYPE_TO_ICON_MAPPING.put("application/x-iwork-numbers-sffnumbers", R.drawable.file_xls); MIMETYPE_TO_ICON_MAPPING.put("application/x-iwork-keynote-sffkey", R.drawable.file_ppt); @@ -494,6 +514,8 @@ public final class MimeTypeUtil { MIMETYPE_TO_ICON_MAPPING.put("text/x-c", R.drawable.file_code); MIMETYPE_TO_ICON_MAPPING.put("text/x-c++src", R.drawable.file_code); MIMETYPE_TO_ICON_MAPPING.put("text/x-h", R.drawable.file_code); + MIMETYPE_TO_ICON_MAPPING.put("text/x-java-source", R.drawable.file_code); + MIMETYPE_TO_ICON_MAPPING.put("text/x-ldif", R.drawable.file_code); MIMETYPE_TO_ICON_MAPPING.put("text/x-python", R.drawable.file_code); MIMETYPE_TO_ICON_MAPPING.put("text/x-shellscript", R.drawable.file_code); MIMETYPE_TO_ICON_MAPPING.put("web", R.drawable.file_code); @@ -525,10 +547,12 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("arw", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("avi", Collections.singletonList("video/x-msvideo")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bash", Collections.singletonList("text/x-shellscript")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bat", Collections.singletonList("application/x-msdos-program")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("blend", Collections.singletonList("application/x-blender")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bin", Collections.singletonList("application/x-bin")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bmp", Collections.singletonList("image/bmp")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bpg", Collections.singletonList("image/bpg")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("bz2", Collections.singletonList("application/x-bzip2")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cb7", Collections.singletonList("application/x-cbr")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cba", Collections.singletonList("application/x-cbr")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cbr", Collections.singletonList("application/x-cbr")); @@ -537,6 +561,7 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cbz", Collections.singletonList("application/x-cbr")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cc", Collections.singletonList("text/x-c")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cdr", Collections.singletonList("application/coreldraw")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("class", Collections.singletonList("application/java")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cnf", Collections.singletonList("text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("conf", Collections.singletonList("text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("cpp", Collections.singletonList("text/x-c++src")); @@ -560,19 +585,27 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("eps", Collections.singletonList("application/postscript")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("erf", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("exe", Collections.singletonList("application/x-ms-dos-executable")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("fb2", Arrays.asList("application/x-fictionbook+xml", "text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("flac", Collections.singletonList("audio/flac")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("flv", Collections.singletonList("video/x-flv")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("gif", Collections.singletonList("image/gif")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("gpx", Collections.singletonList("application/gpx+xml")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("gz", Collections.singletonList("application/gzip")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("gzip", Collections.singletonList("application/gzip")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("h", Collections.singletonList("text/x-h")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("heic", Collections.singletonList("image/heic")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("heif", Collections.singletonList("image/heif")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("hh", Collections.singletonList("text/x-h")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("hpp", Collections.singletonList("text/x-h")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("htaccess", Collections.singletonList("text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("html", Arrays.asList("text/html", "text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("htm", Arrays.asList("text/html", "text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ical", Collections.singletonList("text/calendar")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ics", Collections.singletonList("text/calendar")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("iiq", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("impress", Collections.singletonList("text/impress")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("java", Collections.singletonList("text/x-java-source")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("jp2", Collections.singletonList("image/jp2")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("jpeg", Collections.singletonList("image/jpeg")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("jpg", Collections.singletonList("image/jpeg")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("jps", Collections.singletonList("image/jpeg")); @@ -582,8 +615,16 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("kdc", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("key", Collections.singletonList("application/x-iwork-keynote-sffkey")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("keynote", Collections.singletonList("application/x-iwork-keynote-sffkey")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("kml", Collections.singletonList("application/vnd.google-earth.kml+xml")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("kmz", Collections.singletonList("application/vnd.google-earth.kmz")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("kra", Collections.singletonList("application/x-krita")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ldif", Collections.singletonList("text/x-ldif")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("lwp", Collections.singletonList("application/vnd.lotus-wordpro")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m2t", Collections.singletonList("video/mp2t")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m3u", Collections.singletonList("audio/mpegurl")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m3u8", Collections.singletonList("audio/mpegurl")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m4a", Collections.singletonList("audio/mp4")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m4b", Collections.singletonList("audio/m4b")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m4v", Collections.singletonList("video/mp4")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("markdown", Collections.singletonList("text/markdown")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("mdown", Collections.singletonList("text/markdown")); @@ -613,6 +654,7 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("oga", Collections.singletonList("audio/ogg")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ogg", Collections.singletonList("audio/ogg")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ogv", Collections.singletonList("video/ogg")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("one", Collections.singletonList("application/msonenote")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("opus", Collections.singletonList("audio/ogg")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("orf", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("otf", Collections.singletonList("application/font-sfnt")); @@ -622,6 +664,7 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pef", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("php", Collections.singletonList("application/x-php")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pl", Collections.singletonList("application/x-perl")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pls", Collections.singletonList("audio/x-scpls")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("png", Collections.singletonList("image/png")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("pot", Collections.singletonList("application/vnd.ms-powerpoint")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("potm", Collections.singletonList("application/vnd.ms-powerpoint.template.macroEnabled.12")); @@ -640,8 +683,10 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("raf", Collections.singletonList("image/x-dcraw")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("rar", Collections.singletonList("application/x-rar-compressed")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("reveal", Collections.singletonList("text/reveal")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("rss", Collections.singletonList("application/rss+xml")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("rtf", Collections.singletonList("application/rtf")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("rw2", Collections.singletonList("image/x-dcraw")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("schema", Collections.singletonList("text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("sgf", Collections.singletonList("application/sgf")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("sh-lib", Collections.singletonList("text/x-shellscript")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("sh", Collections.singletonList("text/x-shellscript")); @@ -650,6 +695,10 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("svg", Arrays.asList("image/svg+xml", "text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("swf", Arrays.asList("application/x-shockwave-flash", "application/octet-stream")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tar", Collections.singletonList("application/x-tar")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tar.bz2", Collections.singletonList("application/x-bzip2")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tar.gz", Collections.singletonList("application/x-compressed")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tbz2", Collections.singletonList("application/x-bzip2")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tcx", Collections.singletonList("application/vnd.garmin.tcx+xml")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tex", Collections.singletonList("application/x-tex")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tgz", Collections.singletonList("application/x-compressed")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("tiff", Collections.singletonList("image/tiff")); @@ -659,9 +708,17 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vcard", Collections.singletonList("text/vcard")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vcf", Collections.singletonList("text/vcard")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vob", Collections.singletonList("video/dvd")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vsd", Collections.singletonList("application/vnd.visio")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vsdm", Collections.singletonList("application/vnd.ms-visio.drawing.macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vsdx", Collections.singletonList("application/vnd.ms-visio.drawing")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vssm", Collections.singletonList("application/vnd.ms-visio.stencil.macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vssx", Collections.singletonList("application/vnd.ms-visio.stencil")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vstm", Collections.singletonList("application/vnd.ms-visio.template.macroEnabled.12")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("vstx", Collections.singletonList("application/vnd.ms-visio.template")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("wav", Collections.singletonList("audio/wav")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("webm", Collections.singletonList("video/webm")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("woff", Collections.singletonList("application/font-woff")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("wpd", Collections.singletonList("application/vnd.wordperfect")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("wmv", Collections.singletonList("video/x-ms-wmv")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xcf", Collections.singletonList("application/x-gimp")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("xla", Collections.singletonList("application/vnd.ms-excel")); @@ -678,5 +735,7 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("yaml", Arrays.asList("application/yaml", "text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("yml", Arrays.asList("application/yaml", "text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("zip", Collections.singletonList("application/zip")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("url", Collections.singletonList("application/internet-shortcut")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("webloc", Collections.singletonList("application/internet-shortcut")); } } diff --git a/src/main/res/drawable/file_link.xml b/src/main/res/drawable/file_link.xml new file mode 100644 index 0000000000..820cfa097f --- /dev/null +++ b/src/main/res/drawable/file_link.xml @@ -0,0 +1,4 @@ + + + diff --git a/src/main/res/drawable/file_location.xml b/src/main/res/drawable/file_location.xml new file mode 100644 index 0000000000..c3cff1f51f --- /dev/null +++ b/src/main/res/drawable/file_location.xml @@ -0,0 +1,7 @@ + + + + From bff6395e420db0ee60386e1a0595a81786aca0be Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 28 Aug 2019 18:58:08 +0200 Subject: [PATCH 2/4] Resolve #2073 adding a corresponding file-extension/mimetype mapping for .love files Signed-off-by: Andy Scherzinger --- src/main/java/com/owncloud/android/utils/MimeTypeUtil.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java b/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java index db1272fb1c..08d04e0f25 100644 --- a/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java +++ b/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java @@ -485,6 +485,7 @@ public final class MimeTypeUtil { MIMETYPE_TO_ICON_MAPPING.put("application/x-font", R.drawable.file_image); MIMETYPE_TO_ICON_MAPPING.put("application/x-gimp", R.drawable.file_image); MIMETYPE_TO_ICON_MAPPING.put("application/x-gzip", R.drawable.file_zip); + MIMETYPE_TO_ICON_MAPPING.put("application/x-love-game", R.drawable.file); MIMETYPE_TO_ICON_MAPPING.put("application/x-mobipocket-ebook", R.drawable.file_text); MIMETYPE_TO_ICON_MAPPING.put("application/x-ms-dos-executable", R.drawable.file_application); MIMETYPE_TO_ICON_MAPPING.put("application/x-msdos-program", R.drawable.file_application); @@ -619,6 +620,7 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("kmz", Collections.singletonList("application/vnd.google-earth.kmz")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("kra", Collections.singletonList("application/x-krita")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ldif", Collections.singletonList("text/x-ldif")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("love", Collections.singletonList("application/x-love-game")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("lwp", Collections.singletonList("application/vnd.lotus-wordpro")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m2t", Collections.singletonList("video/mp2t")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m3u", Collections.singletonList("audio/mpegurl")); From 2f30227cfad6e51fa0de0f0c7f8686c0f4593e36 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 28 Aug 2019 19:05:20 +0200 Subject: [PATCH 3/4] Resolve #2081 adding a corresponding file-extension/mimetype mapping for .m files Signed-off-by: Andy Scherzinger --- src/main/java/com/owncloud/android/utils/MimeTypeUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java b/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java index 08d04e0f25..8dca4cf807 100644 --- a/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java +++ b/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java @@ -622,6 +622,7 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ldif", Collections.singletonList("text/x-ldif")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("love", Collections.singletonList("application/x-love-game")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("lwp", Collections.singletonList("application/vnd.lotus-wordpro")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m", Collections.singletonList("text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m2t", Collections.singletonList("video/mp2t")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m3u", Collections.singletonList("audio/mpegurl")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m3u8", Collections.singletonList("audio/mpegurl")); From fba301b248eb844f463aec535258e092f170e67f Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 2 Sep 2019 23:57:55 +0200 Subject: [PATCH 4/4] improve mime type detection Signed-off-by: Andy Scherzinger --- .../owncloud/android/utils/MimeTypeUtil.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java b/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java index 8dca4cf807..1d4432aa5e 100644 --- a/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java +++ b/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java @@ -192,7 +192,10 @@ public final class MimeTypeUtil { * @return A single MIME type, "application/octet-stream" for unknown file extensions. */ public static String getBestMimeTypeByFilename(String filename) { - List candidates = determineMimeTypesByFilename(filename); + return getMimeTypeFromCandidates(determineMimeTypesByFilename(filename)); + } + + private static String getMimeTypeFromCandidates(List candidates) { if (candidates == null || candidates.size() < 1) { return "application/octet-stream"; } @@ -372,15 +375,23 @@ public final class MimeTypeUtil { * @return list of possible mime types (ordered), empty list in case no mime types found */ private static List determineMimeTypesByFilename(String filename) { - String fileExtension = getExtension(filename); + return determineMimeTypesByExtension(getExtension(filename)); + } + /** + * determines the list of possible mime types for the given file, based on its extension. + * + * @param extension the file extension + * @return list of possible mime types (ordered), empty list in case no mime types found + */ + private static List determineMimeTypesByExtension(String extension) { // try detecting the mimetype based on the web app logic equivalent - List mimeTypeList = FILE_EXTENSION_TO_MIMETYPE_MAPPING.get(fileExtension); + List mimeTypeList = FILE_EXTENSION_TO_MIMETYPE_MAPPING.get(extension); if (mimeTypeList != null && mimeTypeList.size() > 0) { return mimeTypeList; } else { // try detecting the mime type via android itself - String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension); + String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mimeType != null) { return Collections.singletonList(mimeType); } else { @@ -393,9 +404,17 @@ public final class MimeTypeUtil { String extension = ""; int pos = path.lastIndexOf('.'); if (pos >= 0) { - extension = path.substring(pos + 1); + extension = path.substring(pos + 1).toLowerCase(Locale.ROOT); } - String result = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase(Locale.ROOT)); + + // Ask OS for mimetype + String result = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + + // fallback to Nc mimetype mapping + if (result == null) { + result = getMimeTypeFromCandidates(determineMimeTypesByExtension(extension)); + } + return (result != null) ? result : ""; } @@ -622,7 +641,7 @@ public final class MimeTypeUtil { FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("ldif", Collections.singletonList("text/x-ldif")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("love", Collections.singletonList("application/x-love-game")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("lwp", Collections.singletonList("application/vnd.lotus-wordpro")); - FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m", Collections.singletonList("text/plain")); + FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m", Arrays.asList("text/x-matlab", "text/plain")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m2t", Collections.singletonList("video/mp2t")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m3u", Collections.singletonList("audio/mpegurl")); FILE_EXTENSION_TO_MIMETYPE_MAPPING.put("m3u8", Collections.singletonList("audio/mpegurl"));