removing a few more functions related to special OTG file handling
This commit is contained in:
parent
10c85cefab
commit
0136b557da
4 changed files with 15 additions and 52 deletions
|
@ -1034,7 +1034,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
if (!File(it.path).exists()) {
|
||||
invalidDirs.add(it)
|
||||
} else if (it.path != config.tempFolderPath) {
|
||||
val children = if (isPathOnOTG(it.path)) getOTGFolderChildrenNames(it.path) else File(it.path).list()?.asList()
|
||||
val children = File(it.path).list()?.asList()
|
||||
val hasMediaFile = children?.any { it?.isMediaFile() == true } ?: false
|
||||
if (!hasMediaFile) {
|
||||
invalidDirs.add(it)
|
||||
|
|
|
@ -320,20 +320,16 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
val paths = ArrayList<String>()
|
||||
val showHidden = activity.config.shouldShowHidden
|
||||
getSelectedPaths().forEach {
|
||||
if (activity.isPathOnOTG(it)) {
|
||||
paths.addAll(getOTGFilePaths(it, showHidden))
|
||||
} else if (it != FAVORITES) {
|
||||
val filter = config.filterMedia
|
||||
File(it).listFiles()?.filter {
|
||||
!File(it.absolutePath).isDirectory &&
|
||||
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 }
|
||||
}
|
||||
val filter = config.filterMedia
|
||||
File(it).listFiles()?.filter {
|
||||
!File(it.absolutePath).isDirectory &&
|
||||
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 }
|
||||
}
|
||||
|
||||
val fileDirItems = paths.map { FileDirItem(it, it.getFilenameFromPath()) } as ArrayList<FileDirItem>
|
||||
|
@ -344,25 +340,6 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
}
|
||||
}
|
||||
|
||||
private fun getOTGFilePaths(path: String, showHidden: Boolean): ArrayList<String> {
|
||||
val paths = ArrayList<String>()
|
||||
val filter = config.filterMedia
|
||||
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}:")
|
||||
paths.add("${config.OTGPath}/$relativePath")
|
||||
}
|
||||
}
|
||||
return paths
|
||||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
when {
|
||||
config.isDeletePasswordProtectionOn -> activity.handleDeletePasswordProtection {
|
||||
|
|
|
@ -594,10 +594,6 @@ fun Context.updateDBDirectory(directory: Directory, directoryDao: DirectoryDao)
|
|||
directoryDao.updateDirectory(directory.path, directory.tmb, directory.mediaCnt, directory.modified, directory.taken, directory.size, directory.types)
|
||||
}
|
||||
|
||||
fun Context.getOTGFolderChildren(path: String) = getDocumentFile(path)?.listFiles()
|
||||
|
||||
fun Context.getOTGFolderChildrenNames(path: String) = getOTGFolderChildren(path)?.map { it.name }?.toMutableList()
|
||||
|
||||
fun Context.getFavoritePaths() = galleryDB.MediumDao().getFavoritePaths() as ArrayList<String>
|
||||
|
||||
// remove the "recycle_bin" from the file path prefix, replace it with real bin path /data/user...
|
||||
|
|
|
@ -146,20 +146,10 @@ class MediaFetcher(val context: Context) {
|
|||
|
||||
private fun addFolder(curFolders: ArrayList<String>, folder: String) {
|
||||
curFolders.add(folder)
|
||||
if (context.isPathOnOTG(folder)) {
|
||||
val files = context.getOTGFolderChildren(folder) ?: return
|
||||
for (file in files) {
|
||||
if (file.isDirectory) {
|
||||
val relativePath = file.uri.path.substringAfterLast("${context.config.OTGPartition}:")
|
||||
addFolder(curFolders, "${context.config.OTGPath}/$relativePath")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val files = File(folder).listFiles() ?: return
|
||||
for (file in files) {
|
||||
if (file.isDirectory) {
|
||||
addFolder(curFolders, file.absolutePath)
|
||||
}
|
||||
val files = File(folder).listFiles() ?: return
|
||||
for (file in files) {
|
||||
if (file.isDirectory) {
|
||||
addFolder(curFolders, file.absolutePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue