do not modify real_file_path if it points to an OTG device
This commit is contained in:
parent
cc06109649
commit
2083865c98
4 changed files with 13 additions and 6 deletions
|
@ -63,7 +63,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
|
|
||||||
saveUri = when {
|
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
|
intent.extras?.containsKey(MediaStore.EXTRA_OUTPUT) == true -> intent.extras!!.get(MediaStore.EXTRA_OUTPUT) as Uri
|
||||||
else -> uri
|
else -> uri
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,10 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
private fun checkIntent(savedInstanceState: Bundle? = null) {
|
private fun checkIntent(savedInstanceState: Bundle? = null) {
|
||||||
mUri = intent.data ?: return
|
mUri = intent.data ?: return
|
||||||
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
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)
|
mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false)
|
||||||
|
|
|
@ -23,7 +23,6 @@ import com.simplemobiletools.gallery.extensions.*
|
||||||
import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST
|
import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import kotlinx.android.synthetic.main.photo_video_item_grid.view.*
|
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,
|
class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>, val listener: MediaOperationsListener?, val isAGetIntent: Boolean,
|
||||||
val allowMultiplePicks: Boolean, recyclerView: MyRecyclerView, fastScroller: FastScroller? = null,
|
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 getCurrentPath() = media[selectedPositions.first()].path
|
||||||
|
|
||||||
private fun getCurrentFile() = File(getCurrentPath())
|
|
||||||
|
|
||||||
private fun deleteFiles() {
|
private fun deleteFiles() {
|
||||||
val fileDirItems = ArrayList<FileDirItem>(selectedPositions.size)
|
val fileDirItems = ArrayList<FileDirItem>(selectedPositions.size)
|
||||||
val removeMedia = ArrayList<Medium>(selectedPositions.size)
|
val removeMedia = ArrayList<Medium>(selectedPositions.size)
|
||||||
|
|
|
@ -217,7 +217,7 @@ class MediaFetcher(val context: Context) {
|
||||||
if (directories.containsKey(parentDir)) {
|
if (directories.containsKey(parentDir)) {
|
||||||
directories[parentDir]!!.add(medium)
|
directories[parentDir]!!.add(medium)
|
||||||
} else {
|
} else {
|
||||||
directories.put(parentDir, arrayListOf(medium))
|
directories[parentDir] = arrayListOf(medium)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return directories
|
return directories
|
||||||
|
|
Loading…
Reference in a new issue