android
android copied to clipboard
Add Sync Worker
- [x] Tests written, or not not needed
Changes:
• Fixed the issue of scheduling too many FileDownloadWorker instances for folder sync. • Improved file download status observation, including states like syncing, downloading, and downloaded. • Better constraints for worker • Enhanced folder sync progress observation in notifications. • Optimized performance using CoroutineWorker.
Demo New Notifications
https://github.com/user-attachments/assets/b9a93482-dbf0-4c18-9d3c-7fcfd974c9ff
Known Issues
https://github.com/nextcloud/android/issues/13906
Resolved the issue of retrieving sub-folder items for the selected folder. •
It is indented, to not flood the entire storage, if the folder is too big.
Resolved the issue of retrieving sub-folder items for the selected folder. •
It is indented, to not flood the entire storage, if the folder is too big.
Fixed via https://github.com/nextcloud/android/pull/14166/commits/e8e1179136285436c3fc8f26ca8f3f174ad22d03
@jancborchardt While the user downloading the folder, I changed the notification icon and progress text. Is that acceptable to you?
Nice! Just some small things:
- [x] Shouldn't the icon of the notification and the action that you clicked be the same?
- [x] Neither icons really work for "Sync". How about we use the actual Material Design Sync icon? https://fonts.google.com/icons?icon.set=Material+Symbols&icon.size=24&icon.color=%235f6368&selected=Material+Symbols+Outlined:sync:FILL@1;wght@400;GRAD@0;opsz@24&icon.query=sync
- [x] Instead of "1 / 5 - filename", can we use "1 of 5 · filename"? Bit more humanly readable with "of" and looks nicer with the middle dot instead of dash.
https://github.com/user-attachments/assets/5ad699a1-16ae-437d-af31-0cdd5c94398b
I just gave it a small smoke test:
From logs it seems that it had trouble with one file:
2025-06-18 15:25:20.425 21749-21898 Synchroniz...eOperation com.nextcloud.client I Synchronizing [email protected], file /allTypes/gif.gif: Operation finished with HTTP status code -1 (success)
2025-06-18 15:25:23.813 21749-21925 FileDownloadWorker com.nextcloud.client E FilesDownloadWorker downloading: [email protected]/allTypes/gif.gif
2025-06-18 15:25:23.823 21749-21925 OwnCloudClient #0 com.nextcloud.client D REQUEST GET /remote.php/dav/files/test/allTypes/gif.gif
2025-06-18 15:25:23.850 21749-21882 OwnCloudClient #0 com.nextcloud.client D REQUEST GET /remote.php/dav/files/test/allTypes/gif.gif
2025-06-18 15:25:24.021 21749-21882 DownloadFi...eOperation com.nextcloud.client I Download of /allTypes/gif.gif to /storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/tmp/[email protected]/allTypes/gif.gif: Operation finished with HTTP status code 200 (success)
2025-06-18 15:25:24.022 21749-21882 DownloadFileOperation com.nextcloud.client I Download of /allTypes/gif.gif to /storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/[email protected]/allTypes/gif.gif: Operation finished with HTTP status code 200 (success)
2025-06-18 15:25:24.022 21749-21882 SyncWorker com.nextcloud.client D Syncing file: /allTypes/gif.gif
2025-06-18 15:25:24.065 21749-21925 DownloadFi...eOperation com.nextcloud.client I Download of /allTypes/gif.gif to /storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/tmp/[email protected]/allTypes/gif.gif: Operation finished with HTTP status code 200 (success)
2025-06-18 15:25:24.065 21749-21925 DownloadFileOperation com.nextcloud.client I Download of /allTypes/gif.gif to /storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/[email protected]/allTypes/gif.gif: Error while moving file to final directory
2025-06-18 15:25:46.130 21749-21995 ThumbnailsCacheManager com.nextcloud.client D generate thumbnail: gif.gif URI: https://nextcloud.kaminsky.me/index.php/core/preview?fileId=1890238&x=256&y=256&a=1&mode=cover&forceIcon=0
2025-06-18 15:25:46.133 21749-21749 OCFileListAdapter com.nextcloud.client D sharees of gif.gif: [ShareeUser(userId=jdl, displayName=jdl, shareType=USER)]
@tobiasKaminsky The error message is not coming from SyncWorker, it's actually used by FileDownloadWorker. How did you encounter this issue? I’m unable to reproduce it. SyncWorker only downloads the first level of the folder hierarchy.
@jancborchardt I will update the PR thanks for the reminder.
Let’s first complete the following PR
https://github.com/nextcloud/android/pull/15540
@jancborchardt We can merge it after get approval from @tobiasKaminsky :)
How to test?
- Create a folder containing multiple files and subfolders.
- Initiate a folder sync.
The sync icon should be displayed for the folder itself and for its sub-files. Subfolders and the files within those subfolders should not be downloaded (because).
When the user reopens the app, the sync icons for the already downloaded folders and subfiles should remain visible.
blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.
Codacy
Lint
| Type | master | PR |
| Warnings | 45 | 42 |
| Errors | 11 | 11 |
SpotBugs
| Category | Base | New |
|---|---|---|
| Bad practice | 46 | 46 |
| Correctness | 73 | 74 |
| Dodgy code | 267 | 267 |
| Experimental | 1 | 1 |
| Internationalization | 7 | 7 |
| Malicious code vulnerability | 2 | 2 |
| Multithreaded correctness | 35 | 35 |
| Performance | 49 | 47 |
| Security | 18 | 18 |
| Total | 498 | 497 |
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/14166.apk
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.