projects
/
pub
/
Android
/
ownCloud.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
92c39be
)
Extend SyncFolderOperation to check local changes of all files and trigger uploads
author
David A. Velasco
<dvelasco@solidgear.es>
Mon, 13 Jul 2015 12:16:18 +0000
(14:16 +0200)
committer
David A. Velasco
<dvelasco@solidgear.es>
Fri, 25 Sep 2015 13:13:35 +0000
(15:13 +0200)
owncloud-android-library
patch
|
blob
|
blame
|
history
res/values/strings.xml
patch
|
blob
|
blame
|
history
src/com/owncloud/android/files/FileMenuFilter.java
patch
|
blob
|
blame
|
history
src/com/owncloud/android/files/FileOperationsHelper.java
patch
|
blob
|
blame
|
history
src/com/owncloud/android/operations/SynchronizeFolderOperation.java
patch
|
blob
|
blame
|
history
src/com/owncloud/android/ui/fragment/FileDetailFragment.java
patch
|
blob
|
blame
|
history
src/com/owncloud/android/ui/fragment/OCFileListFragment.java
patch
|
blob
|
blame
|
history
src/com/owncloud/android/ui/preview/PreviewImageFragment.java
patch
|
blob
|
blame
|
history
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java
patch
|
blob
|
blame
|
history
src/com/owncloud/android/ui/preview/PreviewTextFragment.java
patch
|
blob
|
blame
|
history
diff --git
a/owncloud-android-library
b/owncloud-android-library
index
ecc3415
..
c726e76
160000
(submodule)
--- a/
owncloud-android-library
+++ b/
owncloud-android-library
@@
-1
+1
@@
-Subproject commit
ecc3415e3e3c13fa8f73fdd51a88c1ab7087b199
+Subproject commit
c726e76dad56cc63caa6e8cf894da72c5b4d108f
diff --git
a/res/values/strings.xml
b/res/values/strings.xml
index
8f1aec2
..
4d72032
100644
(file)
--- a/
res/values/strings.xml
+++ b/
res/values/strings.xml
@@
-81,7
+81,7
@@
<string name="filedetails_created">Created:</string>
<string name="filedetails_modified">Modified:</string>
<string name="filedetails_download">Download</string>
<string name="filedetails_created">Created:</string>
<string name="filedetails_modified">Modified:</string>
<string name="filedetails_download">Download</string>
- <string name="filedetails_sync_file">
Refresh fil
e</string>
+ <string name="filedetails_sync_file">
Synchroniz
e</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>
<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>
diff --git
a/src/com/owncloud/android/files/FileMenuFilter.java
b/src/com/owncloud/android/files/FileMenuFilter.java
index
f7fee62
..
4802700
100644
(file)
--- a/
src/com/owncloud/android/files/FileMenuFilter.java
+++ b/
src/com/owncloud/android/files/FileMenuFilter.java
@@
-176,7
+176,7
@@
public class FileMenuFilter {
}
// SYNC FILE CONTENTS
}
// 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);
toHide.add(R.id.action_sync_file);
} else {
toShow.add(R.id.action_sync_file);
diff --git
a/src/com/owncloud/android/files/FileOperationsHelper.java
b/src/com/owncloud/android/files/FileOperationsHelper.java
index
2237028
..
766f579
100644
(file)
--- a/
src/com/owncloud/android/files/FileOperationsHelper.java
+++ b/
src/com/owncloud/android/files/FileOperationsHelper.java
@@
-205,9
+205,15
@@
public class FileOperationsHelper {
}
}
}
}
-
- 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);
if (!file.isFolder()){
Intent intent = new Intent(mFileActivity, OperationsService.class);
intent.setAction(OperationsService.ACTION_SYNC_FILE);
@@
-217,12
+223,20
@@
public class FileOperationsHelper {
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(intent);
mFileActivity.showLoadingDialog();
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);
} 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);
+
}
}
}
}
@@
-240,7
+254,7
@@
public class FileOperationsHelper {
/// immediate content synchronization
if (file.isFavorite()) {
/// immediate content synchronization
if (file.isFavorite()) {
- syncFile(file);
+ syncFile(file
, true
);
}
}
}
}
diff --git
a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java
b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java
index
78b6a7b
..
75e193a
100644
(file)
--- a/
src/com/owncloud/android/operations/SynchronizeFolderOperation.java
+++ b/
src/com/owncloud/android/operations/SynchronizeFolderOperation.java
@@
-99,7
+99,7
@@
public class SynchronizeFolderOperation extends SyncOperation {
private List<SyncOperation> mFilesToSyncContentsWithoutUpload;
// this will go out when 'folder synchronization' replaces 'folder download'; step by step
private List<SyncOperation> mFilesToSyncContentsWithoutUpload;
// this will go out when 'folder synchronization' replaces 'folder download'; step by step
- private List<SyncOperation> mF
avouriteF
ilesToSyncContents;
+ private List<SyncOperation> mFilesToSyncContents;
// this will be used for every file when 'folder synchronization' replaces 'folder download'
private final AtomicBoolean mCancellationRequested;
// this will be used for every file when 'folder synchronization' replaces 'folder download'
private final AtomicBoolean mCancellationRequested;
@@
-121,7
+121,7
@@
public class SynchronizeFolderOperation extends SyncOperation {
mRemoteFolderChanged = false;
mFilesForDirectDownload = new Vector<OCFile>();
mFilesToSyncContentsWithoutUpload = new Vector<SyncOperation>();
mRemoteFolderChanged = false;
mFilesForDirectDownload = new Vector<OCFile>();
mFilesToSyncContentsWithoutUpload = new Vector<SyncOperation>();
- mF
avouriteF
ilesToSyncContents = new Vector<SyncOperation>();
+ mFilesToSyncContents = new Vector<SyncOperation>();
mCancellationRequested = new AtomicBoolean(false);
}
mCancellationRequested = new AtomicBoolean(false);
}
@@
-291,7
+291,7
@@
public class SynchronizeFolderOperation extends SyncOperation {
List<OCFile> updatedFiles = new Vector<OCFile>(folderAndFiles.size() - 1);
mFilesForDirectDownload.clear();
mFilesToSyncContentsWithoutUpload.clear();
List<OCFile> updatedFiles = new Vector<OCFile>(folderAndFiles.size() - 1);
mFilesForDirectDownload.clear();
mFilesToSyncContentsWithoutUpload.clear();
- mF
avouriteF
ilesToSyncContents.clear();
+ mFilesToSyncContents.clear();
if (mCancellationRequested.get()) {
throw new OperationCancelledException();
if (mCancellationRequested.get()) {
throw new OperationCancelledException();
@@
-353,14
+353,15
@@
public class SynchronizeFolderOperation extends SyncOperation {
/// classify file to sync/download contents later
if (remoteFile.isFolder()) {
/// to download children files recursively
/// 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());
}
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,
/// prepare content synchronization for kept-in-sync files
SynchronizeFileOperation operation = new SynchronizeFileOperation(
localFile,
@@
-369,9
+370,9
@@
public class SynchronizeFolderOperation extends SyncOperation {
true,
mContext
);
true,
mContext
);
- mF
avouriteF
ilesToSyncContents.add(operation);
+ mFilesToSyncContents.add(operation);
- } else {
+
/*
} else {
/// prepare limited synchronization for regular files
SynchronizeFileOperation operation = new SynchronizeFileOperation(
localFile,
/// prepare limited synchronization for regular files
SynchronizeFileOperation operation = new SynchronizeFileOperation(
localFile,
@@
-381,7
+382,7
@@
public class SynchronizeFolderOperation extends SyncOperation {
false,
mContext
);
false,
mContext
);
- mFilesToSyncContentsWithoutUpload.add(operation);
+ mFilesToSyncContentsWithoutUpload.add(operation);
*/
}
updatedFiles.add(remoteFile);
}
updatedFiles.add(remoteFile);
@@
-411,7
+412,20
@@
public class SynchronizeFolderOperation extends SyncOperation {
/// prepare limited synchronization for regular files
if (!child.isDown()) {
mFilesForDirectDownload.add(child);
/// 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);
+
}
}
+
}
}
}
}
}
}
@@
-420,7
+434,7
@@
public class SynchronizeFolderOperation extends SyncOperation {
private void syncContents(OwnCloudClient client) throws OperationCancelledException {
startDirectDownloads();
startContentSynchronizations(mFilesToSyncContentsWithoutUpload, client);
private void syncContents(OwnCloudClient client) throws OperationCancelledException {
startDirectDownloads();
startContentSynchronizations(mFilesToSyncContentsWithoutUpload, client);
- startContentSynchronizations(mF
avouriteF
ilesToSyncContents, client);
+ startContentSynchronizations(mFilesToSyncContents, client);
}
}
diff --git
a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java
b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java
index
d4b1ffd
..
bf8d798
100644
(file)
--- a/
src/com/owncloud/android/ui/fragment/FileDetailFragment.java
+++ b/
src/com/owncloud/android/ui/fragment/FileDetailFragment.java
@@
-252,7
+252,7
@@
public class FileDetailFragment extends FileFragment implements OnClickListener
}
case R.id.action_download_file:
case R.id.action_sync_file: {
}
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: {
return true;
}
case R.id.action_send_file: {
@@
-297,7
+297,6
@@
public class FileDetailFragment extends FileFragment implements OnClickListener
}
}
}
}
-
/**
* Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced.
*
/**
* Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced.
*
diff --git
a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java
b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java
index
02bd845
..
e98f9e1
100644
(file)
--- a/
src/com/owncloud/android/ui/fragment/OCFileListFragment.java
+++ b/
src/com/owncloud/android/ui/fragment/OCFileListFragment.java
@@
-363,9
+363,12
@@
public class OCFileListFragment extends ExtendedListFragment implements FileActi
dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
return true;
}
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: {
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_cancel_download:
diff --git
a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java
b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java
index
b6f3682
..
0cf0922
100644
(file)
--- a/
src/com/owncloud/android/ui/preview/PreviewImageFragment.java
+++ b/
src/com/owncloud/android/ui/preview/PreviewImageFragment.java
@@
-311,7
+311,7
@@
public class PreviewImageFragment extends FileFragment {
return true;
}
case R.id.action_sync_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_favorite_file:{
diff --git
a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java
b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java
index
0dbb1a3
..
cc0f064
100644
(file)
--- a/
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java
+++ b/
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java
@@
-378,7
+378,7
@@
public class PreviewMediaFragment extends FileFragment implements
return true;
}
case R.id.action_sync_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_favorite_file:{
diff --git
a/src/com/owncloud/android/ui/preview/PreviewTextFragment.java
b/src/com/owncloud/android/ui/preview/PreviewTextFragment.java
index
6595bf7
..
82c2eee
100644
(file)
--- a/
src/com/owncloud/android/ui/preview/PreviewTextFragment.java
+++ b/
src/com/owncloud/android/ui/preview/PreviewTextFragment.java
@@
-324,7
+324,7
@@
public class PreviewTextFragment extends FileFragment {
return true;
}
case R.id.action_sync_file: {
return true;
}
case R.id.action_sync_file: {
- mContainerActivity.getFileOperationsHelper().syncFile(getFile());
+ mContainerActivity.getFileOperationsHelper().syncFile(getFile()
, true
);
return true;
}
return true;
}