diff --git a/src/com/owncloud/android/files/FileOperationsHelper.java b/src/com/owncloud/android/files/FileOperationsHelper.java index 65e8d83567..538daa835f 100644 --- a/src/com/owncloud/android/files/FileOperationsHelper.java +++ b/src/com/owncloud/android/files/FileOperationsHelper.java @@ -22,7 +22,6 @@ import org.apache.http.protocol.HTTP; import android.accounts.Account; import android.accounts.AccountManager; import android.content.Intent; -import android.media.MediaScannerConnection; import android.net.Uri; import android.support.v4.app.DialogFragment; import android.webkit.MimeTypeMap; diff --git a/src/com/owncloud/android/operations/SynchronizeFileOperation.java b/src/com/owncloud/android/operations/SynchronizeFileOperation.java index 45a73057cd..6bc3321e93 100644 --- a/src/com/owncloud/android/operations/SynchronizeFileOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFileOperation.java @@ -33,6 +33,7 @@ import com.owncloud.android.utils.FileStorageUtils; import android.accounts.Account; import android.content.Context; import android.content.Intent; +import android.media.MediaScannerConnection; /** * Remote operation performing the read of remote file in the ownCloud server. @@ -194,6 +195,12 @@ public class SynchronizeFileOperation extends SyncOperation { } } + + // trigger MediaScan + MediaScannerConnection.scanFile( + null, + new String[]{mLocalFile.getStoragePath()}, + null,null); Log_OC.i(TAG, "Synchronizing " + mAccount.name + ", file " + mLocalFile.getRemotePath() + ": " + result.getLogMessage()); diff --git a/src/com/owncloud/android/services/observer/FileObserverService.java b/src/com/owncloud/android/services/observer/FileObserverService.java index 114f0e426f..fb9df7c545 100644 --- a/src/com/owncloud/android/services/observer/FileObserverService.java +++ b/src/com/owncloud/android/services/observer/FileObserverService.java @@ -30,10 +30,12 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.database.Cursor; +import android.media.MediaScannerConnection; import android.os.IBinder; import com.owncloud.android.MainApp; import com.owncloud.android.authentication.AccountUtils; +import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; import com.owncloud.android.files.services.FileDownloader; @@ -351,7 +353,7 @@ public class FileObserverService extends Service { Log_OC.d(TAG, "Received broadcast intent " + intent); File downloadedFile = new File(intent.getStringExtra(FileDownloader.EXTRA_FILE_PATH)); - String parentPath = downloadedFile.getParent(); + String parentPath = downloadedFile.getParent(); FolderObserver observer = mFolderObserversMap.get(parentPath); if (observer != null) { if (intent.getAction().equals(FileDownloader.getDownloadFinishMessage()) @@ -367,6 +369,13 @@ public class FileObserverService extends Service { } } else { + + if (downloadedFile.exists()){ + Log_OC.d("mediaScan", "mediaScan : " + downloadedFile.getAbsolutePath()); + MediaScannerConnection.scanFile(getApplicationContext(), + new String[]{downloadedFile.getAbsolutePath()}, null, null); + } + Log_OC.d(TAG, "No observer for path " + downloadedFile.getAbsolutePath()); } } diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 37991beba1..021d583810 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -308,7 +308,13 @@ public class OCFileListFragment extends ExtendedListFragment { case R.id.action_download_file: case R.id.action_sync_file: { mContainerActivity.getFileOperationsHelper().syncFile(mTargetFile); - triggerMediaScan(mTargetFile.getStoragePath()); + + Log_OC.d("mediascan", "path: " + mTargetFile.getRemotePath()); + + FileDataStorageManager storageManager = mContainerActivity.getStorageManager(); + Log_OC.d("mediaScan", "path: "+ storageManager.getFileByPath(mTargetFile.getRemotePath()).getStoragePath()); + // TODO triggerMediaScan + return true; } case R.id.action_cancel_download: