Fix search not working in drawer category views#4586
Conversation
VishnuSanal
left a comment
There was a problem hiding this comment.
awesome, LGTM 🚀 thanks for contributing to amaze :)
| mainActivity: MainActivity, | ||
| query: String, | ||
| ): LiveData<List<SearchResult>> { | ||
| val currentMainFragment = mainActivity.currentMainFragment |
There was a problem hiding this comment.
This should follow the structure of the normal search, and launch to a different coroutine. It also misses the other search modes (index and deep), which should probably be disabled completely in some CUSTOM modes.
There was a problem hiding this comment.
Thanks, that makes sense.
I see the issue — this is currently handling CUSTOM / TRASH_BIN inline inside basicSearch() instead of following the existing search structure.
I’ll revisit this and rework it to align more closely with the normal search pattern.
cb149a4 to
a3d2a81
Compare
|
I pushed an updated implementation that follows the normal search structure more closely. Instead of handling CUSTOM / TRASH_BIN inline inside Indexed and deep search escalation are also disabled for these views since they do not support filesystem-backed search modes. Added focused
Quick Access remains unverified (no items available to test), as noted in the original description. |
a3d2a81 to
9cb6bea
Compare
Drawer categories (Quick Access, Recent Files, Images, Videos,
Audio, Documents, APKs, Trash Bin) use numeric paths ("0"–"7")
instead of real filesystem directories.
BasicSearch expects a filesystem path, so searches silently returned
no results when run from these views.
When the current view uses OpenMode.CUSTOM or OpenMode.TRASH_BIN,
search now uses ListElementsSearch to filter the visible dataset
(MainFragmentViewModel.listElements) instead of performing a
filesystem search.
Indexed and deep search modes are disabled for these views because
they do not support filesystem-backed search escalation.
Add ListElementsSearch unit tests covering matching, back/header
filtering, and no-result behavior.
9cb6bea to
928a624
Compare
|
Pushed another small cleanup/refinement pass on the new This follow-up mainly focused on test maintainability and static-analysis cleanup:
No functional behavior changes in this push — primarily readability, maintainability, and test clarity improvements around the dataset-backed search implementation. |


Description
Drawer categories (Quick Access, Recent Files, Images, Videos, Audio,
Documents, APKs, and Trash Bin) do not represent real filesystem
directories. Instead, they display an in-memory list of visible items.
The existing search flow always used
BasicSearch, which expects afilesystem path and searches the underlying filesystem. As a result,
searches from drawer category views either returned no results or did not
search the visible dataset being displayed to the user.
This change introduces
ListElementsSearch, which searches the currentlyvisible
listElementsdataset. Searches launched fromOpenMode.CUSTOMandOpenMode.TRASH_BINnow use this in-memory searchpath, while normal filesystem locations continue using
BasicSearch.The search UI was also updated to hide deep/indexed search options in
drawer category views where filesystem-based search modes do not apply.
Issue tracker
Fixes #4561
Automatic tests
Manual tests
Device: Pixel 9 Pro (emulator)
OS: Android 16 (API 36)
Rooted: No
Build: debug
Verified search in:
Could not verify:
Build tasks success
Successfully running following tasks locally:
./gradlew assembleDebug./gradlew spotlessCheck