-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[file_selector_android] Create initial Android implementation of the file_selector package #3814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
auto-submit
merged 72 commits into
flutter:main
from
bparrishMines:file_selector_android
Jun 26, 2023
Merged
Changes from 69 commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
241eadc
initial commit
bparrishMines 8619800
attempt to get plugin ready for CI
bparrishMines 7ebaa32
formatting
bparrishMines a7f88ad
analyzer errors
bparrishMines 7ad4d46
Merge branch 'main' of github.com:flutter/packages into file_selector…
bparrishMines 40a6178
dep order
bparrishMines 25f36b1
example dep order
bparrishMines 87179de
fix readme
bparrishMines ba934f9
add dependabot
bparrishMines 0dbdc12
Merge branch 'main' of github.com:flutter/packages into file_selector…
bparrishMines 13f55ee
namespace
bparrishMines 1f28c7d
cameraMerge branch 'main' of github.com:flutter/packages into file_se…
bparrishMines 017ed72
implement pigeon files
bparrishMines fe605c0
change namespace
bparrishMines 0fec82b
dart side of impl
bparrishMines f179ab0
java side impl of pigeon api
bparrishMines 1002bc3
implement something
bparrishMines 32c440b
running example
bparrishMines f45cc08
dart side of new impl
bparrishMines 2adae90
capture current state
bparrishMines b49eab6
formatting
bparrishMines a513192
Merge branch 'main' of github.com:flutter/packages into file_selector…
bparrishMines 9cd2774
working code i guess
bparrishMines b8aae60
handle opening multiple files
bparrishMines 6c92c72
finish handling opening images
bparrishMines 82a6c79
java side of handling get dirs
bparrishMines 7725cc5
remove get dirs
bparrishMines a6a4066
remove test context
bparrishMines 6d7a340
some improvements to readablity
bparrishMines 750e588
finish dart side tests
bparrishMines 0e5e416
open file test
bparrishMines 1b08e94
formatting
bparrishMines 56dcdd8
update helper method
bparrishMines be9dcc8
open files test
bparrishMines 4e6c548
use a set instead
bparrishMines 407a118
formatting
bparrishMines fb8485b
add placeholder integration test
bparrishMines b165ed4
update pubspec
bparrishMines 2673f12
Merge branch 'main' of github.com:flutter/packages into file_selector…
bparrishMines c5643ae
conditionalize namespace
bparrishMines d25a689
lint fixes
bparrishMines 6ae37e6
fix integration test import
bparrishMines 20c55f8
formatting
bparrishMines 12070b6
handle null toFileResponse
bparrishMines 9498a56
Merge branch 'main' of github.com:flutter/packages into file_selector…
bparrishMines a99550a
dart side of pigeon updates
bparrishMines 0942fb8
fix dart todo
bparrishMines f3b07c8
update java side
bparrishMines 33c3801
formatting and java side
bparrishMines 21419de
method for typegroups
bparrishMines 8dfc2b1
comment
bparrishMines 882acb7
using the binding instead
bparrishMines e351b7a
Merge branch 'main' of github.com:flutter/packages into file_selector…
bparrishMines dc85a97
bump mockito and clarify launch test
bparrishMines b809399
running integration test
bparrishMines f83d6f3
formatting and the other files
bparrishMines e84c565
Merge branch 'main' of github.com:flutter/packages into file_selector…
bparrishMines 6074461
working integration test
bparrishMines d667d8a
integration test files
bparrishMines 2b72838
running tests
bparrishMines 9827799
license
bparrishMines fff7692
authors
bparrishMines 245336d
some small fixes
bparrishMines 0ceef57
use manifest instead maybe
bparrishMines 563e570
add entry point
bparrishMines 66b32aa
add integrationTestMain to integration test
bparrishMines 791c67e
fix activity test rule
bparrishMines 7d50a42
formatting
bparrishMines 443e4c8
Merge branch 'main' of github.com:flutter/packages into file_selector…
bparrishMines 776a771
Merge branch 'main' of github.com:flutter/packages into file_selector…
bparrishMines b85e1a7
Merge branch 'main' of github.com:flutter/packages into file_selector…
bparrishMines 018aa30
small review fixes
bparrishMines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Below is a list of people and organizations that have contributed | ||
| # to the Flutter project. Names should be added to the list like so: | ||
| # | ||
| # Name/Organization <email address> | ||
|
|
||
| Google Inc. | ||
| The Chromium Authors | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 0.5.0 | ||
|
|
||
| * Implements file_selector_platform_interface for Android. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Copyright 2013 The Flutter Authors. All rights reserved. | ||
|
|
||
| Redistribution and use in source and binary forms, with or without modification, | ||
| are permitted provided that the following conditions are met: | ||
|
|
||
| * Redistributions of source code must retain the above copyright | ||
| notice, this list of conditions and the following disclaimer. | ||
| * Redistributions in binary form must reproduce the above | ||
| copyright notice, this list of conditions and the following | ||
| disclaimer in the documentation and/or other materials provided | ||
| with the distribution. | ||
| * Neither the name of Google Inc. nor the names of its | ||
| contributors may be used to endorse or promote products derived | ||
| from this software without specific prior written permission. | ||
|
|
||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
| ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
| ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # file\_selector\_android | ||
|
|
||
| The Android implementation of [`file_selector`][1]. | ||
|
|
||
| ## Usage | ||
|
|
||
| This package is [endorsed][2], which means you can simply use `file_selector` | ||
| normally. This package will be automatically included in your app when you do, | ||
| so you do not need to add it to your `pubspec.yaml`. | ||
|
|
||
| However, if you `import` this package to use any of its APIs directly, you | ||
| should add it to your `pubspec.yaml` as usual. | ||
|
|
||
| [1]: https://pub.dev/packages/file_selector | ||
| [2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin |
64 changes: 64 additions & 0 deletions
64
packages/file_selector/file_selector_android/android/build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| group 'dev.flutter.packages.file_selector_android' | ||
| version '1.0' | ||
|
|
||
| buildscript { | ||
| repositories { | ||
| google() | ||
| mavenCentral() | ||
| } | ||
|
|
||
| dependencies { | ||
| classpath 'com.android.tools.build:gradle:7.3.0' | ||
| } | ||
| } | ||
|
|
||
| rootProject.allprojects { | ||
| repositories { | ||
| google() | ||
| mavenCentral() | ||
| } | ||
| } | ||
|
|
||
| apply plugin: 'com.android.library' | ||
|
|
||
| android { | ||
| // Conditional for compatibility with AGP <4.2. | ||
| if (project.android.hasProperty("namespace")) { | ||
| namespace 'dev.flutter.packages.file_selector_android' | ||
| } | ||
| compileSdkVersion 33 | ||
|
|
||
| compileOptions { | ||
| sourceCompatibility JavaVersion.VERSION_1_8 | ||
| targetCompatibility JavaVersion.VERSION_1_8 | ||
| } | ||
|
|
||
| defaultConfig { | ||
| minSdkVersion 19 | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation 'androidx.annotation:annotation:1.5.0' | ||
| testImplementation 'junit:junit:4.13.2' | ||
| testImplementation 'org.mockito:mockito-inline:5.1.0' | ||
| testImplementation 'androidx.test:core:1.3.0' | ||
| } | ||
|
|
||
| lintOptions { | ||
| checkAllWarnings true | ||
| warningsAsErrors true | ||
| disable 'AndroidGradlePluginVersion', 'InvalidPackage', 'GradleDependency' | ||
| } | ||
|
|
||
| testOptions { | ||
| unitTests.includeAndroidResources = true | ||
| unitTests.returnDefaultValues = true | ||
| unitTests.all { | ||
| testLogging { | ||
| events "passed", "skipped", "failed", "standardOut", "standardError" | ||
| outputs.upToDateWhen {false} | ||
| showStandardStreams = true | ||
| } | ||
| } | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
packages/file_selector/file_selector_android/android/settings.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| rootProject.name = 'file_selector_android' |
3 changes: 3 additions & 0 deletions
3
packages/file_selector/file_selector_android/android/src/main/AndroidManifest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| package="dev.flutter.packages.file_selector_android"> | ||
| </manifest> |
59 changes: 59 additions & 0 deletions
59
...d/src/main/java/dev/flutter/packages/file_selector_android/FileSelectorAndroidPlugin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package dev.flutter.packages.file_selector_android; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
| import io.flutter.embedding.engine.plugins.FlutterPlugin; | ||
| import io.flutter.embedding.engine.plugins.activity.ActivityAware; | ||
| import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; | ||
|
|
||
| /** Native portion of the Android platform implementation of the file_selector plugin. */ | ||
| public class FileSelectorAndroidPlugin implements FlutterPlugin, ActivityAware { | ||
| @Nullable private FileSelectorApiImpl fileSelectorApi; | ||
| private FlutterPluginBinding pluginBinding; | ||
|
|
||
| @Override | ||
| public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { | ||
| pluginBinding = binding; | ||
| } | ||
|
|
||
| @Override | ||
| public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { | ||
| pluginBinding = null; | ||
| } | ||
|
|
||
| @Override | ||
| public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) { | ||
| fileSelectorApi = new FileSelectorApiImpl(binding); | ||
| GeneratedFileSelectorApi.FileSelectorApi.setup( | ||
| pluginBinding.getBinaryMessenger(), fileSelectorApi); | ||
| } | ||
|
|
||
| @Override | ||
| public void onDetachedFromActivityForConfigChanges() { | ||
| if (fileSelectorApi != null) { | ||
| fileSelectorApi.setActivityPluginBinding(null); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) { | ||
| if (fileSelectorApi != null) { | ||
| fileSelectorApi.setActivityPluginBinding(binding); | ||
| } else { | ||
| fileSelectorApi = new FileSelectorApiImpl(binding); | ||
| GeneratedFileSelectorApi.FileSelectorApi.setup( | ||
| pluginBinding.getBinaryMessenger(), fileSelectorApi); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onDetachedFromActivity() { | ||
| if (fileSelectorApi != null) { | ||
| fileSelectorApi.setActivityPluginBinding(null); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line can be removed.