Skip to content

Commit 33476e1

Browse files
authored
Merge pull request #1910 from daniJimen/feature/fix_select_files_mymetype
Refactor: Simplify MIME type handling in file explorer intent
2 parents 7656dbd + d11b33c commit 33476e1

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
## 10.3.7
2+
### Android
3+
- 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)
4+
15
## 10.3.6
2-
## Android
6+
### Android
37
- Added support for 16 KB page sizes. [#1888](https://github.com/miguelpruivo/flutter_file_picker/issues/1888)
48

59
## 10.3.5
6-
## iOS
10+
### iOS
711
- Fixed an error when loading large files (>= 2GB~).
812

913
## 10.3.4
10-
## Android
14+
### Android
1115
- Detect HEIC and HEIF extensions as valid image
1216
- Use compression format based file extension when compressing images.
1317

android/src/main/kotlin/com/mr/flutter/plugin/filepicker/FileUtils.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ object FileUtils {
142142
if (type == "dir") {
143143
intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
144144
} else {
145-
if (type == "image/*") {
145+
if (type != "*/*") {
146146
intent = Intent(Intent.ACTION_PICK)
147147
val uri = (Environment.getExternalStorageDirectory().path + File.separator).toUri()
148148
intent.setDataAndType(uri, type)
@@ -159,15 +159,16 @@ object FileUtils {
159159
intent.putExtra(Intent.EXTRA_MIME_TYPES, allowedExtensions)
160160
}
161161
} else {
162-
intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
162+
intent = Intent(Intent.ACTION_GET_CONTENT).apply {
163163
addCategory(Intent.CATEGORY_OPENABLE)
164164
type = this@startFileExplorer.type
165+
if (!allowedExtensions.isNullOrEmpty()) {
166+
putExtra(Intent.EXTRA_MIME_TYPES, allowedExtensions!!.toTypedArray())
167+
} else {
168+
putExtra(Intent.EXTRA_MIME_TYPES, type)
169+
}
165170
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, isMultipleSelection)
166171
putExtra("multi-pick", isMultipleSelection)
167-
168-
allowedExtensions?.let {
169-
putExtra(Intent.EXTRA_MIME_TYPES, it.toTypedArray())
170-
}
171172
}
172173

173174
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A package that allows you to use a native file explorer to pick sin
33
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
44
repository: https://github.com/miguelpruivo/flutter_file_picker
55
issue_tracker: https://github.com/miguelpruivo/flutter_file_picker/issues
6-
version: 10.3.6
6+
version: 10.3.7
77

88
dependencies:
99
flutter:

0 commit comments

Comments
 (0)