Skip to content

Commit 587edb0

Browse files
committed
fix: remove documents provider permissions for shared files
1 parent 3383699 commit 587edb0

File tree

1 file changed

+13
-9
lines changed
  • owncloudApp/src/main/java/com/owncloud/android/presentation/documentsprovider/cursors

1 file changed

+13
-9
lines changed

owncloudApp/src/main/java/com/owncloud/android/presentation/documentsprovider/cursors/FileCursor.kt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
* @author Bartosz Przybylski
55
* @author Abel García de Prada
66
* @author Juan Carlos Garrote Gascón
7+
* @author Jorge Aguado Recio
78
*
89
* Copyright (C) 2015 Bartosz Przybylski
9-
* Copyright (C) 2023 ownCloud GmbH.
10+
* Copyright (C) 2025 ownCloud GmbH.
1011
*
1112
* This program is free software: you can redistribute it and/or modify
1213
* it under the terms of the GNU General Public License version 2,
@@ -28,6 +29,7 @@ import android.os.Bundle
2829
import android.provider.DocumentsContract
2930
import android.provider.DocumentsContract.Document
3031
import com.owncloud.android.domain.files.model.OCFile
32+
import com.owncloud.android.domain.spaces.model.OCSpace.Companion.SPACE_ID_SHARES
3133
import com.owncloud.android.utils.MimetypeIconUtil
3234

3335
class FileCursor(projection: Array<String>?) : MatrixCursor(projection ?: DEFAULT_DOCUMENT_PROJECTION) {
@@ -45,15 +47,17 @@ class FileCursor(projection: Array<String>?) : MatrixCursor(projection ?: DEFAUL
4547
val imagePath = if (file.isImage && file.isAvailableLocally) file.storagePath else null
4648
var flags = if (imagePath != null) Document.FLAG_SUPPORTS_THUMBNAIL else 0
4749

48-
flags = flags or Document.FLAG_SUPPORTS_DELETE
49-
flags = flags or Document.FLAG_SUPPORTS_RENAME
50-
flags = flags or Document.FLAG_SUPPORTS_COPY
51-
flags = flags or Document.FLAG_SUPPORTS_MOVE
50+
if (file.spaceId != SPACE_ID_SHARES) {
51+
flags = flags or Document.FLAG_SUPPORTS_DELETE
52+
flags = flags or Document.FLAG_SUPPORTS_RENAME
53+
flags = flags or Document.FLAG_SUPPORTS_COPY
54+
flags = flags or Document.FLAG_SUPPORTS_MOVE
5255

53-
if (mimeType != Document.MIME_TYPE_DIR) { // If it is a file
54-
flags = flags or Document.FLAG_SUPPORTS_WRITE
55-
} else if (file.hasAddFilePermission && file.hasAddSubdirectoriesPermission) { // If it is a folder with writing permissions
56-
flags = flags or Document.FLAG_DIR_SUPPORTS_CREATE
56+
if (mimeType != Document.MIME_TYPE_DIR) { // If it is a file
57+
flags = flags or Document.FLAG_SUPPORTS_WRITE
58+
} else if (file.hasAddFilePermission && file.hasAddSubdirectoriesPermission) { // If it is a folder with writing permissions
59+
flags = flags or Document.FLAG_DIR_SUPPORTS_CREATE
60+
}
5761
}
5862

5963
newRow()

0 commit comments

Comments
 (0)