This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a stub with the Android implementation for the
file_selector
package.Issue related: [file_selector] Add Android support #110098
We worked on the structure of the Android native code (using Java) and the Dart code to link the work to this native part.
We based our structure on the other available packages to avoid having too many discrepancies between them.
For the
dart
code, we extend theFileSelectorPlatform
and override the main four methods:Current implemented methods:
Each of these invokes the
MethodChannel('plugins.flutter.io/file_selector_android')
that is our native code.Our native code has two main points:
LifeCycleObserver
andActivityState
classes to manage the plugin's activity and the result wrappers to respond on the platform thread.Right now, we have implemented the overriding of
onMethodCall,
having the following:We already have a naive implementation of the
getDirectoryPath
, which is to be perfectioned upon feedback from our structure base.As for the tests, we only added a simple test for the dart implementation of
getDirectoryPath
, and the next steps are to add the Java tests for our code.getDirectoryPath naive functionality
Please, any early feedback will be more than welcome to avoid rework in the future.
Edit:
We finished the
getDirectoryPath
implementation and added proper tests in native and dart code.We split the native implementation in a file for each class to avoid being too cumbersome with the activity helpers and wrappers.
We also made some minor refactors when starting to test the native code because we found (even if small) some better dependency injection management for our code.
Lastly, as a note, we couldn't set the Confirm Button Text property because of an inability, at least in the action, for setting other parameters than the extra initial uri. This means that, in Android, we'll have to stick with the button text being "USE THIS FOLDER" for now.
As ACTION_OPEN_DOCUMENT_TREE is SDK 21+ this is our current support. We'll add support for 19+ once we have feedback and well defined structure of the remaining items.
By the way, @stuartmorgan, I didn't get the coverage check for this PR. Do we have to push the .lcov file? In this issue, it says we should upload it to the
flutter/flutter
repo, and I don't see any of these in the/plugins
repo. Could you advise us on how to proceed there? Thanks.Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.