diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt index cfbe7b31..1b978205 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt @@ -160,7 +160,7 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList + holder.bindView(fileDirItem, true, !fileDirItem.isSectionTitle) { itemView, layoutPosition -> setupView(itemView, fileDirItem) } bindViewHolder(holder) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt index 4808db5e..c1cc2bb2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt @@ -175,7 +175,12 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb storedItems = items ItemsAdapter(activity as SimpleActivity, storedItems, this@ItemsFragment, items_list, isPickMultipleIntent, items_fastscroller) { - itemClicked(it as FileDirItem) + if ((it as? ListItem)?.isSectionTitle == true) { + openDirectory(it.mPath) + searchClosed() + } else { + itemClicked(it as FileDirItem) + } }.apply { setupZoomListener(zoomListener) items_list.adapter = this @@ -278,11 +283,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb private fun itemClicked(item: FileDirItem) { if (item.isDirectory) { - (activity as? MainActivity)?.apply { - skipItemUpdating = isSearchOpen - openedDirectory() - } - openPath(item.path) + openDirectory(item.path) } else { val path = item.path if (isGetContentIntent) { @@ -299,6 +300,14 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb } } + private fun openDirectory(path: String) { + (activity as? MainActivity)?.apply { + skipItemUpdating = isSearchOpen + openedDirectory() + } + openPath(path) + } + fun searchQueryChanged(text: String) { val searchText = text.trim() lastSearchedText = searchText @@ -337,7 +346,8 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb files.forEach { val parent = it.mPath.getParentPath() if (parent != previousParent && context != null) { - listItems.add(ListItem("", context!!.humanizePath(parent), false, 0, 0, 0, true)) + val sectionTitle = ListItem(parent, context!!.humanizePath(parent), false, 0, 0, 0, true) + listItems.add(sectionTitle) previousParent = parent } listItems.add(it) diff --git a/app/src/main/res/layout/item_section.xml b/app/src/main/res/layout/item_section.xml index 19a7d654..8e631f6a 100644 --- a/app/src/main/res/layout/item_section.xml +++ b/app/src/main/res/layout/item_section.xml @@ -4,6 +4,7 @@ android:id="@+id/item_section" android:layout_width="match_parent" android:layout_height="wrap_content" + android:background="?attr/selectableItemBackground" android:paddingStart="@dimen/normal_margin" android:paddingTop="@dimen/activity_margin" android:paddingEnd="@dimen/normal_margin"