Skip to content

Commit 44caf48

Browse files
[cross_file_android] Android implementation of cross_file (flutter#12909)
Part of flutter#91869 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 77528cd commit 44caf48

58 files changed

Lines changed: 4529 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/dependabot.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ updates:
3131
- /packages/camera/camera_android/example/android/app
3232
- /packages/camera/camera_android_camerax/example/android/app
3333
- /packages/camera/camera/example/android/app
34+
- /packages/cross_file/cross_file_android/example/android/app
3435
- /packages/espresso/example/android/app
3536
- /packages/extension_google_sign_in_as_googleapis_auth/example/android/app
3637
- /packages/file_selector/file_selector/example/android/app
@@ -89,6 +90,7 @@ updates:
8990
directories:
9091
- /packages/camera/camera_android/android
9192
- /packages/camera/camera_android_camerax/android
93+
- /packages/cross_file/cross_file_android/android
9294
- /packages/espresso/android
9395
- /packages/file_selector/file_selector_android/android
9496
- /packages/flutter_plugin_android_lifecycle/android
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the Flutter project. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Google LLC
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
* Initial release.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright 2013 The Flutter Authors
2+
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# cross\_file\_android
2+
3+
The Android implementation of [`cross_file`][1].
4+
5+
This platform supports traditional file systems and [Android shared storage](https://developer.android.com/training/data-storage/shared ).
6+
7+
When using the `FileSystem` implementations on Android, this implementation returns the
8+
implementation created by `CrossFileIO`.
9+
10+
For the `ScopedStorage` implementation, this implementation uses native APIs that interact with
11+
[shared storage](https://developer.android.com/training/data-storage/shared).
12+
13+
## Usage
14+
15+
This package is [endorsed][2], which means you can simply use `cross_file`
16+
normally. This package will be automatically included in your app when you do,
17+
so you do not need to add it to your `pubspec.yaml`.
18+
19+
However, if you `import` this package to use any of its APIs directly, you
20+
should add it to your `pubspec.yaml` as usual.
21+
22+
[1]: https://pub.dev/packages/cross_file
23+
[2]: https://flutter.dev/to/endorsed-federated-plugin
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
group = "dev.flutter.packages.crossfileandroid"
2+
version = "1.0"
3+
4+
buildscript {
5+
val kotlinVersion = "2.3.0"
6+
repositories {
7+
google()
8+
mavenCentral()
9+
}
10+
11+
dependencies {
12+
classpath("com.android.tools.build:gradle:8.13.1")
13+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
14+
}
15+
}
16+
17+
allprojects {
18+
repositories {
19+
google()
20+
mavenCentral()
21+
}
22+
}
23+
24+
plugins {
25+
id("com.android.library")
26+
}
27+
28+
kotlin {
29+
compilerOptions {
30+
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
31+
}
32+
}
33+
34+
android {
35+
namespace = "dev.flutter.packages.crossfileandroid"
36+
compileSdk = flutter.compileSdkVersion
37+
38+
compileOptions {
39+
sourceCompatibility = JavaVersion.VERSION_17
40+
targetCompatibility = JavaVersion.VERSION_17
41+
}
42+
43+
defaultConfig {
44+
minSdk = 24
45+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
46+
}
47+
48+
dependencies {
49+
implementation("androidx.documentfile:documentfile:1.1.0")
50+
implementation("androidx.annotation:annotation:1.9.1")
51+
implementation("androidx.core:core-ktx:1.13.0")
52+
testImplementation("junit:junit:4.13.2")
53+
testImplementation("org.jetbrains.kotlin:kotlin-test")
54+
testImplementation("org.mockito.kotlin:mockito-kotlin:6.1.0")
55+
testImplementation("org.mockito:mockito-inline:5.2.0")
56+
testImplementation("androidx.test:core:1.7.0")
57+
}
58+
59+
lint {
60+
checkAllWarnings = true
61+
warningsAsErrors = true
62+
disable.addAll(setOf("AndroidGradlePluginVersion", "InvalidPackage", "GradleDependency", "NewerVersionAvailable"))
63+
baseline = file("lint-baseline.xml")
64+
}
65+
66+
testOptions {
67+
unitTests {
68+
isIncludeAndroidResources = true
69+
isReturnDefaultValues = true
70+
all {
71+
it.outputs.upToDateWhen { false }
72+
it.testLogging {
73+
events("passed", "skipped", "failed", "standardOut", "standardError")
74+
showStandardStreams = true
75+
}
76+
}
77+
}
78+
}
79+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<issues format="6" by="lint 8.11.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.11.0)" variant="all" version="8.11.0">
3+
4+
<issue
5+
id="MemberExtensionConflict"
6+
message="`remove` is defined both as a member in class `java.util.HashMap` and an extension in package `kotlin.collections`. The defined behavior for this is to use the member, but since the extension is explicitly imported into this file, there&apos;s a chance that this was not expected. (One common way this happens is for members to be added to a class after code was already written to use an extension)."
7+
errorLine1=" return strongInstances.remove(identifier) as T?"
8+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
9+
<location
10+
file="src/main/kotlin/dev/flutter/packages/crossfileandroid/proxies/AndroidLibrary.g.kt"
11+
line="158"
12+
column="12"/>
13+
</issue>
14+
15+
<issue
16+
id="MemberExtensionConflict"
17+
message="`containsKey` is defined both as a member in class `java.util.WeakHashMap` and an extension in package `kotlin.collections`. The defined behavior for this is to use the member, but since the extension is explicitly imported into this file, there&apos;s a chance that this was not expected. (One common way this happens is for members to be added to a class after code was already written to use an extension)."
18+
errorLine1=" return instance != null &amp;&amp; identifiers.containsKey(IdentityWeakReference(instance))"
19+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
20+
<location
21+
file="src/main/kotlin/dev/flutter/packages/crossfileandroid/proxies/AndroidLibrary.g.kt"
22+
line="225"
23+
column="32"/>
24+
</issue>
25+
26+
<issue
27+
id="MemberExtensionConflict"
28+
message="`remove` is defined both as a member in class `java.util.HashMap` and an extension in package `kotlin.collections`. The defined behavior for this is to use the member, but since the extension is explicitly imported into this file, there&apos;s a chance that this was not expected. (One common way this happens is for members to be added to a class after code was already written to use an extension)."
29+
errorLine1=" weakInstances.remove(identifier)"
30+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
31+
<location
32+
file="src/main/kotlin/dev/flutter/packages/crossfileandroid/proxies/AndroidLibrary.g.kt"
33+
line="270"
34+
column="9"/>
35+
</issue>
36+
37+
<issue
38+
id="MemberExtensionConflict"
39+
message="`remove` is defined both as a member in class `java.util.HashMap` and an extension in package `kotlin.collections`. The defined behavior for this is to use the member, but since the extension is explicitly imported into this file, there&apos;s a chance that this was not expected. (One common way this happens is for members to be added to a class after code was already written to use an extension)."
40+
errorLine1=" strongInstances.remove(identifier)"
41+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
42+
<location
43+
file="src/main/kotlin/dev/flutter/packages/crossfileandroid/proxies/AndroidLibrary.g.kt"
44+
line="271"
45+
column="9"/>
46+
</issue>
47+
48+
<issue
49+
id="MemberExtensionConflict"
50+
message="`containsKey` is defined both as a member in class `java.util.HashMap` and an extension in package `kotlin.collections`. The defined behavior for this is to use the member, but since the extension is explicitly imported into this file, there&apos;s a chance that this was not expected. (One common way this happens is for members to be added to a class after code was already written to use an extension)."
51+
errorLine1=" require(!weakInstances.containsKey(identifier)) {"
52+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
53+
<location
54+
file="src/main/kotlin/dev/flutter/packages/crossfileandroid/proxies/AndroidLibrary.g.kt"
55+
line="280"
56+
column="14"/>
57+
</issue>
58+
59+
</issues>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "cross_file_android"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="dev.flutter.packages.crossfileandroid">
3+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2013 The Flutter Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package dev.flutter.packages.crossfileandroid
6+
7+
import io.flutter.embedding.engine.plugins.FlutterPlugin
8+
9+
/** CrossFileAndroidPlugin */
10+
class CrossFileAndroidPlugin : FlutterPlugin {
11+
12+
private lateinit var registrar: ProxyApiRegistrar
13+
14+
override fun onAttachedToEngine(pluginBinding: FlutterPlugin.FlutterPluginBinding) {
15+
registrar =
16+
ProxyApiRegistrar(pluginBinding.binaryMessenger, context = pluginBinding.applicationContext)
17+
registrar.setUp()
18+
}
19+
20+
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
21+
registrar.ignoreCallsToDart = true
22+
registrar.tearDown()
23+
registrar.instanceManager.clear()
24+
}
25+
}

0 commit comments

Comments
 (0)