use the filepickers getmimetype function instead of a custom one

This commit is contained in:
tibbi 2016-12-04 15:17:32 +01:00
parent 489e284dc2
commit 9ff47e6b6f
2 changed files with 2 additions and 10 deletions

View File

@ -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
""
}
}
}

View File

@ -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) {