mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 14:15:44 +03:00
Fix logic for move and copy
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
3657488332
commit
a0ede76437
3 changed files with 26 additions and 9 deletions
|
@ -885,11 +885,12 @@ public class FileDisplayActivity extends FileActivity
|
|||
FileUploader.LOCAL_BEHAVIOUR_DELETE);
|
||||
}
|
||||
}
|
||||
}, new String[]{FileOperationsHelper.createImageFile(getActivity()).getAbsolutePath()}).execute();
|
||||
}, new String[] { FileOperationsHelper.createImageFile(getActivity()).getAbsolutePath() }).execute();
|
||||
} else if (requestCode == REQUEST_CODE__MOVE_OR_COPY_FILES && resultCode == RESULT_OK) {
|
||||
exitSelectionMode();
|
||||
final Intent fData = data;
|
||||
getHandler().postDelayed(() -> requestMoveOrCopyOperation(fData), DELAY_TO_REQUEST_OPERATIONS_LATER);
|
||||
// TODO check this implementation
|
||||
// final Intent fData = data;
|
||||
// getHandler().postDelayed(() -> requestMoveOrCopyOperation(fData), DELAY_TO_REQUEST_OPERATIONS_LATER);
|
||||
} else if (requestCode == PermissionUtil.REQUEST_CODE_MANAGE_ALL_FILES) {
|
||||
syncAndUpdateFolder(true);
|
||||
} else {
|
||||
|
@ -996,12 +997,15 @@ public class FileDisplayActivity extends FileActivity
|
|||
|
||||
}
|
||||
|
||||
private void requestMoveOrCopyOperation(Intent data) {
|
||||
/*
|
||||
private void requestMoveOrCopyOperation(Intent data) {
|
||||
final OCFile file = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
|
||||
final List<String> filePaths = data.getStringArrayListExtra(FolderPickerActivity.EXTRA_FILE_PATHS);
|
||||
assert filePaths != null;
|
||||
getFileOperationsHelper().moveOrCopyFiles(filePaths, file);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
private boolean isSearchOpen() {
|
||||
if (searchView == null) {
|
||||
|
|
|
@ -27,7 +27,9 @@ import android.content.Intent
|
|||
import android.content.IntentFilter
|
||||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import android.util.Log
|
||||
import android.view.ActionMode
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
|
@ -44,6 +46,7 @@ import com.owncloud.android.lib.common.utils.Log_OC
|
|||
import com.owncloud.android.lib.resources.files.SearchRemoteOperation
|
||||
import com.owncloud.android.operations.CreateFolderOperation
|
||||
import com.owncloud.android.operations.RefreshFolderOperation
|
||||
import com.owncloud.android.services.OperationsService
|
||||
import com.owncloud.android.syncadapter.FileSyncAdapter
|
||||
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment
|
||||
import com.owncloud.android.ui.dialog.SortingOrderDialogFragment.OnSortingOrderListener
|
||||
|
@ -378,12 +381,13 @@ open class FolderPickerActivity :
|
|||
mCopyBtn = findViewById(R.id.btnCopy)
|
||||
mMoveBtn = findViewById(R.id.btnMove)
|
||||
|
||||
// FIXME colorMaterialButtonPrimaryFilled breaks material button style
|
||||
if (mCopyBtn != null) {
|
||||
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(mCopyBtn!!)
|
||||
//viewThemeUtils.material.colorMaterialButtonPrimaryFilled(mCopyBtn!!)
|
||||
mCopyBtn!!.setOnClickListener(this)
|
||||
}
|
||||
if (mMoveBtn != null) {
|
||||
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(mMoveBtn!!)
|
||||
//viewThemeUtils.material.colorMaterialButtonPrimaryFilled(mMoveBtn!!)
|
||||
mMoveBtn!!.setOnClickListener(this)
|
||||
}
|
||||
if (mCancelBtn != null) {
|
||||
|
@ -407,7 +411,16 @@ open class FolderPickerActivity :
|
|||
if (targetFiles != null) {
|
||||
resultData.putParcelableArrayListExtra(EXTRA_FILES, targetFiles)
|
||||
}
|
||||
|
||||
mTargetFilePaths.let {
|
||||
if (it != null) {
|
||||
if (v == mCopyBtn) {
|
||||
fileOperationsHelper.moveOrCopyFiles(OperationsService.ACTION_COPY_FILE, it, file)
|
||||
} else {
|
||||
fileOperationsHelper.moveOrCopyFiles(OperationsService.ACTION_MOVE_FILE, it, file)
|
||||
}
|
||||
}
|
||||
|
||||
resultData.putStringArrayListExtra(EXTRA_FILE_PATHS, it)
|
||||
}
|
||||
setResult(RESULT_OK, resultData)
|
||||
|
|
|
@ -42,6 +42,7 @@ import android.os.Environment;
|
|||
import android.os.StatFs;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
|
@ -1007,10 +1008,10 @@ public class FileOperationsHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void moveOrCopyFiles(final List<String> filePaths, final OCFile targetFolder) {
|
||||
public void moveOrCopyFiles(String action, final List<String> filePaths, final OCFile targetFolder) {
|
||||
for (String path : filePaths) {
|
||||
Intent service = new Intent(fileActivity, OperationsService.class);
|
||||
//service.setAction(OperationsService.ACTION_MOVE_OR_COPY_FILE);
|
||||
service.setAction(action);
|
||||
service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, targetFolder.getRemotePath());
|
||||
service.putExtra(OperationsService.EXTRA_REMOTE_PATH, path);
|
||||
service.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||
|
@ -1019,7 +1020,6 @@ public class FileOperationsHelper {
|
|||
fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_a_moment));
|
||||
}
|
||||
|
||||
|
||||
public void exportFiles(Collection<OCFile> files,
|
||||
Context context,
|
||||
View view,
|
||||
|
|
Loading…
Reference in a new issue