aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien
diff options
context:
space:
mode:
authoreuxane2024-09-18 23:41:13 +0200
committereuxane2024-09-18 23:41:13 +0200
commit2c8f6a263eaea823b107c3d1c19999a8cd3d889d (patch)
tree6b4382778c91cead931218d04c3c840ec5a2b51b /app/src/main/java/org/pacien
parent617acb7b7d068d0b18613d93e9f53df0f1633851 (diff)
downloadtincapp-2c8f6a263eaea823b107c3d1c19999a8cd3d889d.tar.gz
storageprovider: fix findDocumentPath with absolute paths
Diffstat (limited to 'app/src/main/java/org/pacien')
-rw-r--r--app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt b/app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt
index 1e5fd6f..6af8b1b 100644
--- a/app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt
+++ b/app/src/main/java/org/pacien/tincapp/storageprovider/FilesDocumentsProvider.kt
@@ -37,7 +37,7 @@ import org.pacien.tincapp.utils.pathUnder
37import java.io.File 37import java.io.File
38import java.io.FileNotFoundException 38import java.io.FileNotFoundException
39import kotlin.io.path.Path 39import kotlin.io.path.Path
40import kotlin.io.path.name 40import kotlin.io.path.pathString
41import kotlin.io.path.relativeTo 41import kotlin.io.path.relativeTo
42 42
43class FilesDocumentsProvider : DocumentsProvider() { 43class FilesDocumentsProvider : DocumentsProvider() {
@@ -125,8 +125,11 @@ class FilesDocumentsProvider : DocumentsProvider() {
125 if (parentDocumentId != null) 125 if (parentDocumentId != null)
126 childPath = childPath.relativeTo(Path(parentDocumentId)) 126 childPath = childPath.relativeTo(Path(parentDocumentId))
127 127
128 val components = childPath.asSequence().map { it.name }.toList() 128 val subPaths = (1 .. childPath.nameCount).map {
129 return DocumentsContract.Path(ROOT_ID, listOf(ROOT_DOCUMENT_ID) + components) 129 childPath.subpath(0, it).pathString
130 }.toList()
131
132 return DocumentsContract.Path(ROOT_ID, listOf(ROOT_DOCUMENT_ID) + subPaths)
130 } 133 }
131 134
132 override fun isChildDocument(parentDocumentId: String?, documentId: String?): Boolean = 135 override fun isChildDocument(parentDocumentId: String?, documentId: String?): Boolean =