fix: media scan on download for Android 11+#16726
fix: media scan on download for Android 11+#16726alperozturk96 merged 2 commits intonextcloud:masterfrom
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 |
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.