From a9eb2abbb957c551a02aaed9cb7b955baa6d53df Mon Sep 17 00:00:00 2001 From: Miguel Ruivo Date: Mon, 2 Sep 2019 13:20:23 +0100 Subject: [PATCH] see changelog (v1.4.0+1) * Better handling on Android of buggy file managers that return no intent when canceling the file selection even though it returns Activity.RESULT_OK (#111) * removes deprecated Android SDK code and fixes an issue that could prevent some downloaded files from being picked * adds getMultiFile and prevents UI blocking when picking large remote files * updates readme file * fixes an issue that could prevent internal storage files from being properly picked --- CHANGELOG.md | 6 +++++- .../mr/flutter/plugin/filepicker/FilePickerPlugin.java | 4 ++-- .../com/mr/flutter/plugin/filepicker/FileUtils.java | 10 ++-------- pubspec.yaml | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e17a5fc..e16efb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.4.0+1 + +**Bug fix:** Fixes an issue that could prevent internal storage files from being properly picked. + ## 1.4.0 **New features** @@ -5,7 +9,7 @@ * Adds Desktop example, to run it just do `hover init` and then `hover run` within the plugin's example folder (you must have go and hover installed, check the previous point). * Similar to `getFile`, now there is also a `getMultiFile` which behaves the same way, but returning a list of files instead. -**Improvements:** +**Improvements** * Updates Android SDK deprecated code. * Sometimes when a big file was being picked from a remote directory (GDrive for example), the UI could be blocked. Now this shouldn't happen anymore. diff --git a/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java b/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java index 4664a65..197229b 100644 --- a/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java +++ b/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java @@ -199,14 +199,14 @@ public class FilePickerPlugin implements MethodCallHandler { - + @SuppressWarnings("deprecation") private static void startFileExplorer(String type) { Intent intent; if (checkPermission()) { intent = new Intent(Intent.ACTION_GET_CONTENT); - Uri uri = Uri.parse(FileUtils.getExternalPath(instance.activeContext()) + File.separator); + Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + File.separator); intent.setDataAndType(uri, type); intent.setType(type); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, isMultipleSelection); diff --git a/android/src/main/java/com/mr/flutter/plugin/filepicker/FileUtils.java b/android/src/main/java/com/mr/flutter/plugin/filepicker/FileUtils.java index bf66f09..86f6856 100644 --- a/android/src/main/java/com/mr/flutter/plugin/filepicker/FileUtils.java +++ b/android/src/main/java/com/mr/flutter/plugin/filepicker/FileUtils.java @@ -38,14 +38,8 @@ public class FileUtils { return null; } - public static String getExternalPath(Context context) { - if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { - return context.getExternalFilesDir(null).getAbsolutePath(); - } - return context.getFilesDir().getAbsolutePath(); - } - @TargetApi(19) + @SuppressWarnings("deprecation") private static String getForApi19(Context context, Uri uri) { Log.e(TAG, "Getting for API 19 or above" + uri); if (DocumentsContract.isDocumentUri(context, uri)) { @@ -57,7 +51,7 @@ public class FileUtils { final String type = split[0]; if ("primary".equalsIgnoreCase(type)) { Log.e(TAG, "Primary External Document URI"); - return getExternalPath(context) + "/" + split[1]; + return Environment.getExternalStorageDirectory() + "/" + split[1]; } } else if (isDownloadsDocument(uri)) { Log.e(TAG, "Downloads External Document URI"); diff --git a/pubspec.yaml b/pubspec.yaml index f5fd3fe..b7ff908 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,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 extensions filtering support. author: Miguel Ruivo homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker -version: 1.4.0 +version: 1.4.0+1 dependencies: flutter: