fix copying folders from OTG devices
This commit is contained in:
parent
a24050c98d
commit
71a378d5bd
2 changed files with 21 additions and 5 deletions
|
@ -47,7 +47,7 @@ ext {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||||
implementation 'com.android.support:multidex:1.0.3'
|
implementation 'com.android.support:multidex:1.0.3'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
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.PropertiesDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.commons.views.FastScroller
|
import com.simplemobiletools.commons.views.FastScroller
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
|
@ -279,10 +280,14 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||||
val paths = ArrayList<String>()
|
val paths = ArrayList<String>()
|
||||||
selectedPositions.forEach {
|
selectedPositions.forEach {
|
||||||
val dir = File(dirs[it].path)
|
val childrenPaths = ArrayList<String>()
|
||||||
val childrenFiles = dir.listFiles()?.filter { !activity.getIsPathDirectory(it.absolutePath) && it.absolutePath.isImageVideoGif() }?.map { it.absolutePath }
|
val path = dirs[it].path
|
||||||
?: ArrayList<String>()
|
if (path.startsWith(OTG_PATH)) {
|
||||||
paths.addAll(childrenFiles)
|
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>
|
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() {
|
private fun askConfirmDelete() {
|
||||||
if (config.skipDeleteConfirmation) {
|
if (config.skipDeleteConfirmation) {
|
||||||
deleteFiles()
|
deleteFiles()
|
||||||
|
|
Loading…
Reference in a new issue