fix: media scan on download for Android 11+#16726
Conversation
6c58db1 to
8a29a57
Compare
|
@alperozturk96 I am happy for my first contribution on nextcloud-android. |
8a29a57 to
7e2130d
Compare
There was a problem hiding this comment.
Hello, thank you for the PR.
Could you clarify why we’re not using MediaScannerConnection.scanFile across all supported API levels? This approach should work consistently for all API versions we currently support.
Additionally, it would be helpful to include test coverage for this change. I suggest add the Context as a new parameter and providing an overloaded function so that existing callers do not need to be modified.
Please also consider adding a new Kotlin test class that verifies this behavior, including proper context injection for testing purposes.
2466920 to
55e6683
Compare
|
Hi @alperozturk96 I update my code for your comments. |
Signed-off-by: mykh-hailo <kristianderonta0205@gmail.com>
Signed-off-by: mykh-hailo <kristianderonta0205@gmail.com>
55e6683 to
82478f5
Compare
|
Hi @alperozturk96 , @tobiasKaminsky |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Summary
Ensures downloaded files are scanned and indexed so they appear in the device’s media library (e.g. Photos/Gallery) on Android 11 (API 30) and above.
Closes: #16101
Problem
In
triggerMediaScan(), Android 11+ was handled by only logging "SDK > 29, skipping media scan" and not performing any scan. As a result, files downloaded via the Nextcloud app were not added to the MediaStore and did not show up in system media apps.Solution
Use
MediaScannerConnection.scanFile()for devices with SDK ≥ 30 instead of skipping the scan. This API:Works correctly on Android 10+
Takes the file path and optional MIME type
Uses a callback for success and failure
Logs scan completion or failure for debugging
Changes
FileDataStorageManager.java
This PR was generated by Mykhailo. View the repository job log.