Skip to content

Conversation

@alperozturk96
Copy link
Collaborator

@alperozturk96 alperozturk96 commented Nov 7, 2025

  • Tests written, or not not needed

Issue

Local file indicator icons were not updating correctly when files or folders finished downloading, and switching between list and grid layouts caused icons to disappear.

Fixes

Fix observation of multiple workers across all relevant screens to ensure each worker completion is reflected in the UI.

Preserves local file indicator state during layout switches (list ↔ grid).

Fix logic for both folder and file downloads to display local file indicator icons consistently.

@alperozturk96
Copy link
Collaborator Author

/backport to stable-3.34

@alperozturk96 alperozturk96 force-pushed the fix/observe-worker-state branch 2 times, most recently from e7f430c to 1b4292e Compare November 11, 2025 17:14
@tobiasKaminsky tobiasKaminsky marked this pull request as draft November 14, 2025 09:14
@alperozturk96 alperozturk96 force-pushed the fix/observe-worker-state branch from 1b4292e to 797b231 Compare November 14, 2025 13:43
@alperozturk96
Copy link
Collaborator Author

alperozturk96 commented Nov 14, 2025

@tobiasKaminsky

Note:

Events are delivered only to the currently active activity.

For example, this means that when the user is in FileDisplayActivity. ManageAccountsActivity, cannot receive an event.


FolderDownloadCompleted is used:

  • In FileDisplayActivity to mark the green tick for a single OCFile item via notifyItemChanged, indicating that the folder has been downloaded.

FileDownloadStarted is used:

  • In FileDisplayActivity, if mWaitingToPreview is not null, to request the download again if it has not already started.
  • In ManageAccountsActivity, when the user logs out, to cancel all current downloads for the active account.
  • In PreviewImageActivity, if the screen state is PreviewImageActivityState.WaitingForBinder, to select the appropriate page in the ViewPager.

FileDownloadCompleted is used:

  • In FileDisplayActivity to preview an image immediately after the download completes, but only if fileIDForImmediatePreview is valid.
  • In PreviewImageActivity, if the screen state is PreviewImageActivityState.Edit, to start the image editing activity; otherwise, it reinitializes the ViewPager for the newly downloaded file.

FileUploadStarted is used:

  • In UploadListActivity (the Upload screen) to refresh the items in the list.
  • In FileDetailFragment to update the text view and inform the user that the file is uploading.

FileUploadCompleted is used:

  • In UploadListActivity (the Upload screen) to refresh the items in the list.
  • In FileDisplayActivity to insert the related item via notifyItemInserted.

OfflineOperationsCompleted is used:

  • In FileDisplayActivity to refresh the current directory and reload the OCFile list adapter.

Signed-off-by: alperozturk <[email protected]>
@github-actions
Copy link

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/15923.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@alperozturk96
Copy link
Collaborator Author

alperozturk96 commented Nov 14, 2025

@tobiasKaminsky

How to Test the Green Tick for a Folder & Slow Grid View

  1. Ensure the folder contains at least a few files.

  2. Open the three-dot menu for that folder.

  3. Tap "Sync".

  4. The folder will be downloaded via FolderDownloadWorker.

  5. The green tick icon is then displayed through OCFileListDelegate.showLocalFileIndicator.

    • This method uses a Coroutine IO scope to call isFolderFullyDownloaded, which queries the database asynchronously.
    • Other icon checks (e.g., cancel, syncing states) can be handled synchronously, but the folder-completion check cannot because it is suspended.

Why Some Approaches Do Not Work

  1. Setting synchronous icons first, then calling the async check. This shows the quick icons immediately, but the green tick never appears afterward because the adapter is not notified when the async result returns.

  2. Calling isFolderFullyDownloaded asynchronously from OCFileListFragment or FileDisplayActivity, then using notifyItemChanged

  3. Running the check on an ExecutorService or a Thread. This does not change the behavior, since the core issue is the async nature of the database call and the lack of a proper UI update mechanism tied to it.

  4. Switching from setAdapter to swapAdapter in the switchLayoutManager function. While this make UI faster but changing the adapter-swap logic breaks item alignment, styles, and layout behaviors.

@github-actions
Copy link

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions
Copy link

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants