From 9ff47e6b6f5e0cddd76bc9da10257c9f20bb347c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 4 Dec 2016 15:17:32 +0100 Subject: [PATCH] use the filepickers getmimetype function instead of a custom one --- .../main/kotlin/com/simplemobiletools/gallery/Utils.kt | 9 --------- .../simplemobiletools/gallery/activities/MainActivity.kt | 3 ++- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt index 4d89b4be6..0c3ca09d0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt @@ -9,7 +9,6 @@ import android.util.TypedValue import android.view.KeyCharacterMap import android.view.KeyEvent import android.view.ViewConfiguration -import android.webkit.MimeTypeMap class Utils { companion object { @@ -61,13 +60,5 @@ class Utils { !hasMenuKey && !hasBackKey } } - - fun getMimeType(url: String): String? { - val extension = MimeTypeMap.getFileExtensionFromUrl(url) - return if (extension != null) { - MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) - } else - "" - } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 820db1d4e..447296d79 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -18,6 +18,7 @@ import com.simplemobiletools.gallery.* import com.simplemobiletools.gallery.adapters.DirectoryAdapter import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog +import com.simplemobiletools.gallery.extensions.getImageMimeType import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.activity_main.* import java.io.File @@ -254,7 +255,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { val path = resultData.data.path val uri = Uri.fromFile(File(path)) if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) { - val type = Utils.getMimeType(path) ?: "" + val type = uri.getImageMimeType() setDataAndTypeAndNormalize(uri, type) flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION } else if (mIsPickImageIntent || mIsPickVideoIntent) {