Skip to content

Commit def1025

Browse files
authored
[path_provider] path provider linux implementation in dart (flutter#2589)
Adds a pure-Dart path_provider_linux, to use as a federated Linux implementation of path_provider.
1 parent 6ca0171 commit def1025

Some content is hidden

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

62 files changed

+1733
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
.dart_tool/
3+
4+
.packages
5+
.pub/
6+
7+
build/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: e491544588e8d34fdf31d5f840b4649850ef167a
8+
channel: master
9+
10+
project_type: plugin
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## 0.0.1
2+
3+
* The initial implementation of path_provider for Linux
4+
* Implements getApplicationSupportPath, getApplicationDocumentsPath, getDownloadsPath, and getTemporaryPath
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2020 The Chromium Authors. All rights reserved.
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions are
5+
// met:
6+
//
7+
// * Redistributions of source code must retain the above copyright
8+
// notice, this list of conditions and the following disclaimer.
9+
// * Redistributions in binary form must reproduce the above
10+
// copyright notice, this list of conditions and the following disclaimer
11+
// in the documentation and/or other materials provided with the
12+
// distribution.
13+
// * Neither the name of Google Inc. nor the names of its
14+
// contributors may be used to endorse or promote products derived from
15+
// this software without specific prior written permission.
16+
//
17+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# path_provider_linux
2+
3+
The linux implementation of [`path_provider`].
4+
5+
**Please set your constraint to `path_provider_linux: '>=0.0.y+x <2.0.0'`**
6+
7+
## Backward compatible 1.0.0 version is coming
8+
The `path_provider` plugin has reached a stable API, we guarantee that version `1.0.0` will be backward compatible with `0.0.y+z`.
9+
Please use `path_provider_linux: '>=0.0.y+x <2.0.0'` as your dependency constraint to allow a smoother ecosystem migration.
10+
For more details see: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
11+
12+
## Usage
13+
14+
### Import the package
15+
16+
To use this plugin in your Flutter linux app, simply add it as a dependency in
17+
your `pubspec.yaml` alongside the base `path_provider` plugin.
18+
19+
_(This is only temporary: in the future we hope to make this package an
20+
"endorsed" implementation of `path_provider`, so that it is automatically
21+
included in your Flutter linux app when you depend on `package:path_provider`.)_
22+
23+
This is what the above means to your `pubspec.yaml`:
24+
25+
```yaml
26+
...
27+
dependencies:
28+
...
29+
path_provider: ^1.5.1
30+
path_provider_linux: ^0.0.1
31+
...
32+
```
33+
34+
### Use the plugin
35+
36+
Once you have the `path_provider_linux` dependency in your pubspec, you should
37+
be able to use `package:path_provider` as normal.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
.dart_tool/
26+
.flutter-plugins
27+
.flutter-plugins-dependencies
28+
.packages
29+
.pub-cache/
30+
.pub/
31+
/build/
32+
33+
# Web related
34+
lib/generated_plugin_registrant.dart
35+
36+
# Symbolication related
37+
app.*.symbols
38+
39+
# Obfuscation related
40+
app.*.map.json
41+
42+
# Exceptions to above rules.
43+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: e491544588e8d34fdf31d5f840b4649850ef167a
8+
channel: master
9+
10+
project_type: app
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# path_provider_linux_example
2+
3+
Demonstrates how to use the path_provider_linux plugin.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13+
14+
For help getting started with Flutter, view our
15+
[online documentation](https://flutter.dev/docs), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
def localProperties = new Properties()
2+
def localPropertiesFile = rootProject.file('local.properties')
3+
if (localPropertiesFile.exists()) {
4+
localPropertiesFile.withReader('UTF-8') { reader ->
5+
localProperties.load(reader)
6+
}
7+
}
8+
9+
def flutterRoot = localProperties.getProperty('flutter.sdk')
10+
if (flutterRoot == null) {
11+
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12+
}
13+
14+
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15+
if (flutterVersionCode == null) {
16+
flutterVersionCode = '1'
17+
}
18+
19+
def flutterVersionName = localProperties.getProperty('flutter.versionName')
20+
if (flutterVersionName == null) {
21+
flutterVersionName = '1.0'
22+
}
23+
24+
apply plugin: 'com.android.application'
25+
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26+
27+
android {
28+
compileSdkVersion 28
29+
30+
lintOptions {
31+
disable 'InvalidPackage'
32+
}
33+
34+
defaultConfig {
35+
applicationId "io.flutter.plugins.pathproviderexample"
36+
minSdkVersion 16
37+
targetSdkVersion 28
38+
versionCode flutterVersionCode.toInteger()
39+
versionName flutterVersionName
40+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
41+
}
42+
43+
buildTypes {
44+
release {
45+
// TODO: Add your own signing config for the release build.
46+
// Signing with the debug keys for now, so `flutter run --release` works.
47+
signingConfig signingConfigs.debug
48+
}
49+
}
50+
}
51+
52+
flutter {
53+
source '../..'
54+
}
55+
56+
dependencies {
57+
androidTestImplementation 'androidx.test:runner:1.2.0'
58+
androidTestImplementation 'androidx.test:rules:1.2.0'
59+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
60+
61+
testImplementation 'junit:junit:4.12'
62+
androidTestImplementation 'androidx.test:runner:1.1.1'
63+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
package io.flutter.plugins.pathprovider;
3+
4+
import androidx.test.rule.ActivityTestRule;
5+
import dev.flutter.plugins.e2e.FlutterRunner;
6+
import io.flutter.plugins.pathproviderexample.EmbeddingV1Activity;
7+
import org.junit.Rule;
8+
import org.junit.runner.RunWith;
9+
10+
@RunWith(FlutterRunner.class)
11+
public class EmbeddingV1ActivityTest {
12+
@Rule
13+
public ActivityTestRule<EmbeddingV1Activity> rule =
14+
new ActivityTestRule<>(EmbeddingV1Activity.class);
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
package io.flutter.plugins.pathprovider;
3+
4+
import androidx.test.rule.ActivityTestRule;
5+
import dev.flutter.plugins.e2e.FlutterRunner;
6+
import io.flutter.plugins.pathproviderexample.MainActivity;
7+
import org.junit.Rule;
8+
import org.junit.runner.RunWith;
9+
10+
@RunWith(FlutterRunner.class)
11+
public class MainActivityTest {
12+
@Rule public ActivityTestRule<MainActivity> rule = new ActivityTestRule<>(MainActivity.class);
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.pathproviderexample">
3+
4+
<uses-permission android:name="android.permission.INTERNET"/>
5+
6+
<application android:name="io.flutter.app.FlutterApplication" android:label="path_provider_example" android:icon="@mipmap/ic_launcher">
7+
<activity
8+
android:name=".EmbeddingV1Activity"
9+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
10+
android:hardwareAccelerated="true"
11+
android:windowSoftInputMode="adjustResize">
12+
</activity>
13+
<activity android:name=".MainActivity"
14+
android:launchMode="singleTop"
15+
android:theme="@android:style/Theme.Black.NoTitleBar"
16+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
17+
android:hardwareAccelerated="true"
18+
android:windowSoftInputMode="adjustResize">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN"/>
21+
<category android:name="android.intent.category.LAUNCHER"/>
22+
</intent-filter>
23+
</activity>
24+
</application>
25+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
package io.flutter.plugins.pathproviderexample;
3+
4+
import android.os.Bundle;
5+
import io.flutter.app.FlutterActivity;
6+
import io.flutter.plugins.GeneratedPluginRegistrant;
7+
8+
public class EmbeddingV1Activity extends FlutterActivity {
9+
@Override
10+
protected void onCreate(Bundle savedInstanceState) {
11+
super.onCreate(savedInstanceState);
12+
GeneratedPluginRegistrant.registerWith(this);
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
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 io.flutter.plugins.pathproviderexample;
6+
7+
import dev.flutter.plugins.e2e.E2EPlugin;
8+
import io.flutter.embedding.android.FlutterActivity;
9+
import io.flutter.embedding.engine.FlutterEngine;
10+
import io.flutter.plugins.pathprovider.PathProviderPlugin;
11+
12+
public class MainActivity extends FlutterActivity {
13+
// TODO(xster): Remove this once v2 of GeneratedPluginRegistrant rolls to stable. https://github.com/flutter/flutter/issues/42694
14+
@Override
15+
public void configureFlutterEngine(FlutterEngine flutterEngine) {
16+
flutterEngine.getPlugins().add(new PathProviderPlugin());
17+
flutterEngine.getPlugins().add(new E2EPlugin());
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
buildscript {
2+
repositories {
3+
google()
4+
jcenter()
5+
}
6+
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:3.3.0'
9+
}
10+
}
11+
12+
allprojects {
13+
repositories {
14+
google()
15+
jcenter()
16+
}
17+
}
18+
19+
rootProject.buildDir = '../build'
20+
subprojects {
21+
project.buildDir = "${rootProject.buildDir}/${project.name}"
22+
}
23+
subprojects {
24+
project.evaluationDependsOn(':app')
25+
}
26+
27+
task clean(type: Delete) {
28+
delete rootProject.buildDir
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
org.gradle.jvmargs=-Xmx1536M
2+
android.enableR8=true
3+
android.useAndroidX=true
4+
android.enableJetifier=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
zipStoreBase=GRADLE_USER_HOME
4+
zipStorePath=wrapper/dists
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
include ':app'
2+
3+
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4+
5+
def plugins = new Properties()
6+
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7+
if (pluginsFile.exists()) {
8+
pluginsFile.withInputStream { stream -> plugins.load(stream) }
9+
}
10+
11+
plugins.each { name, path ->
12+
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13+
include ":$name"
14+
project(":$name").projectDir = pluginDirectory
15+
}

0 commit comments

Comments
 (0)