Adds non legacy support for Android Q

This commit is contained in:
Miguel Ruivo 2020-08-04 20:44:07 +01:00
parent 1e78f28220
commit b9e33851cf
4 changed files with 13 additions and 7 deletions

View File

@ -1,3 +1,6 @@
## 1.13.1
Android: adds support to non-legacy picking on Android Q or above (thank you @lakshyab1995).
## 1.13.0+1
Fixes an issue that could prevent `1.13.0` from being built due to missing `allowCompression` property.

View File

@ -87,9 +87,11 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
final ArrayList<String> paths = new ArrayList<>();
while (currentItem < count) {
final Uri currentUri = data.getClipData().getItemAt(currentItem).getUri();
String path = FileUtils.getPath(currentUri, FilePickerDelegate.this.activity);
if (path == null) {
String path;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
path = FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, currentUri);
} else {
path = FileUtils.getPath(currentUri, FilePickerDelegate.this.activity);
}
paths.add(path);
Log.i(FilePickerDelegate.TAG, "[MultiFilePick] File #" + currentItem + " - URI: " + currentUri.getPath());
@ -108,10 +110,11 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
}
Log.i(FilePickerDelegate.TAG, "[SingleFilePick] File URI:" + uri.toString());
fullPath = FileUtils.getPath(uri, FilePickerDelegate.this.activity);
if (fullPath == null) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
fullPath = type.equals("dir") ? FileUtils.getFullPathFromTreeUri(uri, activity) : FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, uri);
} else {
fullPath = FileUtils.getPath(uri, FilePickerDelegate.this.activity);
}
if (fullPath != null) {

View File

@ -110,7 +110,7 @@ public class FileUtils {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
final String selection = "_id=?";
final String selection = MediaStore.Images.Media._ID + "=?";
final String[] selectionArgs = new String[]{
split[1]
};
@ -156,7 +156,7 @@ public class FileUtils {
private static String getDataColumn(final Context context, final Uri uri, final String selection,
final String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String column = MediaStore.Images.Media.DATA;
final String[] projection = {
column
};

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: 1.13.0+1
version: 1.13.1
dependencies:
flutter: