|
@@ -31,6 +31,7 @@ import android.content.Intent;
|
|
import android.content.OperationApplicationException;
|
|
import android.content.OperationApplicationException;
|
|
import android.database.Cursor;
|
|
import android.database.Cursor;
|
|
import android.net.Uri;
|
|
import android.net.Uri;
|
|
|
|
+import android.os.Build;
|
|
import android.os.RemoteException;
|
|
import android.os.RemoteException;
|
|
import android.provider.MediaStore;
|
|
import android.provider.MediaStore;
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
@@ -395,7 +396,7 @@ public class FileDataStorageManager {
|
|
if (file.isDown()) {
|
|
if (file.isDown()) {
|
|
String path = file.getStoragePath();
|
|
String path = file.getStoragePath();
|
|
if (new File(path).delete() && MimeTypeUtil.isMedia(file.getMimeType())) {
|
|
if (new File(path).delete() && MimeTypeUtil.isMedia(file.getMimeType())) {
|
|
- triggerMediaScan(path); // notify MediaScanner about removed file
|
|
|
|
|
|
+ triggerMediaScan(path, file); // notify MediaScanner about removed file
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1750,10 +1751,28 @@ public class FileDataStorageManager {
|
|
}
|
|
}
|
|
|
|
|
|
public static void triggerMediaScan(String path) {
|
|
public static void triggerMediaScan(String path) {
|
|
|
|
+ triggerMediaScan(path, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void triggerMediaScan(String path, OCFile file) {
|
|
if (path != null) {
|
|
if (path != null) {
|
|
- Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
|
|
|
- intent.setData(Uri.fromFile(new File(path)));
|
|
|
|
- MainApp.getAppContext().sendBroadcast(intent);
|
|
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|