mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
use the filepickers getmimetype function instead of a custom one
This commit is contained in:
parent
489e284dc2
commit
9ff47e6b6f
2 changed files with 2 additions and 10 deletions
|
@ -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
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue