X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/b2af9efa788b773069df27bd5b82666c135305b0..eaa3b1ef566ec3301dc648e6e57b39af7915392f:/src/com/owncloud/android/datamodel/FileDataStorageManager.java diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index b10e525c..abaafa5f 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -33,7 +33,6 @@ import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.utils.FileStorageUtils; - import android.accounts.Account; import android.content.ContentProviderClient; import android.content.ContentProviderOperation; @@ -41,6 +40,7 @@ import android.content.ContentProviderResult; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; +import android.content.Intent; import android.content.OperationApplicationException; import android.database.Cursor; import android.net.Uri; @@ -346,7 +346,13 @@ public class FileDataStorageManager { ).withSelection(where, whereArgs).build()); if (file.isDown()) { + String path = file.getStoragePath(); new File(file.getStoragePath()).delete(); + + // Notify MediaScanner about removed file + Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + intent.setData(Uri.fromFile(new File(path))); + MainApp.getAppContext().sendBroadcast(intent); } } } @@ -542,11 +548,17 @@ public class FileDataStorageManager { success &= removeLocalFolder(file); } else { if (file.isDown()) { + String path = file.getStoragePath(); File localFile = new File(file.getStoragePath()); success &= localFile.delete(); if (success) { file.setStoragePath(null); saveFile(file); + + // Notify MediaScanner about removed file + Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + intent.setData(Uri.fromFile(new File(path))); + MainApp.getAppContext().sendBroadcast(intent); } } } @@ -568,7 +580,13 @@ public class FileDataStorageManager { if (localFile.isDirectory()) { success &= removeLocalFolder(localFile); } else { + String path = localFile.getAbsolutePath(); success &= localFile.delete(); + + // Notify MediaScanner about removed file + Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + intent.setData(Uri.fromFile(new File(path))); + MainApp.getAppContext().sendBroadcast(intent); } } } @@ -787,6 +805,18 @@ public class FileDataStorageManager { } Log_OC.d(TAG, "Local file RENAMED : " + renamed); + // Notify MediaScanner about removed file + Intent intent1 = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + intent1.setData(Uri.fromFile(new File(file.getStoragePath()))); + MainApp.getAppContext().sendBroadcast(intent1); + + // Notify MediaScanner about new file/folder + Intent intent2 = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + intent2.setData(Uri.fromFile(new File(defaultSavePath + targetPath))); + MainApp.getAppContext().sendBroadcast(intent2); + + Log_OC.d(TAG, "uri old: " + file.getStoragePath()); + Log_OC.d(TAG, "uri new: " + defaultSavePath + targetPath); } }