mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-01-21 23:35:25 +01:00
fix copying folders from OTG devices
This commit is contained in:
parent
a24050c98d
commit
71a378d5bd
@ -47,7 +47,7 @@ ext {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.19.20'
|
||||
implementation 'com.simplemobiletools:commons:3.19.21'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||
|
@ -12,6 +12,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
@ -279,10 +280,14 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||
val paths = ArrayList<String>()
|
||||
selectedPositions.forEach {
|
||||
val dir = File(dirs[it].path)
|
||||
val childrenFiles = dir.listFiles()?.filter { !activity.getIsPathDirectory(it.absolutePath) && it.absolutePath.isImageVideoGif() }?.map { it.absolutePath }
|
||||
?: ArrayList<String>()
|
||||
paths.addAll(childrenFiles)
|
||||
val childrenPaths = ArrayList<String>()
|
||||
val path = dirs[it].path
|
||||
if (path.startsWith(OTG_PATH)) {
|
||||
paths.addAll(getOTGFilePaths(path))
|
||||
} else {
|
||||
File(path).list()?.filter { !activity.getIsPathDirectory(it) && it.isImageVideoGif() }?.mapTo(childrenPaths, { it })
|
||||
}
|
||||
paths.addAll(childrenPaths)
|
||||
}
|
||||
|
||||
val fileDirItems = paths.map { FileDirItem(it, it.getFilenameFromPath()) } as ArrayList<FileDirItem>
|
||||
@ -293,6 +298,17 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOTGFilePaths(path: String): ArrayList<String> {
|
||||
val paths = ArrayList<String>()
|
||||
activity.getOTGFolderChildren(path)?.forEach {
|
||||
if (!it.isDirectory && it.name.isImageVideoGif()) {
|
||||
val relativePath = it.uri.path.substringAfterLast("${activity.config.OTGPartition}:")
|
||||
paths.add("$OTG_PATH$relativePath")
|
||||
}
|
||||
}
|
||||
return paths
|
||||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
if (config.skipDeleteConfirmation) {
|
||||
deleteFiles()
|
||||
|
Loading…
Reference in New Issue
Block a user