check if the type is an image and utilize the MediaStore Opener (which goes through the gallery) instead

This commit is contained in:
Tejas Mehta 2021-03-27 01:35:53 -04:00 committed by Miguel Ruivo
parent e134816489
commit a1878c8816
3 changed files with 11 additions and 3 deletions

View File

@ -1,3 +1,7 @@
## 3.0.1
#### Android
- Use MediaStore Opener (which goes through the gallery) instead of default explorer. (Thank you @tmthecoder).
## 3.0.0
Adds null safety support ([#510](https://github.com/miguelpruivo/flutter_file_picker/issues/510)).
## 2.1.7

View File

@ -197,13 +197,17 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
if (type.equals("dir")) {
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
} else {
intent = new Intent(Intent.ACTION_GET_CONTENT);
if (type.equals("image/*")) {
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
} else {
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
}
final Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + File.separator);
Log.d(TAG, "Selected type " + type);
intent.setDataAndType(uri, this.type);
intent.setType(this.type);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, this.isMultipleSelection);
intent.addCategory(Intent.CATEGORY_OPENABLE);
if (type.contains(",")) {
allowedExtensions = type.split(",");

View File

@ -1,7 +1,7 @@
name: file_picker
description: A package that allows you to use a native file explorer to pick single or multiple absolute file paths, with extension filtering support.
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
version: 3.0.0
version: 3.0.1
dependencies:
flutter: