diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java index 89f83d0406..92478acdca 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java @@ -751,7 +751,15 @@ public class OCFileListAdapter extends RecyclerView.Adapter files = OCShareToOCFileConverter.buildOCFilesFromShares(shares); + + // set localPath of individual files iff present on device + for (OCFile file : files) { + FileStorageUtils.searchForLocalFileInDefaultPath(file, user.getAccountName()); + } + + mFiles.clear(); mFiles.addAll(files); mStorageManager.saveShares(shares); } @@ -1018,27 +1026,4 @@ public class OCFileListAdapter extends RecyclerView.Adapter mFiles = mAdapter.getFiles(); + mFiles.set(mFiles.indexOf(file), file); mAdapter.notifyItemChanged(file); } diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/SharedListFragment.kt b/app/src/main/java/com/owncloud/android/ui/fragment/SharedListFragment.kt index 9ff9f5f7a5..05d76ad9de 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/SharedListFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/fragment/SharedListFragment.kt @@ -101,7 +101,6 @@ class SharedListFragment : OCFileListFragment(), Injectable { isSharedWithSharee = partialFile.isSharedWithSharee sharees = partialFile.sharees } - adapter.replaceFileByRemotePath(savedFile, false) savedFile } } @@ -120,6 +119,25 @@ class SharedListFragment : OCFileListFragment(), Injectable { } } + private fun fetchAllAndRun(partialFiles: MutableSet?, callback: (MutableSet?) -> Unit) { + lifecycleScope.launch { + isLoading = true + if (partialFiles != null) { + val files = partialFiles.toMutableSet().mapNotNull {partialFile -> + fetchFileData(partialFile).also {fetched -> + if (fetched == null) { + DisplayUtils.showSnackMessage(requireActivity(), R.string.error_retrieving_file) + } + } + } + isLoading = false + callback(files.toHashSet()) + } else { + isLoading = false + } + } + } + override fun onShareIconClick(file: OCFile) { fetchFileAndRun(file) { fetched -> super.onShareIconClick(fetched) @@ -145,16 +163,32 @@ class SharedListFragment : OCFileListFragment(), Injectable { } override fun onItemClicked(file: OCFile) { - fetchFileAndRun(file) { fetched -> - super.onItemClicked(fetched) + // if in multi select keep mock file + if (adapter.isMultiSelect()) { + super.onItemClicked(file) + } else { + fetchFileAndRun(file) { fetched -> + super.onItemClicked(fetched) + } } } - override fun onLongItemClicked(file: OCFile): Boolean { - fetchFileAndRun(file) { fetched -> - super.onLongItemClicked(fetched) + override fun onFileActionChosen(itemId: Int, checkedFiles: MutableSet?): Boolean { + // fetch all files and run selected action + if (itemId != R.id.action_select_all_action_menu && itemId != R.id.action_deselect_all_action_menu) { + fetchAllAndRun(checkedFiles) {files -> + exitSelectionMode() + super.onFileActionChosen(itemId, files) + } + return true + } else { + return super.onFileActionChosen(itemId, checkedFiles) } - return true + } + + override fun onRefresh() { + exitSelectionMode() + super.onRefresh() } companion object {