Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/4802
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Show destination folder snackbar for copy/move operations

A snackbar message has been displayed after copy or move operations with an action button that allows users to quickly navigate to the destination folder.

https://github.com/owncloud/android/issues/4379
https://github.com/owncloud/android/pull/4802
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ fun Activity.showMessageInSnackbar(
Snackbar.make(findViewById(layoutId), message, duration).show()
}

fun Activity.showSnackbarWithAction(
message: CharSequence,
action: () -> Unit,
actionText: CharSequence,
duration: Int = Snackbar.LENGTH_LONG,
layoutId: Int = android.R.id.content
) {
Snackbar.make(findViewById(layoutId), message, duration)
.setAction(actionText) { action() }
.show()
}

fun Activity.showErrorInToast(
genericErrorMessageId: Int,
throwable: Throwable?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class FileListAdapter(
params -> params.marginStart = if (isFolderInKw) 0 else
context.resources.getDimensionPixelSize(R.dimen.standard_quarter_margin) }
it.fileListLastMod.text = DisplayUtils.getRelativeTimestamp(context, file.modificationTimestamp)
it.threeDotMenu.isVisible = getCheckedItems().isEmpty()
it.threeDotMenu.isVisible = !isPickerMode && getCheckedItems().isEmpty()
it.threeDotMenu.contentDescription = context.getString(R.string.content_description_file_operations, file.fileName)
if (fileListOption.isAvailableOffline() || (fileListOption.isSharedByLink() && fileWithSyncInfo.space == null)) {
it.spacePathLine.path.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import com.owncloud.android.extensions.parseError
import com.owncloud.android.extensions.sendDownloadedFilesByShareSheet
import com.owncloud.android.extensions.showErrorInSnackbar
import com.owncloud.android.extensions.showMessageInSnackbar
import com.owncloud.android.extensions.showSnackbarWithAction
import com.owncloud.android.lib.common.accounts.AccountUtils
import com.owncloud.android.lib.common.authentication.OwnCloudBearerCredentials
import com.owncloud.android.lib.common.network.CertificateCombinedException
Expand Down Expand Up @@ -181,6 +182,8 @@ class FileDisplayActivity : FileActivity(),
private var waitingToSend: OCFile? = null
private var waitingToOpen: OCFile? = null

private var copyMoveTargetFolder: OCFile? = null

private var localBroadcastManager: LocalBroadcastManager? = null

private val fileOperationsViewModel: FileOperationsViewModel by viewModel()
Expand Down Expand Up @@ -707,6 +710,7 @@ class FileDisplayActivity : FileActivity(),
private fun requestMoveOperation(data: Intent) {
val folderToMoveAt = data.getParcelableExtra<OCFile>(FolderPickerActivity.EXTRA_FOLDER) ?: return
val files = data.getParcelableArrayListExtra<OCFile>(FolderPickerActivity.EXTRA_FILES) ?: return
copyMoveTargetFolder = folderToMoveAt
val moveOperation = FileOperation.MoveOperation(
listOfFilesToMove = files.toList(),
targetFolder = folderToMoveAt,
Expand All @@ -723,6 +727,7 @@ class FileDisplayActivity : FileActivity(),
private fun requestCopyOperation(data: Intent) {
val folderToCopyAt = data.getParcelableExtra<OCFile>(FolderPickerActivity.EXTRA_FOLDER) ?: return
val files = data.getParcelableArrayListExtra<OCFile>(FolderPickerActivity.EXTRA_FILES) ?: return
copyMoveTargetFolder = folderToCopyAt
val copyOperation = FileOperation.CopyOperation(
listOfFilesToCopy = files.toList(),
targetFolder = folderToCopyAt,
Expand Down Expand Up @@ -1082,6 +1087,9 @@ class FileDisplayActivity : FileActivity(),
// Refresh the spaces and update the quota
spacesListViewModel.refreshSpacesFromServer()
}
if (uiResult.data.isNullOrEmpty()) {
showCopyMoveSuccessSnackbar(isCopy = false)
}
}

is UIResult.Error -> {
Expand Down Expand Up @@ -1130,6 +1138,9 @@ class FileDisplayActivity : FileActivity(),

// Refresh the spaces and update the quota
spacesListViewModel.refreshSpacesFromServer()
if (uiResult.data.isNullOrEmpty()) {
showCopyMoveSuccessSnackbar(isCopy = true)
}
}

is UIResult.Error -> {
Expand All @@ -1148,6 +1159,26 @@ class FileDisplayActivity : FileActivity(),
}
}

private fun showCopyMoveSuccessSnackbar(isCopy: Boolean) {
val message = getString(if (isCopy) R.string.copy_success_msg else R.string.move_success_msg)
val targetFolderId = copyMoveTargetFolder?.id
if (targetFolderId != null) {
showSnackbarWithAction(
message = message,
actionText = getString(R.string.go_to_destination_folder),
action = {
val fileListFragment = mainFileListFragment
?: supportFragmentManager.findFragmentById(R.id.left_fragment_container) as? MainFileListFragment
fileListFragment?.navigateToFolderId(targetFolderId)
},
layoutId = R.id.list_layout
)
} else {
showMessageInSnackbar(R.id.list_layout, message)
}
copyMoveTargetFolder = null
}

private fun showConflictDecisionDialog(
uiResult: UIResult.Success<List<OCFile>>,
data: List<OCFile>,
Expand Down
3 changes: 3 additions & 0 deletions owncloudApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@
<string name="copy_file_invalid_into_descendent">It is not possible to copy a folder into a descendant.</string>
<string name="copy_file_invalid_overwrite">The file exists already in the destination folder.</string>
<string name="copy_file_error">An error occurred while trying to copy this file or folder.</string>
<string name="copy_success_msg">The file has been copied</string>
<string name="move_success_msg">The file has been moved</string>
<string name="go_to_destination_folder">Go to target folder</string>
<string name="forbidden_permissions_copy">to copy this file</string>

<string name="prefs_category_camera_upload">Camera uploads</string>
Expand Down
Loading