diff --git a/CHANGELOG.md b/CHANGELOG.md index ca850656..b2fb1a6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,17 @@ +## 10.3.7 +### Android +- Fixed an issue where file type filtering was not being applied correctly, now only displaying files that match the selected MIME types. [#1906](https://github.com/miguelpruivo/flutter_file_picker/pull/1906) + ## 10.3.6 -## Android +### Android - Added support for 16 KB page sizes. [#1888](https://github.com/miguelpruivo/flutter_file_picker/issues/1888) ## 10.3.5 -## iOS +### iOS - Fixed an error when loading large files (>= 2GB~). ## 10.3.4 -## Android +### Android - Detect HEIC and HEIF extensions as valid image - Use compression format based file extension when compressing images. diff --git a/android/src/main/kotlin/com/mr/flutter/plugin/filepicker/FileUtils.kt b/android/src/main/kotlin/com/mr/flutter/plugin/filepicker/FileUtils.kt index 3c65c491..67726b41 100644 --- a/android/src/main/kotlin/com/mr/flutter/plugin/filepicker/FileUtils.kt +++ b/android/src/main/kotlin/com/mr/flutter/plugin/filepicker/FileUtils.kt @@ -142,7 +142,7 @@ object FileUtils { if (type == "dir") { intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) } else { - if (type == "image/*") { + if (type != "*/*") { intent = Intent(Intent.ACTION_PICK) val uri = (Environment.getExternalStorageDirectory().path + File.separator).toUri() intent.setDataAndType(uri, type) @@ -159,15 +159,16 @@ object FileUtils { intent.putExtra(Intent.EXTRA_MIME_TYPES, allowedExtensions) } } else { - intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply { + intent = Intent(Intent.ACTION_GET_CONTENT).apply { addCategory(Intent.CATEGORY_OPENABLE) type = this@startFileExplorer.type + if (!allowedExtensions.isNullOrEmpty()) { + putExtra(Intent.EXTRA_MIME_TYPES, allowedExtensions!!.toTypedArray()) + } else { + putExtra(Intent.EXTRA_MIME_TYPES, type) + } putExtra(Intent.EXTRA_ALLOW_MULTIPLE, isMultipleSelection) putExtra("multi-pick", isMultipleSelection) - - allowedExtensions?.let { - putExtra(Intent.EXTRA_MIME_TYPES, it.toTypedArray()) - } } } diff --git a/pubspec.yaml b/pubspec.yaml index 2c6123c7..d07c5148 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A package that allows you to use a native file explorer to pick sin homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker repository: https://github.com/miguelpruivo/flutter_file_picker issue_tracker: https://github.com/miguelpruivo/flutter_file_picker/issues -version: 10.3.6 +version: 10.3.7 dependencies: flutter: