-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[file_selector_android] Create initial Android implementation of the …
…file_selector package (#3814) Android implementation of the file_selector package Related Links: flutter/plugins#6468 flutter/flutter#25659 Part of flutter/flutter#110098 Useful Resources: https://developer.android.com/guide/topics/providers/document-provider https://developer.android.com/training/data-storage/shared/documents-files
- Loading branch information
1 parent
90e3d32
commit b9935d1
Showing
53 changed files
with
2,738 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,6 @@ | ||
# 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. |
This file contains 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 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 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 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 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 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 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.