Skip to content

Commit 087eac6

Browse files
committed
Shares: Honor write/delete permissions inside shared folders
The "Shares" bottom-bar tab navigates with FileListOption.SHARED_BY_LINK, which treated every screen under it as a flat list. As a result the FAB and the Remove/Rename/Move menu items were hidden even when standing inside a folder shared with full Create/Change/Delete permissions. Restrict the flat-list assumption to the root: show the FAB inside SHARED_BY_LINK sub-folders when the folder grants add-file/subdirectory permission, and let onlySharedByLinkFiles flag only at the root so the file's own permissions gate Remove/Rename/Move. Fixes #193
1 parent e0354b1 commit 087eac6

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

opencloudApp/src/main/java/eu/opencloud/android/presentation/files/filelist/MainFileListFragment.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,13 +994,18 @@ class MainFileListFragment : Fragment(),
994994
* Check whether the fab should be shown or hidden depending on the [FileListOption] and
995995
* the current folder displayed permissions
996996
*
997-
* Show FAB when [FileListOption.ALL_FILES] and not picking a folder
998-
* Hide FAB When [FileListOption.SHARED_BY_LINK], [FileListOption.AV_OFFLINE] or picking a folder
997+
* Show FAB when [FileListOption.ALL_FILES], or when inside a sub-folder reached via
998+
* [FileListOption.SHARED_BY_LINK] (i.e. a folder shared with the user in the Shares space)
999+
* and the current folder grants add-file or add-subdirectory permission.
1000+
* Hide FAB at the flat-list roots ([FileListOption.SHARED_BY_LINK] root,
1001+
* [FileListOption.AV_OFFLINE]) or when picking a folder.
9991002
*
10001003
* @param newFileListOption new file list option to enable.
10011004
*/
10021005
private fun showOrHideFab(newFileListOption: FileListOption, currentFolder: OCFile) {
1003-
if (!newFileListOption.isAllFiles() || isPickingAFolder() ||
1006+
val isFabSupportedView = newFileListOption.isAllFiles() ||
1007+
(newFileListOption.isSharedByLink() && currentFolder.remotePath != ROOT_PATH)
1008+
if (!isFabSupportedView || isPickingAFolder() ||
10041009
(!currentFolder.hasAddFilePermission && !currentFolder.hasAddSubdirectoriesPermission)) {
10051010
toggleFabVisibility(false)
10061011
} else {

opencloudApp/src/main/java/eu/opencloud/android/presentation/files/filelist/MainFileListViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ class MainFileListViewModel(
319319
displaySelectAll = displaySelectAll,
320320
displaySelectInverse = isMultiselection,
321321
onlyAvailableOfflineFiles = fileListOption.value.isAvailableOffline(),
322-
onlySharedByLinkFiles = fileListOption.value.isSharedByLink(),
322+
onlySharedByLinkFiles = fileListOption.value.isSharedByLink() &&
323+
currentFolderDisplayed.value.remotePath == ROOT_PATH,
323324
shareViaLinkAllowed = shareViaLinkAllowed,
324325
shareWithUsersAllowed = shareWithUsersAllowed,
325326
sendAllowed = sendAllowed,

0 commit comments

Comments
 (0)