From 2881d113794ccb848084c1c8be26c6d3c014fd1c Mon Sep 17 00:00:00 2001 From: LaksCastro Date: Sun, 29 May 2022 22:37:26 -0300 Subject: [PATCH 01/12] (#50) Query `COLUMN_DOCUMENT_ID` even when not requested --- .../lib/DocumentCommon.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/android/src/main/kotlin/io/lakscastro/sharedstorage/storageaccessframework/lib/DocumentCommon.kt b/android/src/main/kotlin/io/lakscastro/sharedstorage/storageaccessframework/lib/DocumentCommon.kt index ee7083c..ab358d2 100644 --- a/android/src/main/kotlin/io/lakscastro/sharedstorage/storageaccessframework/lib/DocumentCommon.kt +++ b/android/src/main/kotlin/io/lakscastro/sharedstorage/storageaccessframework/lib/DocumentCommon.kt @@ -8,14 +8,12 @@ import android.os.Build import android.provider.DocumentsContract import android.util.Base64 import androidx.annotation.RequiresApi -import androidx.annotation.RestrictTo import androidx.documentfile.provider.DocumentFile import io.lakscastro.sharedstorage.plugin.API_19 import io.lakscastro.sharedstorage.plugin.API_21 import io.lakscastro.sharedstorage.plugin.API_24 import java.io.ByteArrayOutputStream import java.io.Closeable -import java.io.File /** * Helper class to make more easy to handle callbacks using Kotlin syntax @@ -174,12 +172,17 @@ fun traverseDirectoryEntries( while (dirNodes.isNotEmpty()) { val (parent, children) = dirNodes.removeAt(0) - val requiredColumns = if (rootOnly) emptyArray() else arrayOf( - DocumentsContract.Document.COLUMN_MIME_TYPE, - DocumentsContract.Document.COLUMN_DOCUMENT_ID - ) + val requiredColumns = + if (rootOnly) emptyArray() else arrayOf(DocumentsContract.Document.COLUMN_MIME_TYPE) + + val intrinsicColumns = + arrayOf(DocumentsContract.Document.COLUMN_DOCUMENT_ID) - val projection = arrayOf(*columns, *requiredColumns).toSet().toTypedArray() + val projection = arrayOf( + *columns, + *requiredColumns, + *intrinsicColumns + ).toSet().toTypedArray() val cursor = contentResolver.query( children, @@ -220,7 +223,7 @@ fun traverseDirectoryEntries( ) ) - if (isDirectory != null && isDirectory && !rootOnly) { + if (isDirectory == true && !rootOnly) { val nextChildren = DocumentsContract.buildChildDocumentsUriUsingTree(rootUri, id) From 7b841602184fd9a9304055cc18b5486a6dc0b601 Mon Sep 17 00:00:00 2001 From: lask Date: Sun, 29 May 2022 22:38:58 -0300 Subject: [PATCH 02/12] (#50) Remove assignee from bug template --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b6bda89..0888702 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -3,7 +3,7 @@ name: Bug report about: Create a report to help us improve title: '' labels: bug -assignees: lakscastro +assignees: '' --- From 6270f2c1e5fea1edeb61e9f87f82859d2ca58ef0 Mon Sep 17 00:00:00 2001 From: lask Date: Sun, 29 May 2022 22:45:54 -0300 Subject: [PATCH 03/12] Fix missing entry file --- .all-contributorsrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 016a4dd..1044204 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,7 +1,7 @@ { "files": [ "README.md", - "docs/Getting Started.md" + "docs/index.md" ], "imageSize": 100, "contributorsPerLine": 7, From 4af6625dc3bcaa0b01e1c8270e1179c3d176689d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 01:46:26 +0000 Subject: [PATCH 04/12] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ee3f807..363751c 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ These are the brilliant minds behind the development of this plugin!
www.bibliotecaortodoxa.ro

💻 🐛 🤔
dangilbert

💻 🐛
dhaval-k-simformsolutions

🐛 🤔 +
Daniel Dunn

🐛 From 881ca0908b9fb50c8d46bd12664b633e32b1e949 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 01:46:27 +0000 Subject: [PATCH 05/12] docs: update docs/index.md [skip ci] --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 58914ce..6b04301 100644 --- a/docs/index.md +++ b/docs/index.md @@ -70,7 +70,6 @@ Most Flutter plugins use Android API's under the hood. So this plugin does the s These are the brilliant minds behind the development of this plugin! - @@ -80,6 +79,7 @@ These are the brilliant minds behind the development of this plugin! +

www.bibliotecaortodoxa.ro

💻 🐛 🤔

dangilbert

💻 🐛

dhaval-k-simformsolutions

🐛 🤔

Daniel Dunn

🐛
From c6eb77aebac5908fc92f79394132a03dbe227fad Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 01:46:28 +0000 Subject: [PATCH 06/12] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 1044204..84cba1a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -58,6 +58,15 @@ "bug", "ideas" ] + }, + { + "login": "EternityForest", + "name": "Daniel Dunn", + "avatar_url": "https://avatars.githubusercontent.com/u/758047?v=4", + "profile": "https://eternityforest.com", + "contributions": [ + "bug" + ] } ], "projectName": "shared-storage", From ce1d518d77e218967f07c26df074fe66714b4d3a Mon Sep 17 00:00:00 2001 From: LaksCastro Date: Mon, 30 May 2022 21:33:25 -0300 Subject: [PATCH 07/12] (#50) Warn that `DocumentFileColumn.id` is optional on `listFiles` docs --- docs/Usage/Storage Access Framework.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/Usage/Storage Access Framework.md b/docs/Usage/Storage Access Framework.md index 7596ef0..503f2d1 100644 --- a/docs/Usage/Storage Access Framework.md +++ b/docs/Usage/Storage Access Framework.md @@ -68,6 +68,8 @@ if (grantedUri != null) { This method list files lazily **over a granted uri:** +> **Info** `DocumentFileColumn.id` is optional. It is required to fetch the file list from native API. So it is enabled regardless if you include this column or not. And this applies only to this API (`listFiles`). + ```dart /// *Must* be a granted uri from `openDocumentTree` final Uri myGrantedUri = ... @@ -83,7 +85,7 @@ const List columns = [ DocumentFileColumn.displayName, DocumentFileColumn.size, DocumentFileColumn.lastModified, - DocumentFileColumn.id, + DocumentFileColumn.id, // Optional column, will be available/queried regardless if is or not included here DocumentFileColumn.mimeType, ]; From 4396a8ec0a196e4fc1bbd9ab44b97145f409a077 Mon Sep 17 00:00:00 2001 From: LaksCastro Date: Mon, 30 May 2022 21:33:59 -0300 Subject: [PATCH 08/12] (#50) Fix bug by using `projection` var (computed columns) rather raw `columns` --- .../sharedstorage/storageaccessframework/lib/DocumentCommon.kt | 2 +- example/lib/screens/folder_files/folder_file_list.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/kotlin/io/lakscastro/sharedstorage/storageaccessframework/lib/DocumentCommon.kt b/android/src/main/kotlin/io/lakscastro/sharedstorage/storageaccessframework/lib/DocumentCommon.kt index ab358d2..8e49462 100644 --- a/android/src/main/kotlin/io/lakscastro/sharedstorage/storageaccessframework/lib/DocumentCommon.kt +++ b/android/src/main/kotlin/io/lakscastro/sharedstorage/storageaccessframework/lib/DocumentCommon.kt @@ -201,7 +201,7 @@ fun traverseDirectoryEntries( while (cursor.moveToNext()) { val data = mutableMapOf() - for (column in columns) { + for (column in projection) { data[column] = cursorHandlerOf(typeOfColumn(column)!!)( cursor, cursor.getColumnIndexOrThrow(column) diff --git a/example/lib/screens/folder_files/folder_file_list.dart b/example/lib/screens/folder_files/folder_file_list.dart index b869d64..55399de 100644 --- a/example/lib/screens/folder_files/folder_file_list.dart +++ b/example/lib/screens/folder_files/folder_file_list.dart @@ -159,7 +159,7 @@ class _FolderFileListState extends State { DocumentFileColumn.displayName, DocumentFileColumn.size, DocumentFileColumn.lastModified, - DocumentFileColumn.id, + // DocumentFileColumn.id, DocumentFileColumn.mimeType, ]; From a3d426e54aa51b0e156dad99d85456f1bee730b2 Mon Sep 17 00:00:00 2001 From: LaksCastro Date: Mon, 30 May 2022 21:35:13 -0300 Subject: [PATCH 09/12] (#50) Add comment on `/example` at `listFiles` usage --- example/lib/screens/folder_files/folder_file_list.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/example/lib/screens/folder_files/folder_file_list.dart b/example/lib/screens/folder_files/folder_file_list.dart index 55399de..292e35f 100644 --- a/example/lib/screens/folder_files/folder_file_list.dart +++ b/example/lib/screens/folder_files/folder_file_list.dart @@ -159,7 +159,8 @@ class _FolderFileListState extends State { DocumentFileColumn.displayName, DocumentFileColumn.size, DocumentFileColumn.lastModified, - // DocumentFileColumn.id, + // Optional column (this can't be removed because it's required to list files) + DocumentFileColumn.id, DocumentFileColumn.mimeType, ]; From 3211c6d3ea7074a859d06128076fd32758e1df6e Mon Sep 17 00:00:00 2001 From: LaksCastro Date: Mon, 30 May 2022 21:41:08 -0300 Subject: [PATCH 10/12] (#50) Add all v0.3.1 changes on `CHANGELOG.md` --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f1d1d0..6d69bb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.3.1 + +Minor improvements and bug fixes: + +- Crash when ommiting `DocumentFileColumn.id` column on `listFiles` API. Thanks to @EternityForest. +- Updated docs to info that now `DocumentFileColumn.id` column is optional when calling `listFiles`. + ## 0.3.0 Major release focused on support for `Storage Access Framework`. From cd2815f40b9b247b43a6da0939a6db42826190b0 Mon Sep 17 00:00:00 2001 From: lask Date: Mon, 30 May 2022 21:44:14 -0300 Subject: [PATCH 11/12] (#52) Fix typo on docs --- docs/Usage/Storage Access Framework.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Usage/Storage Access Framework.md b/docs/Usage/Storage Access Framework.md index 503f2d1..41cd5d7 100644 --- a/docs/Usage/Storage Access Framework.md +++ b/docs/Usage/Storage Access Framework.md @@ -68,7 +68,7 @@ if (grantedUri != null) { This method list files lazily **over a granted uri:** -> **Info** `DocumentFileColumn.id` is optional. It is required to fetch the file list from native API. So it is enabled regardless if you include this column or not. And this applies only to this API (`listFiles`). +> **Note** `DocumentFileColumn.id` is optional. It is required to fetch the file list from native API. So it is enabled regardless if you include this column or not. And this applies only to this API (`listFiles`). ```dart /// *Must* be a granted uri from `openDocumentTree` From 82cf74693a8ece2936f363945a01763c053a16cb Mon Sep 17 00:00:00 2001 From: lask Date: Mon, 30 May 2022 21:45:46 -0300 Subject: [PATCH 12/12] (#52) Update plugin version to `v0.3.1` --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 65191f4..ccb99ff 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: shared_storage description: "Flutter plugin to get Android shared folders like DCIM, Downloads, Video, Audio. Works with Android 4.1 (API Level 16+)" -version: 0.3.0 +version: 0.3.1 homepage: https://github.com/lakscastro/shared-storage repository: https://github.com/lakscastro/shared-storage issue_tracker: https://github.com/lakscastro/shared-storage/issues