fix #440, show folders at search results too

This commit is contained in:
tibbi 2021-01-16 12:16:23 +01:00
parent cbd092862f
commit af82cc5119
2 changed files with 19 additions and 3 deletions

View File

@ -706,7 +706,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
if (listItem.isSectionTitle) {
item_icon.setImageDrawable(folderDrawable)
item_section.text = listItem.mName
item_section.text = if (textToHighlight.isEmpty()) listItem.mName else listItem.mName.highlightTextPart(textToHighlight, adjustedPrimaryColor)
item_section.setTextColor(textColor)
item_section.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
} else {

View File

@ -346,12 +346,21 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
var previousParent = ""
files.forEach {
val parent = it.mPath.getParentPath()
if (parent != previousParent && context != null) {
if (!it.isDirectory && parent != previousParent && context != null) {
val sectionTitle = ListItem(parent, context!!.humanizePath(parent), false, 0, 0, 0, true)
listItems.add(sectionTitle)
previousParent = parent
}
listItems.add(it)
if (it.isDirectory) {
val sectionTitle = ListItem(it.path, context!!.humanizePath(it.path), true, 0, 0, 0, true)
listItems.add(sectionTitle)
previousParent = parent
}
if (!it.isDirectory) {
listItems.add(it)
}
}
activity?.runOnUiThread {
@ -378,6 +387,13 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
val isSortingBySize = sorting and SORT_BY_SIZE != 0
File(path).listFiles()?.sortedBy { it.isDirectory }?.forEach {
if (it.isDirectory) {
if (it.name.contains(text, true)) {
val fileDirItem = getFileDirItemFromFile(it, isSortingBySize, HashMap<String, Long>(), false)
if (fileDirItem != null) {
files.add(fileDirItem)
}
}
files.addAll(searchFiles(text, it.absolutePath))
} else {
if (it.name.contains(text, true)) {