import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
import com.owncloud.android.files.OwnCloudFileObserver;
import com.owncloud.android.files.OwnCloudFileObserver.FileObserverStatusListener;
+import com.owncloud.android.operations.RemoteOperationResult;
+import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.ui.activity.ConflictsResolveActivity;
import com.owncloud.android.utils.FileStorageUtils;
* Registers the local copy of a remote file to be observed for local changes,
* an automatically updated in the ownCloud server.
*
- * If there is no local copy of the remote file, a request to download it is send
- * to the FileDownloader service. The observation is delayed until the download
- * is finished.
- *
* @param file Object representing a remote file which local copy must be observed.
* @param account OwnCloud account containing file.
*/
DownloadCompletedReceiver receiver = new DownloadCompletedReceiver(localPath, observer);
registerReceiver(receiver, new IntentFilter(FileDownloader.DOWNLOAD_FINISH_MESSAGE));
- Intent i = new Intent(this, FileDownloader.class);
- i.putExtra(FileDownloader.EXTRA_ACCOUNT, account);
- i.putExtra(FileDownloader.EXTRA_FILE, file);
- startService(i);
-
} else {
observer.startWatching();
Log.d(TAG, "Started watching " + localPath);
}
@Override
- public void OnObservedFileStatusUpdate(String localPath, String remotePath, Account account, Status status) {
- switch (status) {
- case CONFLICT:
- {
+ public void onObservedFileStatusUpdate(String localPath, String remotePath, Account account, RemoteOperationResult result) {
+ if (!result.isSuccess()) {
+ if (result.getCode() == ResultCode.SYNC_CONFLICT) {
// ISSUE 5: if the user is not running the app (this is a service!), this can be very intrusive; a notification should be preferred
Intent i = new Intent(getApplicationContext(), ConflictsResolveActivity.class);
i.setFlags(i.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra("localpath", localPath);
i.putExtra("account", account);
startActivity(i);
- break;
+
+ } else {
+ // TODO send notification to the notification bar?
}
- case SENDING_TO_UPLOADER:
- case INCORRECT_MASK:
- break;
- default:
- Log.wtf(TAG, "Unhandled status " + status);
- }
+ } // else, nothing else to do; now it's duty of FileUploader service
}
private class DownloadCompletedReceiver extends BroadcastReceiver {