diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index 70265732b..bfda0f48c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -63,7 +63,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } saveUri = when { - intent.extras?.containsKey(REAL_FILE_PATH) == true -> Uri.fromFile(File(intent.extras.get(REAL_FILE_PATH) as String)) + intent.extras?.containsKey(REAL_FILE_PATH) == true -> { + val realPath = intent.extras.get(REAL_FILE_PATH) as String + if (isPathOnOTG(realPath)) { + Uri.parse(realPath) + } else { + Uri.fromFile(File(realPath)) + } + } intent.extras?.containsKey(MediaStore.EXTRA_OUTPUT) == true -> intent.extras!!.get(MediaStore.EXTRA_OUTPUT) as Uri else -> uri } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index 1a67e6333..3305f0086 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -59,7 +59,10 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList private fun checkIntent(savedInstanceState: Bundle? = null) { mUri = intent.data ?: return if (intent.extras?.containsKey(REAL_FILE_PATH) == true) { - mUri = Uri.fromFile(File(intent.extras.get(REAL_FILE_PATH) as String)) + val realPath = intent.extras.get(REAL_FILE_PATH) as String + if (!isPathOnOTG(realPath)) { + mUri = Uri.fromFile(File(realPath)) + } } mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index fc07bcca2..55b9269bc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -23,7 +23,6 @@ import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST import com.simplemobiletools.gallery.models.Medium import kotlinx.android.synthetic.main.photo_video_item_grid.view.* -import java.io.File class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, val listener: MediaOperationsListener?, val isAGetIntent: Boolean, val allowMultiplePicks: Boolean, recyclerView: MyRecyclerView, fastScroller: FastScroller? = null, @@ -217,8 +216,6 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, private fun getCurrentPath() = media[selectedPositions.first()].path - private fun getCurrentFile() = File(getCurrentPath()) - private fun deleteFiles() { val fileDirItems = ArrayList(selectedPositions.size) val removeMedia = ArrayList(selectedPositions.size) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index 3621bb8b6..719d96721 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -217,7 +217,7 @@ class MediaFetcher(val context: Context) { if (directories.containsKey(parentDir)) { directories[parentDir]!!.add(medium) } else { - directories.put(parentDir, arrayListOf(medium)) + directories[parentDir] = arrayListOf(medium) } } return directories