delete/copy/move only the visible files at doing those operations on a folder

This commit is contained in:
tibbi 2018-12-02 16:46:32 +01:00
parent f1daf5fbcf
commit f751adcd97
3 changed files with 29 additions and 5 deletions

View File

@ -57,7 +57,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:5.5.2' implementation 'com.simplemobiletools:commons:5.5.4'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'androidx.multidex:multidex:2.0.0' implementation 'androidx.multidex:multidex:2.0.0'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'

View File

@ -497,9 +497,18 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
if (config.useRecycleBin) { if (config.useRecycleBin) {
val pathsToDelete = ArrayList<String>() val pathsToDelete = ArrayList<String>()
val filter = config.filterMedia
val showHidden = config.shouldShowHidden
fileDirItems.filter { it.isDirectory }.forEach { fileDirItems.filter { it.isDirectory }.forEach {
val files = File(it.path).listFiles() val files = File(it.path).listFiles()
files?.filter { it.absolutePath.isMediaFile() }?.mapTo(pathsToDelete) { it.absolutePath } files?.filter {
it.absolutePath.isMediaFile() && (showHidden || !it.name.startsWith('.')) &&
((it.isImageFast() && filter and TYPE_IMAGES != 0) ||
(it.isVideoFast() && filter and TYPE_VIDEOS != 0) ||
(it.isGif() && filter and TYPE_GIFS != 0) ||
(it.isRawFast() && filter and TYPE_RAWS != 0) ||
(it.isSvg() && filter and TYPE_SVGS != 0))
}?.mapTo(pathsToDelete) { it.absolutePath }
} }
movePathsInRecycleBin(pathsToDelete, mMediumDao) { movePathsInRecycleBin(pathsToDelete, mMediumDao) {

View File

@ -323,8 +323,15 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
if (it.startsWith(OTG_PATH)) { if (it.startsWith(OTG_PATH)) {
paths.addAll(getOTGFilePaths(it, showHidden)) paths.addAll(getOTGFilePaths(it, showHidden))
} else if (it != FAVORITES) { } else if (it != FAVORITES) {
val filter = config.filterMedia
File(it).listFiles()?.filter { File(it).listFiles()?.filter {
!activity.getIsPathDirectory(it.absolutePath) && it.isMediaFile() && (showHidden || !it.name.startsWith('.')) !activity.getIsPathDirectory(it.absolutePath) &&
it.absolutePath.isMediaFile() && (showHidden || !it.name.startsWith('.')) &&
((it.isImageFast() && filter and TYPE_IMAGES != 0) ||
(it.isVideoFast() && filter and TYPE_VIDEOS != 0) ||
(it.isGif() && filter and TYPE_GIFS != 0) ||
(it.isRawFast() && filter and TYPE_RAWS != 0) ||
(it.isSvg() && filter and TYPE_SVGS != 0))
}?.mapTo(paths) { it.absolutePath } }?.mapTo(paths) { it.absolutePath }
} }
} }
@ -339,8 +346,16 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
private fun getOTGFilePaths(path: String, showHidden: Boolean): ArrayList<String> { private fun getOTGFilePaths(path: String, showHidden: Boolean): ArrayList<String> {
val paths = ArrayList<String>() val paths = ArrayList<String>()
activity.getOTGFolderChildren(path)?.forEach { val filter = config.filterMedia
if (!it.isDirectory && it.name!!.isMediaFile() && (showHidden || !it.name!!.startsWith('.'))) { activity.getOTGFolderChildren(path)?.filter { it.name != null }?.forEach {
if (!it.isDirectory &&
it.name!!.isMediaFile() && (showHidden || !it.name!!.startsWith('.')) &&
((it.name!!.isImageFast() && filter and TYPE_IMAGES != 0) ||
(it.name!!.isVideoFast() && filter and TYPE_VIDEOS != 0) ||
(it.name!!.isGif() && filter and TYPE_GIFS != 0) ||
(it.name!!.isRawFast() && filter and TYPE_RAWS != 0) ||
(it.name!!.isSvg() && filter and TYPE_SVGS != 0))
) {
val relativePath = it.uri.path.substringAfterLast("${activity.config.OTGPartition}:") val relativePath = it.uri.path.substringAfterLast("${activity.config.OTGPartition}:")
paths.add("$OTG_PATH$relativePath") paths.add("$OTG_PATH$relativePath")
} }