mirror of
https://github.com/nextcloud/android.git
synced 2024-11-28 10:18:59 +03:00
Combine Move and Copy feature
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
78fa3851fd
commit
3657488332
12 changed files with 28 additions and 108 deletions
|
@ -39,8 +39,7 @@ enum class FileAction(@IdRes val id: Int, @StringRes val title: Int, @DrawableRe
|
||||||
|
|
||||||
// File moving
|
// File moving
|
||||||
RENAME_FILE(R.id.action_rename_file, R.string.common_rename, R.drawable.ic_rename),
|
RENAME_FILE(R.id.action_rename_file, R.string.common_rename, R.drawable.ic_rename),
|
||||||
MOVE(R.id.action_move, R.string.actionbar_move, R.drawable.ic_move),
|
MOVE_OR_COPY(R.id.action_move_or_copy, R.string.actionbar_move_or_copy, R.drawable.ic_move),
|
||||||
COPY(R.id.action_copy, R.string.actionbar_copy, R.drawable.ic_content_copy),
|
|
||||||
|
|
||||||
// favorites
|
// favorites
|
||||||
FAVORITE(R.id.action_favorite, R.string.favorite, R.drawable.ic_star),
|
FAVORITE(R.id.action_favorite, R.string.favorite, R.drawable.ic_star),
|
||||||
|
@ -83,8 +82,7 @@ enum class FileAction(@IdRes val id: Int, @StringRes val title: Int, @DrawableRe
|
||||||
SEE_DETAILS,
|
SEE_DETAILS,
|
||||||
LOCK_FILE,
|
LOCK_FILE,
|
||||||
RENAME_FILE,
|
RENAME_FILE,
|
||||||
MOVE,
|
MOVE_OR_COPY,
|
||||||
COPY,
|
|
||||||
DOWNLOAD_FILE,
|
DOWNLOAD_FILE,
|
||||||
EXPORT_FILE,
|
EXPORT_FILE,
|
||||||
STREAM_MEDIA,
|
STREAM_MEDIA,
|
||||||
|
|
|
@ -161,8 +161,7 @@ public class FileMenuFilter {
|
||||||
filterDownload(toHide, synchronizing);
|
filterDownload(toHide, synchronizing);
|
||||||
filterExport(toHide);
|
filterExport(toHide);
|
||||||
filterRename(toHide, synchronizing);
|
filterRename(toHide, synchronizing);
|
||||||
filterCopy(toHide, synchronizing);
|
filterMoveOrCopy(toHide, synchronizing);
|
||||||
filterMove(toHide, synchronizing);
|
|
||||||
filterRemove(toHide, synchronizing);
|
filterRemove(toHide, synchronizing);
|
||||||
filterSelectAll(toHide, inSingleFileFragment);
|
filterSelectAll(toHide, inSingleFileFragment);
|
||||||
filterDeselectAll(toHide, inSingleFileFragment);
|
filterDeselectAll(toHide, inSingleFileFragment);
|
||||||
|
@ -346,19 +345,12 @@ public class FileMenuFilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filterMove(List<Integer> toHide, boolean synchronizing) {
|
private void filterMoveOrCopy(List<Integer> toHide, boolean synchronizing) {
|
||||||
if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) {
|
if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) {
|
||||||
toHide.add(R.id.action_move);
|
toHide.add(R.id.action_move_or_copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filterCopy(List<Integer> toHide, boolean synchronizing) {
|
|
||||||
if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
|
|
||||||
toHide.add(R.id.action_copy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void filterRename(Collection<Integer> toHide, boolean synchronizing) {
|
private void filterRename(Collection<Integer> toHide, boolean synchronizing) {
|
||||||
if (!isSingleSelection() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) {
|
if (!isSingleSelection() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) {
|
||||||
toHide.add(R.id.action_rename_file);
|
toHide.add(R.id.action_rename_file);
|
||||||
|
|
|
@ -204,8 +204,7 @@ public class FileDisplayActivity extends FileActivity
|
||||||
|
|
||||||
public static final int REQUEST_CODE__SELECT_CONTENT_FROM_APPS = REQUEST_CODE__LAST_SHARED + 1;
|
public static final int REQUEST_CODE__SELECT_CONTENT_FROM_APPS = REQUEST_CODE__LAST_SHARED + 1;
|
||||||
public static final int REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM = REQUEST_CODE__LAST_SHARED + 2;
|
public static final int REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM = REQUEST_CODE__LAST_SHARED + 2;
|
||||||
public static final int REQUEST_CODE__MOVE_FILES = REQUEST_CODE__LAST_SHARED + 3;
|
public static final int REQUEST_CODE__MOVE_OR_COPY_FILES = REQUEST_CODE__LAST_SHARED + 3;
|
||||||
public static final int REQUEST_CODE__COPY_FILES = REQUEST_CODE__LAST_SHARED + 4;
|
|
||||||
public static final int REQUEST_CODE__UPLOAD_FROM_CAMERA = REQUEST_CODE__LAST_SHARED + 5;
|
public static final int REQUEST_CODE__UPLOAD_FROM_CAMERA = REQUEST_CODE__LAST_SHARED + 5;
|
||||||
public static final int REQUEST_CODE__UPLOAD_SCAN_DOC_FROM_CAMERA = REQUEST_CODE__LAST_SHARED + 6;
|
public static final int REQUEST_CODE__UPLOAD_SCAN_DOC_FROM_CAMERA = REQUEST_CODE__LAST_SHARED + 6;
|
||||||
|
|
||||||
|
@ -887,31 +886,10 @@ public class FileDisplayActivity extends FileActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new String[]{FileOperationsHelper.createImageFile(getActivity()).getAbsolutePath()}).execute();
|
}, new String[]{FileOperationsHelper.createImageFile(getActivity()).getAbsolutePath()}).execute();
|
||||||
} else if (requestCode == REQUEST_CODE__MOVE_FILES && resultCode == RESULT_OK) {
|
} else if (requestCode == REQUEST_CODE__MOVE_OR_COPY_FILES && resultCode == RESULT_OK) {
|
||||||
exitSelectionMode();
|
exitSelectionMode();
|
||||||
final Intent fData = data;
|
final Intent fData = data;
|
||||||
getHandler().postDelayed(
|
getHandler().postDelayed(() -> requestMoveOrCopyOperation(fData), DELAY_TO_REQUEST_OPERATIONS_LATER);
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
requestMoveOperation(fData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
DELAY_TO_REQUEST_OPERATIONS_LATER
|
|
||||||
);
|
|
||||||
|
|
||||||
} else if (requestCode == REQUEST_CODE__COPY_FILES && resultCode == RESULT_OK) {
|
|
||||||
exitSelectionMode();
|
|
||||||
final Intent fData = data;
|
|
||||||
getHandler().postDelayed(
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
requestCopyOperation(fData);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
DELAY_TO_REQUEST_OPERATIONS_LATER
|
|
||||||
);
|
|
||||||
} else if (requestCode == PermissionUtil.REQUEST_CODE_MANAGE_ALL_FILES) {
|
} else if (requestCode == PermissionUtil.REQUEST_CODE_MANAGE_ALL_FILES) {
|
||||||
syncAndUpdateFolder(true);
|
syncAndUpdateFolder(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1018,26 +996,11 @@ public class FileDisplayActivity extends FileActivity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void requestMoveOrCopyOperation(Intent data) {
|
||||||
* Request the operation for moving the file/folder from one path to another
|
final OCFile file = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
|
||||||
*
|
|
||||||
* @param data Intent received
|
|
||||||
*/
|
|
||||||
private void requestMoveOperation(Intent data) {
|
|
||||||
final OCFile folderToMoveAt = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
|
|
||||||
final List<String> filePaths = data.getStringArrayListExtra(FolderPickerActivity.EXTRA_FILE_PATHS);
|
final List<String> filePaths = data.getStringArrayListExtra(FolderPickerActivity.EXTRA_FILE_PATHS);
|
||||||
getFileOperationsHelper().moveFiles(filePaths, folderToMoveAt);
|
assert filePaths != null;
|
||||||
}
|
getFileOperationsHelper().moveOrCopyFiles(filePaths, file);
|
||||||
|
|
||||||
/**
|
|
||||||
* Request the operation for copying the file/folder from one path to another
|
|
||||||
*
|
|
||||||
* @param data Intent received
|
|
||||||
*/
|
|
||||||
private void requestCopyOperation(Intent data) {
|
|
||||||
final OCFile targetFolder = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
|
|
||||||
final List<String> filePaths = data.getStringArrayListExtra(FolderPickerActivity.EXTRA_FILE_PATHS);
|
|
||||||
getFileOperationsHelper().copyFiles(filePaths, targetFolder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSearchOpen() {
|
private boolean isSearchOpen() {
|
||||||
|
|
|
@ -347,7 +347,7 @@ open class FolderPickerActivity :
|
||||||
// for copy and move, disable selecting parent folder of target files
|
// for copy and move, disable selecting parent folder of target files
|
||||||
private fun checkFolderSelectable(): Boolean {
|
private fun checkFolderSelectable(): Boolean {
|
||||||
return when {
|
return when {
|
||||||
mAction != COPY && mAction != MOVE -> true
|
mAction != MOVE_OR_COPY -> true
|
||||||
mTargetFilePaths.isNullOrEmpty() -> true
|
mTargetFilePaths.isNullOrEmpty() -> true
|
||||||
file?.isFolder != true -> true
|
file?.isFolder != true -> true
|
||||||
// all of the target files are already in the selected directory
|
// all of the target files are already in the selected directory
|
||||||
|
@ -588,8 +588,7 @@ open class FolderPickerActivity :
|
||||||
@JvmField
|
@JvmField
|
||||||
val EXTRA_ACTION = FolderPickerActivity::class.java.canonicalName?.plus(".EXTRA_ACTION")
|
val EXTRA_ACTION = FolderPickerActivity::class.java.canonicalName?.plus(".EXTRA_ACTION")
|
||||||
|
|
||||||
const val MOVE = "MOVE"
|
const val MOVE_OR_COPY = "MOVE_OR_COPY"
|
||||||
const val COPY = "COPY"
|
|
||||||
const val CHOOSE_LOCATION = "CHOOSE_LOCATION"
|
const val CHOOSE_LOCATION = "CHOOSE_LOCATION"
|
||||||
private val TAG = FolderPickerActivity::class.java.simpleName
|
private val TAG = FolderPickerActivity::class.java.simpleName
|
||||||
protected const val TAG_LIST_OF_FOLDERS = "LIST_OF_FOLDERS"
|
protected const val TAG_LIST_OF_FOLDERS = "LIST_OF_FOLDERS"
|
||||||
|
|
|
@ -278,8 +278,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
||||||
R.id.action_favorite,
|
R.id.action_favorite,
|
||||||
R.id.action_unset_favorite,
|
R.id.action_unset_favorite,
|
||||||
R.id.action_see_details,
|
R.id.action_see_details,
|
||||||
R.id.action_move,
|
R.id.action_move_or_copy,
|
||||||
R.id.action_copy,
|
|
||||||
R.id.action_stream_media,
|
R.id.action_stream_media,
|
||||||
R.id.action_send_share_file,
|
R.id.action_send_share_file,
|
||||||
R.id.action_pin_to_homescreen
|
R.id.action_pin_to_homescreen
|
||||||
|
|
|
@ -1235,11 +1235,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||||
} else if (itemId == R.id.action_unset_favorite) {
|
} else if (itemId == R.id.action_unset_favorite) {
|
||||||
mContainerActivity.getFileOperationsHelper().toggleFavoriteFiles(checkedFiles, false);
|
mContainerActivity.getFileOperationsHelper().toggleFavoriteFiles(checkedFiles, false);
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_move) {
|
} else if (itemId == R.id.action_move_or_copy) {
|
||||||
pickFolderForMoveOrCopy(FolderPickerActivity.MOVE, checkedFiles);
|
pickFolderForMoveOrCopy(FolderPickerActivity.MOVE_OR_COPY, checkedFiles);
|
||||||
return true;
|
|
||||||
} else if (itemId == R.id.action_copy) {
|
|
||||||
pickFolderForMoveOrCopy(FolderPickerActivity.COPY, checkedFiles);
|
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_select_all_action_menu) {
|
} else if (itemId == R.id.action_select_all_action_menu) {
|
||||||
selectAllFiles(true);
|
selectAllFiles(true);
|
||||||
|
@ -1259,14 +1256,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||||
|
|
||||||
private void pickFolderForMoveOrCopy(final String extraAction, final Set<OCFile> checkedFiles) {
|
private void pickFolderForMoveOrCopy(final String extraAction, final Set<OCFile> checkedFiles) {
|
||||||
int requestCode;
|
int requestCode;
|
||||||
switch (extraAction) {
|
if (extraAction.equals(FolderPickerActivity.MOVE_OR_COPY)) {
|
||||||
case FolderPickerActivity.MOVE:
|
requestCode = FileDisplayActivity.REQUEST_CODE__MOVE_OR_COPY_FILES;
|
||||||
requestCode = FileDisplayActivity.REQUEST_CODE__MOVE_FILES;
|
} else {
|
||||||
break;
|
|
||||||
case FolderPickerActivity.COPY:
|
|
||||||
requestCode = FileDisplayActivity.REQUEST_CODE__COPY_FILES;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unknown extra action: " + extraAction);
|
throw new IllegalArgumentException("Unknown extra action: " + extraAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1007,30 +1007,10 @@ public class FileOperationsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void moveOrCopyFiles(final List<String> filePaths, final OCFile targetFolder) {
|
||||||
* Start operations to move one or several files
|
|
||||||
*
|
|
||||||
* @param filePaths Remote paths of files to move
|
|
||||||
* @param targetFolder Folder where the files while be moved into
|
|
||||||
*/
|
|
||||||
public void moveFiles(final List<String> filePaths, final OCFile targetFolder) {
|
|
||||||
copyOrMoveFiles(OperationsService.ACTION_MOVE_FILE, filePaths, targetFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start operations to copy one or several files
|
|
||||||
*
|
|
||||||
* @param filePaths Remote paths of files to move
|
|
||||||
* @param targetFolder Folder where the files while be copied into
|
|
||||||
*/
|
|
||||||
public void copyFiles(final List<String> filePaths, final OCFile targetFolder) {
|
|
||||||
copyOrMoveFiles(OperationsService.ACTION_COPY_FILE, filePaths, targetFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void copyOrMoveFiles(final String action, final List<String> filePaths, final OCFile targetFolder) {
|
|
||||||
for (String path : filePaths) {
|
for (String path : filePaths) {
|
||||||
Intent service = new Intent(fileActivity, OperationsService.class);
|
Intent service = new Intent(fileActivity, OperationsService.class);
|
||||||
service.setAction(action);
|
//service.setAction(OperationsService.ACTION_MOVE_OR_COPY_FILE);
|
||||||
service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, targetFolder.getRemotePath());
|
service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, targetFolder.getRemotePath());
|
||||||
service.putExtra(OperationsService.EXTRA_REMOTE_PATH, path);
|
service.putExtra(OperationsService.EXTRA_REMOTE_PATH, path);
|
||||||
service.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
service.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||||
|
|
|
@ -375,8 +375,7 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
R.id.action_rename_file,
|
R.id.action_rename_file,
|
||||||
R.id.action_sync_file,
|
R.id.action_sync_file,
|
||||||
R.id.action_move,
|
R.id.action_move_or_copy,
|
||||||
R.id.action_copy,
|
|
||||||
R.id.action_favorite,
|
R.id.action_favorite,
|
||||||
R.id.action_unset_favorite,
|
R.id.action_unset_favorite,
|
||||||
R.id.action_pin_to_homescreen
|
R.id.action_pin_to_homescreen
|
||||||
|
|
|
@ -424,8 +424,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
R.id.action_rename_file,
|
R.id.action_rename_file,
|
||||||
R.id.action_sync_file,
|
R.id.action_sync_file,
|
||||||
R.id.action_move,
|
R.id.action_move_or_copy,
|
||||||
R.id.action_copy,
|
|
||||||
R.id.action_favorite,
|
R.id.action_favorite,
|
||||||
R.id.action_unset_favorite,
|
R.id.action_unset_favorite,
|
||||||
R.id.action_pin_to_homescreen
|
R.id.action_pin_to_homescreen
|
||||||
|
|
|
@ -300,8 +300,7 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
R.id.action_rename_file,
|
R.id.action_rename_file,
|
||||||
R.id.action_sync_file,
|
R.id.action_sync_file,
|
||||||
R.id.action_move,
|
R.id.action_move_or_copy,
|
||||||
R.id.action_copy,
|
|
||||||
R.id.action_favorite,
|
R.id.action_favorite,
|
||||||
R.id.action_unset_favorite,
|
R.id.action_unset_favorite,
|
||||||
R.id.action_pin_to_homescreen
|
R.id.action_pin_to_homescreen
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
<item name="action_see_details" type="id"/>
|
<item name="action_see_details" type="id"/>
|
||||||
<item name="action_lock_file" type="id"/>
|
<item name="action_lock_file" type="id"/>
|
||||||
<item name="action_rename_file" type="id"/>
|
<item name="action_rename_file" type="id"/>
|
||||||
<item name="action_move" type="id"/>
|
<item name="action_move_or_copy" type="id"/>
|
||||||
<item name="action_copy" type="id"/>
|
|
||||||
<item name="action_download_file" type="id"/>
|
<item name="action_download_file" type="id"/>
|
||||||
<item name="action_export_file" type="id"/>
|
<item name="action_export_file" type="id"/>
|
||||||
<item name="action_stream_media" type="id"/>
|
<item name="action_stream_media" type="id"/>
|
||||||
|
|
|
@ -428,6 +428,7 @@
|
||||||
<string name="log_send_no_mail_app">No app for sending logs found. Please install an email client.</string>
|
<string name="log_send_no_mail_app">No app for sending logs found. Please install an email client.</string>
|
||||||
<string name="log_send_mail_subject">%1$s Android app logs</string>
|
<string name="log_send_mail_subject">%1$s Android app logs</string>
|
||||||
|
|
||||||
|
<string name="actionbar_move_or_copy">Move or Copy</string>
|
||||||
<string name="actionbar_move">Move</string>
|
<string name="actionbar_move">Move</string>
|
||||||
<string name="actionbar_copy">Copy</string>
|
<string name="actionbar_copy">Copy</string>
|
||||||
<string name="file_list_empty_moving">Nothing in here. You can add a folder.</string>
|
<string name="file_list_empty_moving">Nothing in here. You can add a folder.</string>
|
||||||
|
|
Loading…
Reference in a new issue