mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
Merge remote-tracking branch 'rhabbachi/feature/308_sync_folder' into download_folder
This commit is contained in:
commit
34433e924d
2 changed files with 45 additions and 11 deletions
|
@ -148,7 +148,7 @@ public class FileMenuFilter {
|
|||
/// decision is taken for each possible action on a file in the menu
|
||||
|
||||
// DOWNLOAD
|
||||
if (mFile == null || mFile.isFolder() || mFile.isDown() || downloading || uploading) {
|
||||
if (mFile == null || mFile.isDown() || downloading || uploading) {
|
||||
toHide.add(R.id.action_download_file);
|
||||
|
||||
} else {
|
||||
|
|
|
@ -23,11 +23,13 @@ import android.accounts.Account;
|
|||
import android.accounts.AccountManager;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
|
||||
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
|
||||
|
@ -40,6 +42,10 @@ import com.owncloud.android.services.OperationsService;
|
|||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.ui.dialog.ShareLinkToDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author masensio
|
||||
|
@ -197,18 +203,46 @@ public class FileOperationsHelper {
|
|||
|
||||
|
||||
public void syncFile(OCFile file) {
|
||||
// Sync file
|
||||
Intent service = new Intent(mFileActivity, OperationsService.class);
|
||||
service.setAction(OperationsService.ACTION_SYNC_FILE);
|
||||
service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
|
||||
service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
|
||||
service.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true);
|
||||
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service);
|
||||
|
||||
mFileActivity.showLoadingDialog();
|
||||
Vector<OCFile> filesList = new Vector<OCFile>();
|
||||
if (!file.isFolder()){
|
||||
filesList.add(file);
|
||||
}else {
|
||||
// Add files recursivly
|
||||
FileDataStorageManager storageManager = mFileActivity.getStorageManager();
|
||||
filesList.addAll(storageManager.getFolderContent(file));
|
||||
boolean newfiles;
|
||||
do {
|
||||
Vector<OCFile> tmpFolders = new Vector<OCFile>();
|
||||
for (OCFile tmpfile : filesList) {
|
||||
if (tmpfile.isFolder()) {
|
||||
tmpFolders.add(tmpfile);
|
||||
}
|
||||
}
|
||||
if (tmpFolders.isEmpty()){
|
||||
newfiles = false;
|
||||
}else {
|
||||
for(OCFile tmpFolder : tmpFolders){
|
||||
filesList.remove(tmpFolder);
|
||||
filesList.addAll(storageManager.getFolderContent(tmpFolder));
|
||||
}
|
||||
newfiles = true;
|
||||
}
|
||||
}while(newfiles);
|
||||
}
|
||||
// Sync file(s)
|
||||
for (OCFile childFile : filesList) {
|
||||
Intent service = new Intent(mFileActivity, OperationsService.class);
|
||||
service.setAction(OperationsService.ACTION_SYNC_FILE);
|
||||
service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
|
||||
service.putExtra(OperationsService.EXTRA_REMOTE_PATH, childFile.getRemotePath());
|
||||
service.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true);
|
||||
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service);
|
||||
}
|
||||
if (!file.isFolder()) {
|
||||
mFileActivity.showLoadingDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void renameFile(OCFile file, String newFilename) {
|
||||
// RenameFile
|
||||
Intent service = new Intent(mFileActivity, OperationsService.class);
|
||||
|
|
Loading…
Reference in a new issue