diff options
author | euxane | 2024-09-18 23:41:13 +0200 |
---|---|---|
committer | euxane | 2024-09-18 23:41:13 +0200 |
commit | 2c8f6a263eaea823b107c3d1c19999a8cd3d889d (patch) | |
tree | 6b4382778c91cead931218d04c3c840ec5a2b51b /app/src/main/java/org/pacien | |
parent | 617acb7b7d068d0b18613d93e9f53df0f1633851 (diff) | |
download | tincapp-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.kt | 9 |
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 | |||
37 | import java.io.File | 37 | import java.io.File |
38 | import java.io.FileNotFoundException | 38 | import java.io.FileNotFoundException |
39 | import kotlin.io.path.Path | 39 | import kotlin.io.path.Path |
40 | import kotlin.io.path.name | 40 | import kotlin.io.path.pathString |
41 | import kotlin.io.path.relativeTo | 41 | import kotlin.io.path.relativeTo |
42 | 42 | ||
43 | class FilesDocumentsProvider : DocumentsProvider() { | 43 | class 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 = |