Skip to content

Commit af82cc5

Browse files
committed
fix #440, show folders at search results too
1 parent cbd0928 commit af82cc5

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
706706
if (listItem.isSectionTitle) {
707707
item_icon.setImageDrawable(folderDrawable)
708708

709-
item_section.text = listItem.mName
709+
item_section.text = if (textToHighlight.isEmpty()) listItem.mName else listItem.mName.highlightTextPart(textToHighlight, adjustedPrimaryColor)
710710
item_section.setTextColor(textColor)
711711
item_section.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
712712
} else {

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,21 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
346346
var previousParent = ""
347347
files.forEach {
348348
val parent = it.mPath.getParentPath()
349-
if (parent != previousParent && context != null) {
349+
if (!it.isDirectory && parent != previousParent && context != null) {
350350
val sectionTitle = ListItem(parent, context!!.humanizePath(parent), false, 0, 0, 0, true)
351351
listItems.add(sectionTitle)
352352
previousParent = parent
353353
}
354-
listItems.add(it)
354+
355+
if (it.isDirectory) {
356+
val sectionTitle = ListItem(it.path, context!!.humanizePath(it.path), true, 0, 0, 0, true)
357+
listItems.add(sectionTitle)
358+
previousParent = parent
359+
}
360+
361+
if (!it.isDirectory) {
362+
listItems.add(it)
363+
}
355364
}
356365

357366
activity?.runOnUiThread {
@@ -378,6 +387,13 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
378387
val isSortingBySize = sorting and SORT_BY_SIZE != 0
379388
File(path).listFiles()?.sortedBy { it.isDirectory }?.forEach {
380389
if (it.isDirectory) {
390+
if (it.name.contains(text, true)) {
391+
val fileDirItem = getFileDirItemFromFile(it, isSortingBySize, HashMap<String, Long>(), false)
392+
if (fileDirItem != null) {
393+
files.add(fileDirItem)
394+
}
395+
}
396+
381397
files.addAll(searchFiles(text, it.absolutePath))
382398
} else {
383399
if (it.name.contains(text, true)) {

0 commit comments

Comments
 (0)