import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
-import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.operations.SynchronizeFolderOperation;
import com.owncloud.android.operations.UnshareLinkOperation;
+import com.owncloud.android.utils.FileStorageUtils;
import android.accounts.Account;
import android.accounts.AccountsException;
Pair<Target, RemoteOperation> itemToQueue = newOperation(intent);
if (itemToQueue != null) {
mSyncFolderHandler.add(account, remotePath, (SynchronizeFolderOperation)itemToQueue.second);
+ sendBroadcastNewSyncFolder(account, remotePath);
Message msg = mSyncFolderHandler.obtainMessage();
msg.arg1 = startId;
msg.obj = itemSyncKey;
return START_NOT_STICKY;
}
+ /**
+ * TODO remove this method when "folder synchronization" replaces "folder download"; this is a fast and ugly
+ * patch.
+ */
+ private void sendBroadcastNewSyncFolder(Account account, String remotePath) {
+ Intent added = new Intent(FileDownloader.getDownloadAddedMessage());
+ added.putExtra(FileDownloader.ACCOUNT_NAME, account.name);
+ added.putExtra(FileDownloader.EXTRA_REMOTE_PATH, remotePath);
+ added.putExtra(FileDownloader.EXTRA_FILE_PATH, FileStorageUtils.getSavePath(account.name) + remotePath);
+ sendStickyBroadcast(added);
+ }
+
+
@Override
public void onDestroy() {
//Log_OC.wtf(TAG, "onDestroy init" );
//Log_OC.wtf(TAG, "Not finished yet");
}
}
+
+
+ /**
+ * Returns True when the file described by 'file' in the ownCloud account 'account' is downloading or waiting to download.
+ *
+ * If 'file' is a directory, returns 'true' if some of its descendant files is downloading or waiting to download.
+ *
+ * @param account ownCloud account where the remote file is stored.
+ * @param file A file that could be affected
+ */
+ public boolean isSynchronizing(Account account, String remotePath) {
+ return mSyncFolderHandler.isSynchronizing(account, remotePath);
+ }
}
mService = service;
}
+
+ public boolean isSynchronizing(Account account, String remotePath) {
+ if (account == null || remotePath == null) return false;
+ String targetKey = buildRemoteName(account, remotePath);
+ synchronized (mPendingOperations) {
+ return (mPendingOperations.containsKey(targetKey));
+ }
+ }
+
+
@Override
public void handleMessage(Message msg) {
Pair<Account, String> itemSyncKey = (Pair<Account, String>) msg.obj;
import com.owncloud.android.files.FileOperationsHelper;
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
+import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
public interface ComponentsGetter {
/**
- * Callback method invoked when the parent activity is fully created to get a reference to the FileDownloader service API.
- *
- * @return Directory to list firstly. Can be NULL.
+ * To be invoked when the parent activity is fully created to get a reference to the FileDownloader service API.
*/
public FileDownloaderBinder getFileDownloaderBinder();
/**
- * Callback method invoked when the parent activity is fully created to get a reference to the FileUploader service API.
- *
- * @return Directory to list firstly. Can be NULL.
+ * To be invoked when the parent activity is fully created to get a reference to the FileUploader service API.
*/
public FileUploaderBinder getFileUploaderBinder();
+ /**
+ * To be invoked when the parent activity is fully created to get a reference to the OperationsSerivce service API.
+ */
+ public OperationsServiceBinder getOperationsServiceBinder();
+
public FileDataStorageManager getStorageManager();
public FileOperationsHelper getFileOperationsHelper();
+
}
import com.owncloud.android.datamodel.ThumbnailsCacheManager.AsyncDrawable;\r
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;\r
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;\r
+import com.owncloud.android.services.OperationsService.OperationsServiceBinder;\r
import com.owncloud.android.ui.activity.ComponentsGetter;\r
import com.owncloud.android.utils.DisplayUtils;\r
import com.owncloud.android.utils.FileStorageUtils;\r
FileDownloaderBinder downloaderBinder = \r
mTransferServiceGetter.getFileDownloaderBinder();\r
FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();\r
- if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {\r
+ OperationsServiceBinder opsBinder = mTransferServiceGetter.getOperationsServiceBinder();\r
+ if ((downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) ||\r
+ (opsBinder != null && opsBinder.isSynchronizing(mAccount, file.getRemotePath()))) {\r
localStateView.setImageResource(R.drawable.downloading_file_indicator);\r
localStateView.setVisibility(View.VISIBLE);\r
} else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {\r