Skip to content

Fix drawer category views not refreshing after file operations#4589

Open
geoffreysisco wants to merge 1 commit intoTeamAmaze:release/4.0from
geoffreysisco:fix/drawer-views-not-refreshing
Open

Fix drawer category views not refreshing after file operations#4589
geoffreysisco wants to merge 1 commit intoTeamAmaze:release/4.0from
geoffreysisco:fix/drawer-views-not-refreshing

Conversation

@geoffreysisco
Copy link
Copy Markdown
Contributor

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:

  • forcing reload for drawer category views to ensure fresh data after operations
  • filtering Amaze trash paths from category queries

This ensures drawer views correctly reflect the current filesystem state
across all categories.

Issue tracker

Fixes #4558

Automatic tests

  • Added test cases

Manual tests

  • Done

  • Device: Pixel 9 Pro (emulator)

  • OS: Android 16.0

  • Rooted: No

  • Version: 3.11.2

Verified in:

  • Documents
  • APKs
  • Recent Files
  • Images
  • Videos
  • Audio

Scenarios tested:

  • Delete file → removed from drawer view
  • Repeat delete → not possible (item is no longer visible after deletion)

Before/after reproduction videos:

Before

before.mp4

After

after.mp4

Build tasks success

Successfully running the following tasks locally:

  • ./gradlew assembleDebug
  • ./gradlew spotlessCheck

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 VishnuSanal added the PR-Awaiting-Initial-Review this PR is awaiting for an initial review label Mar 21, 2026
Copy link
Copy Markdown
Member

@VishnuSanal VishnuSanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pls use AppConfig.TRASH_BIN_BASE_PATH here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +441 to +443
if (path != null && path.startsWith(AMAZE_TRASH_PATH)) {
continue;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, that makes sense. I’ll move the trash exclusion into the query instead of filtering in the loop.

@VishnuSanal VishnuSanal added PR-Requested-Changes this PR is awaiting an update from the author and removed PR-Awaiting-Initial-Review this PR is awaiting for an initial review labels Mar 22, 2026
@geoffreysisco
Copy link
Copy Markdown
Contributor Author

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 forceReload change in MainFragment for OpenMode.CUSTOM, but they still go through listMediaCommon() for querying.

When you mentioned “all quick access menu listings,” should the trash-path exclusion also be applied in listMediaCommon() for Images/Videos/Audio, or only to the MediaStore.Files-based listings touched here (Documents/APKs/Recent files)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Requested-Changes this PR is awaiting an update from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refresh not work when deleting files in "Images", "Videos", etc.

2 participants