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

Commit 1ed46af

Browse files
authored
Add path_provider plugin (#12)
1 parent aa929a9 commit 1ed46af

File tree

79 files changed

+2695
-0
lines changed

Some content is hidden

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

79 files changed

+2695
-0
lines changed

packages/path-provider/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
.atom/
3+
.idea
4+
.packages
5+
.pub/
6+
build/
7+
ios/.generated/
8+
packages
9+
pubspec.lock

packages/path-provider/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## [0.1.0] - 2017-05-03
2+
3+
* Initial Open Source release.

packages/path-provider/LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright 2017, the Flutter project authors. All rights reserved.
2+
Redistribution and use in source and binary forms, with or without
3+
modification, are permitted provided that the following conditions are
4+
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
17+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

packages/path-provider/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# path_provider
2+
3+
Flutter plugin for finding commonly used locations on the filesystem. Supports iOS and Android.
4+
5+
6+
## Usage
7+
8+
To use this plugin, add path_provider as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).
9+
10+
11+
### Example
12+
After importing ```'package:path_provider/path_provider.dart'``` the directories can be queried as follows
13+
14+
``` dart
15+
Directory tempDir = await getTemporaryDirectory();
16+
String tempPath = tempDir.path;
17+
18+
Directory appDocDir = await getApplicationDocumentsDirectory();
19+
String appDocPath = appDocDir.path;
20+
```
21+
Please see the example app of this plugin for a full example.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
10+
/gradle
11+
/gradlew
12+
/gradlew.bat
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
group 'io.flutter.plugins.path_provider'
2+
version '1.0-SNAPSHOT'
3+
4+
buildscript {
5+
repositories {
6+
jcenter()
7+
}
8+
9+
dependencies {
10+
classpath 'com.android.tools.build:gradle:2.3.0'
11+
}
12+
}
13+
14+
allprojects {
15+
repositories {
16+
jcenter()
17+
}
18+
}
19+
20+
apply plugin: 'com.android.library'
21+
22+
android {
23+
compileSdkVersion 25
24+
buildToolsVersion '25.0.0'
25+
26+
defaultConfig {
27+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
28+
}
29+
lintOptions {
30+
disable 'InvalidPackage'
31+
}
32+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.jvmargs=-Xmx1536M
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'path_provider'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.path_provider"
3+
android:versionCode="1"
4+
android:versionName="0.0.1">
5+
6+
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
7+
</manifest>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.path_provider;
6+
7+
import io.flutter.app.FlutterActivity;
8+
import io.flutter.plugin.common.MethodChannel;
9+
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
10+
import io.flutter.plugin.common.MethodChannel.Result;
11+
import io.flutter.plugin.common.MethodCall;
12+
import io.flutter.util.PathUtils;
13+
14+
15+
public class PathProviderPlugin implements MethodCallHandler {
16+
private FlutterActivity activity;
17+
18+
public static PathProviderPlugin register(FlutterActivity activity) {
19+
return new PathProviderPlugin(activity);
20+
}
21+
22+
private PathProviderPlugin(FlutterActivity activity) {
23+
this.activity = activity;
24+
new MethodChannel(activity.getFlutterView(), "plugins.flutter.io/path_provider").
25+
setMethodCallHandler(this);
26+
}
27+
28+
@Override
29+
public void onMethodCall(MethodCall call, Result result) {
30+
switch (call.method) {
31+
case "getTemporaryDirectory":
32+
result.success(getPathProviderTemporaryDirectory());
33+
break;
34+
case "getApplicationDocumentsDirectory":
35+
result.success(getPathProviderApplicationDocumentsDirectory());
36+
break;
37+
default:
38+
result.notImplemented();
39+
}
40+
}
41+
42+
private String getPathProviderTemporaryDirectory() {
43+
return activity.getCacheDir().getPath();
44+
}
45+
46+
private String getPathProviderApplicationDocumentsDirectory() {
47+
return PathUtils.getDataDirectory(activity);
48+
}
49+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
.atom/
3+
.idea
4+
.packages
5+
.pub/
6+
build/
7+
ios/.generated/
8+
packages
9+
pubspec.lock
10+
.flutter-plugins
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# path_provider_example
2+
3+
Demonstrates how to use the path_provider plugin.
4+
5+
## Getting Started
6+
7+
For help getting started with Flutter, view our online
8+
[documentation](http://flutter.io/).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$/android">
6+
<sourceFolder url="file://$MODULE_DIR$/android/app/src/main/java" isTestSource="false" />
7+
</content>
8+
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
<orderEntry type="library" name="Flutter for Android" level="project" />
11+
</component>
12+
</module>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
10+
/gradle
11+
/gradlew
12+
/gradlew.bat
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
def localProperties = new Properties()
2+
def localPropertiesFile = rootProject.file('local.properties')
3+
if (localPropertiesFile.exists()) {
4+
localPropertiesFile.withInputStream { stream ->
5+
localProperties.load(stream)
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+
apply plugin: 'com.android.application'
15+
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
16+
17+
android {
18+
compileSdkVersion 25
19+
buildToolsVersion '25.0.2'
20+
21+
lintOptions {
22+
disable 'InvalidPackage'
23+
}
24+
25+
defaultConfig {
26+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
27+
}
28+
29+
buildTypes {
30+
release {
31+
// TODO: Add your own signing config for the release build.
32+
// Signing with the debug keys for now, so `flutter run --release` works.
33+
signingConfig signingConfigs.debug
34+
}
35+
}
36+
}
37+
38+
flutter {
39+
source '../..'
40+
}
41+
42+
dependencies {
43+
androidTestCompile 'com.android.support:support-annotations:25.0.0'
44+
androidTestCompile 'com.android.support.test:runner:0.5'
45+
androidTestCompile 'com.android.support.test:rules:0.5'
46+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.path_provider_example"
3+
android:versionCode="1"
4+
android:versionName="0.0.1">
5+
6+
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
7+
8+
<!-- The INTERNET permission is required for development. Specifically,
9+
flutter needs it to communicate with the running application
10+
to allow setting breakpoints, to provide hot reload, etc.
11+
-->
12+
<uses-permission android:name="android.permission.INTERNET"/>
13+
14+
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
15+
calls FlutterMain.startInitialization(this); in its onCreate method.
16+
In most cases you can leave this as-is, but you if you want to provide
17+
additional functionality it is fine to subclass or reimplement
18+
FlutterApplication and put your custom class here. -->
19+
<application android:name="io.flutter.app.FlutterApplication" android:label="path_provider_example" android:icon="@mipmap/ic_launcher">
20+
<activity android:name=".MainActivity"
21+
android:launchMode="singleTop"
22+
android:theme="@android:style/Theme.Black.NoTitleBar"
23+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
24+
android:hardwareAccelerated="true"
25+
android:windowSoftInputMode="adjustResize">
26+
<intent-filter>
27+
<action android:name="android.intent.action.MAIN"/>
28+
<category android:name="android.intent.category.LAUNCHER"/>
29+
</intent-filter>
30+
</activity>
31+
</application>
32+
</manifest>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.flutter.plugins;
2+
3+
import io.flutter.app.FlutterActivity;
4+
5+
import io.flutter.plugins.path_provider.PathProviderPlugin;
6+
7+
/**
8+
* Generated file. Do not edit.
9+
*/
10+
11+
public class PluginRegistry {
12+
public PathProviderPlugin path_provider;
13+
14+
public void registerAll(FlutterActivity activity) {
15+
path_provider = PathProviderPlugin.register(activity);
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.flutter.plugins.path_provider_example;
2+
3+
import android.os.Bundle;
4+
import io.flutter.app.FlutterActivity;
5+
import io.flutter.plugins.PluginRegistry;
6+
7+
public class MainActivity extends FlutterActivity {
8+
PluginRegistry pluginRegistry;
9+
10+
@Override
11+
protected void onCreate(Bundle savedInstanceState) {
12+
super.onCreate(savedInstanceState);
13+
pluginRegistry = new PluginRegistry();
14+
pluginRegistry.registerAll(this);
15+
}
16+
}
Loading
Loading
Loading
Loading
Loading
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
}
5+
6+
dependencies {
7+
classpath 'com.android.tools.build:gradle:2.2.3'
8+
}
9+
}
10+
11+
allprojects {
12+
repositories {
13+
jcenter()
14+
}
15+
}
16+
17+
rootProject.buildDir = '../build'
18+
subprojects {
19+
project.buildDir = "${rootProject.buildDir}/${project.name}"
20+
project.evaluationDependsOn(':app')
21+
}
22+
23+
task clean(type: Delete) {
24+
delete rootProject.buildDir
25+
}
26+
27+
task wrapper(type: Wrapper) {
28+
gradleVersion = '2.14.1'
29+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.jvmargs=-Xmx1536M
Lines changed: 15 additions & 0 deletions
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)