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()) {
|
if (!File(it.path).exists()) {
|
||||||
invalidDirs.add(it)
|
invalidDirs.add(it)
|
||||||
} else if (it.path != config.tempFolderPath) {
|
} 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
|
val hasMediaFile = children?.any { it?.isMediaFile() == true } ?: false
|
||||||
if (!hasMediaFile) {
|
if (!hasMediaFile) {
|
||||||
invalidDirs.add(it)
|
invalidDirs.add(it)
|
||||||
|
|
|
@ -320,20 +320,16 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
val paths = ArrayList<String>()
|
val paths = ArrayList<String>()
|
||||||
val showHidden = activity.config.shouldShowHidden
|
val showHidden = activity.config.shouldShowHidden
|
||||||
getSelectedPaths().forEach {
|
getSelectedPaths().forEach {
|
||||||
if (activity.isPathOnOTG(it)) {
|
val filter = config.filterMedia
|
||||||
paths.addAll(getOTGFilePaths(it, showHidden))
|
File(it).listFiles()?.filter {
|
||||||
} else if (it != FAVORITES) {
|
!File(it.absolutePath).isDirectory &&
|
||||||
val filter = config.filterMedia
|
it.absolutePath.isMediaFile() && (showHidden || !it.name.startsWith('.')) &&
|
||||||
File(it).listFiles()?.filter {
|
((it.isImageFast() && filter and TYPE_IMAGES != 0) ||
|
||||||
!File(it.absolutePath).isDirectory &&
|
(it.isVideoFast() && filter and TYPE_VIDEOS != 0) ||
|
||||||
it.absolutePath.isMediaFile() && (showHidden || !it.name.startsWith('.')) &&
|
(it.isGif() && filter and TYPE_GIFS != 0) ||
|
||||||
((it.isImageFast() && filter and TYPE_IMAGES != 0) ||
|
(it.isRawFast() && filter and TYPE_RAWS != 0) ||
|
||||||
(it.isVideoFast() && filter and TYPE_VIDEOS != 0) ||
|
(it.isSvg() && filter and TYPE_SVGS != 0))
|
||||||
(it.isGif() && filter and TYPE_GIFS != 0) ||
|
}?.mapTo(paths) { it.absolutePath }
|
||||||
(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>
|
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() {
|
private fun askConfirmDelete() {
|
||||||
when {
|
when {
|
||||||
config.isDeletePasswordProtectionOn -> activity.handleDeletePasswordProtection {
|
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)
|
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>
|
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...
|
// 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) {
|
private fun addFolder(curFolders: ArrayList<String>, folder: String) {
|
||||||
curFolders.add(folder)
|
curFolders.add(folder)
|
||||||
if (context.isPathOnOTG(folder)) {
|
val files = File(folder).listFiles() ?: return
|
||||||
val files = context.getOTGFolderChildren(folder) ?: return
|
for (file in files) {
|
||||||
for (file in files) {
|
if (file.isDirectory) {
|
||||||
if (file.isDirectory) {
|
addFolder(curFolders, file.absolutePath)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue