[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[path_provider] Android: Support multiple external storage options #2049

Merged
merged 43 commits into from
Oct 21, 2019

Conversation

ened
Copy link
Contributor
@ened ened commented Sep 9, 2019

Description

Some Android phones support multiple external storage options to store files, e.g. SD cards.
This PR adds functionality to path_provider so that developers can inquire about those folders.

The Android API defines a set of standard folder name constants in android.os.Environment which are now bridged to Dart using this PR.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

An existing test does not pass currently, this was introduced in #1953. Will include the fix in this PR.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • No, this is not a breaking change.

This is a followup PR of #966

/cc @collinjackson

Copy link
Contributor
@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR. I left some comments.

packages/path_provider/lib/path_provider.dart Outdated Show resolved Hide resolved
packages/path_provider/lib/path_provider.dart Outdated Show resolved Hide resolved
packages/path_provider/lib/path_provider.dart Outdated Show resolved Hide resolved
packages/path_provider/lib/path_provider.dart Outdated Show resolved Hide resolved
packages/path_provider/lib/path_provider.dart Outdated Show resolved Hide resolved
@ened
Copy link
Contributor Author
ened commented Oct 3, 2019

@cyanglaz Thank you for reviewing and will update the PR tomorrow.

@ened
Copy link
Contributor Author
ened commented Oct 4, 2019

@amirh @cyanglaz there may a problem that's not catch with either approach (enum, String etc):
When you look at the documentation here: https://developer.android.com/reference/android/os/Environment.html#fields_1 , then you find that the DIRECTORY_* variables are marked as Fields and do not show their actual constant value.

I would therefore assume that the values are not stable and thus, we should not rely on arbitrary string values.

Perhaps that's what you meant with public-facing enum & string internally, but I think there needs to be double-mapping. So on dart side enum to a transfer type (like integer) and on native side from integer to the actual constant. WDYT?

Copy link
Contributor
@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ened I think what you said makes sense. Do you mind work on that? After you done with it, we might need to add a test to test the mapping.

packages/path_provider/lib/path_provider.dart Outdated Show resolved Hide resolved
@ened
Copy link
Contributor Author
ened commented Oct 11, 2019

@cyanglaz back to you, when you get a chance

@ened ened requested a review from cyanglaz October 21, 2019 08:16
@ened
Copy link
Contributor Author
ened commented Oct 21, 2019

@cyanglaz sorry to re-request - Github shows more changes required but I can not find them anywhere.

Copy link
Contributor
@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@cyanglaz cyanglaz merged commit 017a57e into flutter:master Oct 21, 2019
sungmin-park pushed a commit to sungmin-park/flutter-plugins that referenced this pull request Dec 17, 2019
julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants