removing a few more functions related to special OTG file handling

This commit is contained in:
tibbi 2019-02-15 21:50:29 +01:00
parent 10c85cefab
commit 0136b557da
4 changed files with 15 additions and 52 deletions

View file

@ -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)

View file

@ -320,9 +320,6 @@ 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 &&
@ -334,7 +331,6 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
(it.isSvg() && filter and TYPE_SVGS != 0))
}?.mapTo(paths) { it.absolutePath }
}
}
val fileDirItems = paths.map { FileDirItem(it, it.getFilenameFromPath()) } as ArrayList<FileDirItem>
activity.tryCopyMoveFilesTo(fileDirItems, isCopyOperation) {
@ -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 {

View file

@ -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...

View file

@ -146,15 +146,6 @@ 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) {
@ -162,7 +153,6 @@ class MediaFetcher(val context: Context) {
}
}
}
}
private fun getMediaInFolder(folder: String, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int, getProperDateTaken: Boolean,
favoritePaths: ArrayList<String>, getVideoDurations: Boolean): ArrayList<Medium> {