Fixes picking paths from Downloads directory on versions below SDK 29
This commit is contained in:
parent
506cf55516
commit
0d8c62b4f7
|
@ -1,3 +1,6 @@
|
||||||
|
## 1.13.2
|
||||||
|
Android: fixes picking paths from Downloads directory on versions below Android Q.
|
||||||
|
|
||||||
## 1.13.1
|
## 1.13.1
|
||||||
Android: adds support to non-legacy picking on Android Q or above (thank you @lakshyab1995).
|
Android: adds support to non-legacy picking on Android Q or above (thank you @lakshyab1995).
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,9 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
||||||
path = FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, currentUri);
|
path = FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, currentUri);
|
||||||
} else {
|
} else {
|
||||||
path = FileUtils.getPath(currentUri, FilePickerDelegate.this.activity);
|
path = FileUtils.getPath(currentUri, FilePickerDelegate.this.activity);
|
||||||
|
if (path == null) {
|
||||||
|
path = FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, currentUri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
paths.add(path);
|
paths.add(path);
|
||||||
Log.i(FilePickerDelegate.TAG, "[MultiFilePick] File #" + currentItem + " - URI: " + currentUri.getPath());
|
Log.i(FilePickerDelegate.TAG, "[MultiFilePick] File #" + currentItem + " - URI: " + currentUri.getPath());
|
||||||
|
@ -115,6 +118,9 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
||||||
fullPath = type.equals("dir") ? FileUtils.getFullPathFromTreeUri(uri, activity) : FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, uri);
|
fullPath = type.equals("dir") ? FileUtils.getFullPathFromTreeUri(uri, activity) : FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, uri);
|
||||||
} else {
|
} else {
|
||||||
fullPath = FileUtils.getPath(uri, FilePickerDelegate.this.activity);
|
fullPath = FileUtils.getPath(uri, FilePickerDelegate.this.activity);
|
||||||
|
if (fullPath == null) {
|
||||||
|
fullPath = type.equals("dir") ? FileUtils.getFullPathFromTreeUri(uri, activity) : FileUtils.getUriFromRemote(FilePickerDelegate.this.activity, uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullPath != null) {
|
if (fullPath != null) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
name: file_picker
|
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.
|
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
|
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
|
||||||
version: 1.13.1
|
version: 1.13.2
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
|
|
@ -17,8 +17,10 @@ class FilePicker extends FilePickerPlatform {
|
||||||
/// [allowedExtensions] can be used (eg. `[.jpg, .pdf]`) to restrict picking types
|
/// [allowedExtensions] can be used (eg. `[.jpg, .pdf]`) to restrict picking types
|
||||||
///
|
///
|
||||||
/// Returns a `List<html.File>`
|
/// Returns a `List<html.File>`
|
||||||
static Future<List<html.File>> getMultiFile({FileType type = FileType.any, List<String> allowedExtensions}) async {
|
static Future<List<html.File>> getMultiFile(
|
||||||
return await _instance.getFiles(type: type, allowMultiple: true, allowedExtensions: allowedExtensions);
|
{FileType type = FileType.any, List<String> allowedExtensions}) async {
|
||||||
|
return await _instance.getFiles(
|
||||||
|
type: type, allowMultiple: true, allowedExtensions: allowedExtensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Opens browser file picker window to select a single file.
|
/// Opens browser file picker window to select a single file.
|
||||||
|
@ -26,8 +28,11 @@ class FilePicker extends FilePickerPlatform {
|
||||||
/// [allowedExtensions] can be used (eg. `[.jpg, .pdf]`) to restrict picking types
|
/// [allowedExtensions] can be used (eg. `[.jpg, .pdf]`) to restrict picking types
|
||||||
///
|
///
|
||||||
/// Returns a `html.File`
|
/// Returns a `html.File`
|
||||||
static Future<html.File> getFile({FileType type = FileType.any, List<String> allowedExtensions}) async {
|
static Future<html.File> getFile(
|
||||||
return (await _instance.getFiles(type: type, allowedExtensions: allowedExtensions)).first;
|
{FileType type = FileType.any, List<String> allowedExtensions}) async {
|
||||||
|
return (await _instance.getFiles(
|
||||||
|
type: type, allowedExtensions: allowedExtensions))
|
||||||
|
.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -41,7 +46,8 @@ class FilePicker extends FilePickerPlatform {
|
||||||
html.InputElement uploadInput = html.FileUploadInputElement();
|
html.InputElement uploadInput = html.FileUploadInputElement();
|
||||||
uploadInput.multiple = allowMultiple;
|
uploadInput.multiple = allowMultiple;
|
||||||
uploadInput.accept = _fileType(type, allowedExtensions);
|
uploadInput.accept = _fileType(type, allowedExtensions);
|
||||||
uploadInput.onChange.listen((event) => pickedFiles.complete(uploadInput.files));
|
uploadInput.onChange
|
||||||
|
.listen((event) => pickedFiles.complete(uploadInput.files));
|
||||||
uploadInput.click();
|
uploadInput.click();
|
||||||
return await pickedFiles.future;
|
return await pickedFiles.future;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +70,8 @@ class FilePicker extends FilePickerPlatform {
|
||||||
return 'video/*|image/*';
|
return 'video/*|image/*';
|
||||||
|
|
||||||
case FileType.custom:
|
case FileType.custom:
|
||||||
return allowedExtensions.fold('', (prev, next) => '${prev.isEmpty ? '' : '$prev,'} .$next');
|
return allowedExtensions.fold(
|
||||||
|
'', (prev, next) => '${prev.isEmpty ? '' : '$prev,'} .$next');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
|
|
Loading…
Reference in New Issue