do not modify real_file_path if it points to an OTG device

This commit is contained in:
tibbi 2018-02-19 23:09:49 +01:00
parent cc06109649
commit 2083865c98
4 changed files with 13 additions and 6 deletions

View file

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

View file

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

View file

@ -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<Medium>, 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<Medium>,
private fun getCurrentPath() = media[selectedPositions.first()].path
private fun getCurrentFile() = File(getCurrentPath())
private fun deleteFiles() {
val fileDirItems = ArrayList<FileDirItem>(selectedPositions.size)
val removeMedia = ArrayList<Medium>(selectedPositions.size)

View file

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