-Subproject commit ecc3415e3e3c13fa8f73fdd51a88c1ab7087b199
+Subproject commit c726e76dad56cc63caa6e8cf894da72c5b4d108f
<string name="filedetails_created">Created:</string>
<string name="filedetails_modified">Modified:</string>
<string name="filedetails_download">Download</string>
- <string name="filedetails_sync_file">Refresh file</string>
+ <string name="filedetails_sync_file">Synchronize</string>
<string name="filedetails_renamed_in_upload_msg">File was renamed to %1$s during upload</string>
<string name="list_layout">List Layout</string>
<string name="action_share_file">Share link</string>
}
// SYNC FILE CONTENTS
- if (mFile == null || mFile.isFolder() || !mFile.isDown() || downloading || uploading) {
+ if (mFile == null || (!mFile.isFolder() && !mFile.isDown()) || downloading || uploading) {
toHide.add(R.id.action_sync_file);
} else {
toShow.add(R.id.action_sync_file);
}
}
-
- public void syncFile(OCFile file) {
-
+ /**
+ * Request the synchronization of a file or folder with the OC server, including its contents.
+ *
+ * @param file The file or folder to synchronize
+ * @param twoWays TMP parameter: when 'false', only download is tried; valid for folders only, single files
+ * are always synchronized in both ways.
+ */
+ public void syncFile(OCFile file, boolean twoWays) {
+
if (!file.isFolder()){
Intent intent = new Intent(mFileActivity, OperationsService.class);
intent.setAction(OperationsService.ACTION_SYNC_FILE);
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(intent);
mFileActivity.showLoadingDialog();
+ } else if (twoWays){
+ Intent intent = new Intent(mFileActivity, OperationsService.class);
+ intent.setAction(OperationsService.ACTION_SYNC_FOLDER);
+ intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ mFileActivity.startService(intent);
+
} else {
Intent intent = new Intent(mFileActivity, OperationsService.class);
intent.setAction(OperationsService.ACTION_SYNC_FOLDER);
intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
mFileActivity.startService(intent);
+
}
}
/// immediate content synchronization
if (file.isFavorite()) {
- syncFile(file);
+ syncFile(file, true);
}
}
private List<SyncOperation> mFilesToSyncContentsWithoutUpload;
// this will go out when 'folder synchronization' replaces 'folder download'; step by step
- private List<SyncOperation> mFavouriteFilesToSyncContents;
+ private List<SyncOperation> mFilesToSyncContents;
// this will be used for every file when 'folder synchronization' replaces 'folder download'
private final AtomicBoolean mCancellationRequested;
mRemoteFolderChanged = false;
mFilesForDirectDownload = new Vector<OCFile>();
mFilesToSyncContentsWithoutUpload = new Vector<SyncOperation>();
- mFavouriteFilesToSyncContents = new Vector<SyncOperation>();
+ mFilesToSyncContents = new Vector<SyncOperation>();
mCancellationRequested = new AtomicBoolean(false);
}
List<OCFile> updatedFiles = new Vector<OCFile>(folderAndFiles.size() - 1);
mFilesForDirectDownload.clear();
mFilesToSyncContentsWithoutUpload.clear();
- mFavouriteFilesToSyncContents.clear();
+ mFilesToSyncContents.clear();
if (mCancellationRequested.get()) {
throw new OperationCancelledException();
/// classify file to sync/download contents later
if (remoteFile.isFolder()) {
/// to download children files recursively
- synchronized(mCancellationRequested) {
+ synchronized (mCancellationRequested) {
if (mCancellationRequested.get()) {
throw new OperationCancelledException();
}
startSyncFolderOperation(remoteFile.getRemotePath());
}
- } else if (remoteFile.isFavorite()) {
+ //} else if (remoteFile.isFavorite()) {
+ } else {
/// prepare content synchronization for kept-in-sync files
SynchronizeFileOperation operation = new SynchronizeFileOperation(
localFile,
true,
mContext
);
- mFavouriteFilesToSyncContents.add(operation);
+ mFilesToSyncContents.add(operation);
- } else {
+ /*} else {
/// prepare limited synchronization for regular files
SynchronizeFileOperation operation = new SynchronizeFileOperation(
localFile,
false,
mContext
);
- mFilesToSyncContentsWithoutUpload.add(operation);
+ mFilesToSyncContentsWithoutUpload.add(operation);*/
}
updatedFiles.add(remoteFile);
/// prepare limited synchronization for regular files
if (!child.isDown()) {
mFilesForDirectDownload.add(child);
+
+ } else {
+ /// this should result in direct upload of files that were locally modified
+ SynchronizeFileOperation operation = new SynchronizeFileOperation(
+ child,
+ child, // cheating with the remote file to get an upadte to server; to refactor
+ mAccount,
+ true,
+ mContext
+ );
+ mFilesToSyncContents.add(operation);
+
}
+
}
}
}
private void syncContents(OwnCloudClient client) throws OperationCancelledException {
startDirectDownloads();
startContentSynchronizations(mFilesToSyncContentsWithoutUpload, client);
- startContentSynchronizations(mFavouriteFilesToSyncContents, client);
+ startContentSynchronizations(mFilesToSyncContents, client);
}
}
case R.id.action_download_file:
case R.id.action_sync_file: {
- mContainerActivity.getFileOperationsHelper().syncFile(getFile());
+ mContainerActivity.getFileOperationsHelper().syncFile(getFile(), true);
return true;
}
case R.id.action_send_file: {
}
}
-
/**
* Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced.
*
dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
return true;
}
- case R.id.action_download_file:
+ case R.id.action_download_file: {
+ mContainerActivity.getFileOperationsHelper().syncFile(mTargetFile, false);
+ return true;
+ }
case R.id.action_sync_file: {
- mContainerActivity.getFileOperationsHelper().syncFile(mTargetFile);
+ mContainerActivity.getFileOperationsHelper().syncFile(mTargetFile, true);
return true;
}
case R.id.action_cancel_download:
return true;
}
case R.id.action_sync_file: {
- mContainerActivity.getFileOperationsHelper().syncFile(getFile());
+ mContainerActivity.getFileOperationsHelper().syncFile(getFile(), true);
return true;
}
case R.id.action_favorite_file:{
return true;
}
case R.id.action_sync_file: {
- mContainerActivity.getFileOperationsHelper().syncFile(getFile());
+ mContainerActivity.getFileOperationsHelper().syncFile(getFile(), true);
return true;
}
case R.id.action_favorite_file:{
return true;
}
case R.id.action_sync_file: {
- mContainerActivity.getFileOperationsHelper().syncFile(getFile());
+ mContainerActivity.getFileOperationsHelper().syncFile(getFile(), true);
return true;
}