|
@@ -1736,10 +1736,28 @@ public class FileDataStorageManager {
|
|
|
}
|
|
|
|
|
|
public static void triggerMediaScan(String path) {
|
|
|
- if (path != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
|
|
- Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
|
|
- intent.setData(Uri.fromFile(new File(path)));
|
|
|
- MainApp.getAppContext().sendBroadcast(intent);
|
|
|
+ triggerMediaScan(path, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void triggerMediaScan(String path, OCFile file) {
|
|
|
+ if (path != null) {
|
|
|
+ ContentValues values = new ContentValues();
|
|
|
+ ContentResolver contentResolver = MainApp.getAppContext().getContentResolver();
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
|
+ if (file != null) {
|
|
|
+ values.put(MediaStore.Images.Media.MIME_TYPE, file.getMimeType());
|
|
|
+ values.put(MediaStore.Images.Media.TITLE, file.getFileName());
|
|
|
+ values.put(MediaStore.Images.Media.DISPLAY_NAME, file.getFileName());
|
|
|
+ }
|
|
|
+ values.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis() / 1000);
|
|
|
+ values.put(MediaStore.Images.Media.RELATIVE_PATH, path);
|
|
|
+ values.put(MediaStore.Images.Media.IS_PENDING, 0);
|
|
|
+ contentResolver.insert(MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY), values);
|
|
|
+ } else {
|
|
|
+ Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
|
|
+ intent.setData(Uri.fromFile(new File(path)));
|
|
|
+ MainApp.getAppContext().sendBroadcast(intent);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|