Skip to content

Commit 8014f33

Browse files
seungsoo47swift-kim
authored andcommitted
[path_provider] Add path_provider_tizen package
1 parent cb71f1d commit 8014f33

19 files changed

+870
-0
lines changed

packages/path_provider/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
* Initial release

packages/path_provider/LICENSE

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
2+
Copyright (c) 2019 The Chromium Authors. All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are 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
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the names of the copyright holders nor the names of the
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

packages/path_provider/README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# path_provider_tizen
2+
3+
The Tizen implementation of [`path_provider`](https://github.com/flutter/plugins/tree/master/packages/path_provider).
4+
5+
## Usage
6+
7+
This package is not an _endorsed_ implementation of `path_provider`. Therefore, you have to include `path_provider_tizen` alongside `path_provider` as dependencies in your `pubspec.yaml` file.
8+
9+
```yaml
10+
dependencies:
11+
path_provider: ^1.6.10
12+
path_provider_tizen: ^1.0.0
13+
```
14+
15+
Then you can import `path_provider` in your Dart code:
16+
17+
```dart
18+
import 'package:path_provider/path_provider.dart';
19+
```
20+
21+
For detailed usage, see https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider#usage.
22+
23+
## Required privileges
24+
25+
To access paths returned by
26+
27+
- `getExternalDataPath`
28+
- `getExternalCachePath`
29+
30+
add below lines under the `<manifest>` section in your `tizen-manifest.xml` file.
31+
32+
```xml
33+
<privilege>http://tizen.org/privilege/externalstorage.appdata</privilege>
34+
```
35+
36+
To access paths returned by
37+
38+
- `getExternalStoragePaths`
39+
- `getDownloadsPath`
40+
41+
add below lines under the `<manifest>` section in your `tizen-manifest.xml` file,
42+
43+
```xml
44+
<privilege>http://tizen.org/privilege/mediastorage</privilege>
45+
```
46+
47+
and also acquire the **Storage** [permission](https://docs.tizen.org/application/dotnet/tutorials/sec-privileges) using the [`permission_handler`](https://pub.dev/packages/permission_handler_tizen) plugin (to be available soon).
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
**/ios/Flutter/.last_build_id
26+
.dart_tool/
27+
.flutter-plugins
28+
.flutter-plugins-dependencies
29+
.packages
30+
.pub-cache/
31+
.pub/
32+
/build/
33+
34+
# Web related
35+
lib/generated_plugin_registrant.dart
36+
37+
# Symbolication related
38+
app.*.symbols
39+
40+
# Obfuscation related
41+
app.*.map.json
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# path_provider_tizen_example
2+
3+
Demonstrates how to use the path_provider_tizen plugin.
4+
5+
## Getting Started
6+
7+
To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
import 'dart:io';
8+
import 'package:flutter_test/flutter_test.dart';
9+
import 'package:path_provider/path_provider.dart';
10+
import 'package:integration_test/integration_test.dart';
11+
12+
void main() {
13+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
14+
15+
testWidgets('getTemporaryDirectory', (WidgetTester tester) async {
16+
final Directory result = await getTemporaryDirectory();
17+
_verifySampleFile(result, 'temporaryDirectory');
18+
});
19+
20+
testWidgets('getApplicationDocumentsDirectory', (WidgetTester tester) async {
21+
final Directory result = await getApplicationDocumentsDirectory();
22+
_verifySampleFile(result, 'applicationDocuments');
23+
});
24+
25+
testWidgets('getApplicationSupportDirectory', (WidgetTester tester) async {
26+
final Directory result = await getApplicationSupportDirectory();
27+
_verifySampleFile(result, 'applicationSupport');
28+
});
29+
30+
testWidgets('getLibraryDirectory', (WidgetTester tester) async {
31+
if (Platform.isIOS) {
32+
final Directory result = await getLibraryDirectory();
33+
_verifySampleFile(result, 'library');
34+
} else if (Platform.isAndroid) {
35+
final Future<Directory> result = getLibraryDirectory();
36+
expect(result, throwsA(isInstanceOf<UnsupportedError>()));
37+
}
38+
});
39+
40+
testWidgets('getExternalStorageDirectory', (WidgetTester tester) async {
41+
if (Platform.isIOS) {
42+
final Future<Directory> result = getExternalStorageDirectory();
43+
expect(result, throwsA(isInstanceOf<UnsupportedError>()));
44+
} else if (Platform.isAndroid) {
45+
final Directory result = await getExternalStorageDirectory();
46+
_verifySampleFile(result, 'externalStorage');
47+
}
48+
});
49+
50+
testWidgets('getExternalCacheDirectories', (WidgetTester tester) async {
51+
if (Platform.isIOS) {
52+
final Future<List<Directory>> result = getExternalCacheDirectories();
53+
expect(result, throwsA(isInstanceOf<UnsupportedError>()));
54+
} else if (Platform.isAndroid) {
55+
final List<Directory> directories = await getExternalCacheDirectories();
56+
for (Directory result in directories) {
57+
_verifySampleFile(result, 'externalCache');
58+
}
59+
}
60+
});
61+
62+
final List<StorageDirectory> _allDirs = <StorageDirectory>[
63+
null,
64+
StorageDirectory.music,
65+
StorageDirectory.podcasts,
66+
StorageDirectory.ringtones,
67+
StorageDirectory.alarms,
68+
StorageDirectory.notifications,
69+
StorageDirectory.pictures,
70+
StorageDirectory.movies,
71+
];
72+
73+
for (StorageDirectory type in _allDirs) {
74+
test('getExternalStorageDirectories (type: $type)', () async {
75+
if (Platform.isIOS) {
76+
final Future<List<Directory>> result =
77+
getExternalStorageDirectories(type: null);
78+
expect(result, throwsA(isInstanceOf<UnsupportedError>()));
79+
} else if (Platform.isAndroid) {
80+
final List<Directory> directories =
81+
await getExternalStorageDirectories(type: type);
82+
for (Directory result in directories) {
83+
_verifySampleFile(result, '$type');
84+
}
85+
}
86+
});
87+
}
88+
}
89+
90+
/// Verify a file called [name] in [directory] by recreating it with test
91+
/// contents when necessary.
92+
void _verifySampleFile(Directory directory, String name) {
93+
final File file = File('${directory.path}/$name');
94+
95+
if (file.existsSync()) {
96+
file.deleteSync();
97+
expect(file.existsSync(), isFalse);
98+
}
99+
100+
file.writeAsStringSync('Hello world!');
101+
expect(file.readAsStringSync(), 'Hello world!');
102+
expect(directory.listSync(), isNotEmpty);
103+
file.deleteSync();
104+
}

0 commit comments

Comments
 (0)