Fix drawer category views not refreshing after file operations#4589
Fix drawer category views not refreshing after file operations#4589geoffreysisco wants to merge 1 commit intoTeamAmaze:release/4.0from
Conversation
Force reload when navigating to drawer category views to ensure the list updates after file operations. Filter out Amaze trash directory (.AmazeData) from category queries to prevent stale entries. This ensures drawer views correctly reflect the current filesystem state.
VishnuSanal
left a comment
There was a problem hiding this comment.
hi @geoffreysisco great work, thanks for contributing to amaze! :) I have some comments, please address them, and we are good to go, tahnsk!
- also, can you pls add the trash directory check to all quick access menu listings too? thanks!
| extends AsyncTask<Void, Throwable, Pair<OpenMode, List<LayoutElementParcelable>>> { | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(LoadFilesListTask.class); | ||
| private static final String AMAZE_TRASH_PATH = "/storage/emulated/0/.AmazeData"; |
There was a problem hiding this comment.
can we pls use AppConfig.TRASH_BIN_BASE_PATH here?
There was a problem hiding this comment.
TRASH_BIN_BASE_PATH is currently private in AppConfig, so it’s not accessible here.
I can expose it via a getter (e.g. AppConfig.getTrashBinBasePath()) and use that instead — let me know if you’d prefer a different approach.
| if (path != null && path.startsWith(AMAZE_TRASH_PATH)) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
hmm, nice, but I think we can add this selection to the cursor itself like below. WDYT?
final String[] projection = {MediaStore.Files.FileColumns.DATA};
final String selection = MediaStore.Files.FileColumns.DATA + " NOT LIKE ?";
final String[] selectionArgs = new String[] {AppConfig.TRASH_BIN_BASE_PATH + "%"};
Cursor cursor =
context
.getContentResolver()
.query(MediaStore.Files.getContentUri("external"), projection, selection, selectionArgs, null);There was a problem hiding this comment.
I agree, that makes sense. I’ll move the trash exclusion into the query instead of filtering in the loop.
|
Thanks for the review. I’ve started addressing the comments. Documents, APKs, and Recent files now exclude the trash directory at query time instead of filtering in the loop. For Images/Videos/Audio, the stale delete behavior is already handled via the When you mentioned “all quick access menu listings,” should the trash-path exclusion also be applied in |
Description
Drawer category views did not consistently reflect filesystem changes
after file operations such as create and delete.
In some categories (Documents, APKs, Recent Files), queries could include
entries from Amaze's trash directory (.AmazeData), causing deleted files
to remain visible and allowing repeated deletes to create duplicate
Trash Bin entries.
This PR addresses the issue by:
This ensures drawer views correctly reflect the current filesystem state
across all categories.
Issue tracker
Fixes #4558
Automatic tests
Manual tests
Done
Device: Pixel 9 Pro (emulator)
OS: Android 16.0
Rooted: No
Version: 3.11.2
Verified in:
Scenarios tested:
Before/after reproduction videos:
Before
before.mp4
After
after.mp4
Build tasks success
Successfully running the following tasks locally:
./gradlew assembleDebug./gradlew spotlessCheck