From 3e7d67a3a2317b98ff3db5901f9c6fdcdc62e362 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 24 Oct 2017 22:57:04 +0200 Subject: [PATCH] update commons, use our custom map for determining file mimetype --- app/build.gradle | 2 +- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 2 +- .../com/simplemobiletools/gallery/extensions/activity.kt | 2 +- .../kotlin/com/simplemobiletools/gallery/models/Medium.kt | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 44b5233f4..4296e2ac2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.31.4' + compile 'com.simplemobiletools:commons:2.31.10' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' 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 ef6cae120..08a8aafbd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -480,7 +480,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun fillIntentPath(resultData: Intent, resultIntent: Intent) { val path = resultData.data.path val uri = Uri.fromFile(File(path)) - val type = File(path).getMimeType("image/jpeg") + val type = path.getMimeTypeFromPath() resultIntent.setDataAndTypeAndNormalize(uri, type) resultIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt index a856ca11f..4fe4d6180 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -88,7 +88,7 @@ fun Activity.setAs(uri: Uri, file: File, showToast: Boolean = true): Boolean { var success = false Intent().apply { action = Intent.ACTION_ATTACH_DATA - setDataAndType(uri, file.getMimeType("image/*")) + setDataAndType(uri, file.getMimeType()) addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) val chooser = Intent.createChooser(this, getString(R.string.set_as)) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt index fadf715ea..bf15cd20c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt @@ -1,10 +1,9 @@ package com.simplemobiletools.gallery.models -import com.simplemobiletools.commons.extensions.getMimeType +import com.simplemobiletools.commons.extensions.getMimeTypeFromPath import com.simplemobiletools.commons.extensions.isGif import com.simplemobiletools.commons.extensions.isPng import com.simplemobiletools.commons.helpers.* -import java.io.File import java.io.Serializable data class Medium(var name: String, var path: String, val video: Boolean, val modified: Long, val taken: Long, val size: Long) : Serializable, Comparable { @@ -21,7 +20,7 @@ data class Medium(var name: String, var path: String, val video: Boolean, val mo fun isImage() = !isGif() && !video - fun getMimeType() = File(path).getMimeType() + fun getMimeType() = path.getMimeTypeFromPath() override fun compareTo(other: Medium): Int { var result: Int