Skip to content

Commit 40bc8bf

Browse files
author
LaksCastro
committed
(#12) Update CHANGELOG and code docs
1 parent 2ed784c commit 40bc8bf

5 files changed

Lines changed: 119 additions & 80 deletions

File tree

CHANGELOG.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,31 @@ Major release focused on support for `Storage Access Framework`.
44

55
### Breaking Changes
66

7-
- New `minSdkVersion` set to `19`.
8-
- `getMediaStoreContentDirectory` return type set to `Uri`.
7+
- `minSdkVersion` set to `19`.
8+
- `getMediaStoreContentDirectory` return type changed to `Uri`.
9+
- Import package directive path is now modular. Which means you need to import the modules you are using:
10+
- `import 'package:shared_storage/saf.dart' as saf;` to enable **Storage Access Framework** API.
11+
- `import 'package:shared_storage/environment.dart' as environment;` to enable **Environment** API.
12+
- `import 'package:shared_storage/media_store.dart' as mediastore;` to enable **Media Store** API.
13+
- `import 'package:shared_storage/shared_storage' as sharedstorage;` if you want to import all above and as a single module (Not recommended because can conflict/override names/methods).
14+
15+
### New Features
16+
17+
- <samp>Mirror</samp> `createFile` from [DocumentFile.createFile()](<https://developer.android.com/reference/androidx/documentfile/provider/DocumentFile#createFile(java.lang.String,%20java.lang.String)>). Create a child file from given a parent uri.
18+
19+
- <samp>Mirror</samp> `child` from [DocumentFile.child()](<https://developer.android.com/reference/androidx/documentfile/provider/DocumentFile#createFile(java.lang.String,%20java.lang.String)>). Find the child file of a given parent uri and child name, null if doesn't exists.
20+
21+
- <samp>Original `UNSTABLE`</samp> `openDocumentFile`. Open a file uri in a external app, by starting a new activity with `ACTION_VIEW` Intent.
22+
23+
- <samp>Original `UNSTABLE`</samp> `getRealPathFromUri`. Return the real path to work with native old `File` API instead Uris, be aware this approach is no longer supported on Android 10+ (API 29+) and though new, this API is **marked as deprecated** and should be migrated to a _scoped-storage_ approach.
24+
25+
- <samp>Alias</samp> `getDocumentContentAsString`. Alias for `getDocumentContent` and convert all bytes into `String`.
26+
27+
-
928

1029
### Deprecation Notices
1130

12-
- `getExternalStoragePublicDirectory` was marked as deprecated and should be replaced with an equivalent API depending on your use-case, see [how to migrate `getExternalStoragePublicDirectory`](https://stackoverflow.com/questions/56468539/getexternalstoragepublicdirectory-deprecated-in-android-q).
31+
- `getExternalStoragePublicDirectory` was marked as deprecated and should be replaced with an equivalent API depending on your use-case, see [how to migrate `getExternalStoragePublicDirectory`](https://stackoverflow.com/questions/56468539/getexternalstoragepublicdirectory-deprecated-in-android-q). This deprecation is originated from official Android documentation and not by the plugin itself.
1332

1433
## 0.2.0
1534

android/src/main/kotlin/io/lakscastro/sharedstorage/storageaccessframework/DocumentFileHelperApi.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ import io.lakscastro.sharedstorage.storageaccessframework.lib.*
2929
* natively by Android.
3030
*
3131
* This is why it is separated from the original and raw `DocumentFileApi` which is the class that
32-
* only exposes the APIs without modifying them
32+
* only exposes the APIs without modifying them (Mirror API).
3333
*
3434
* Then here is where we can implement the main abstractions/use-cases which would be available
35-
* globally without modifying the strict APIs
35+
* globally without modifying the strict APIs.
3636
*/
3737
internal class DocumentFileHelperApi(private val plugin: SharedStoragePlugin) :
3838
MethodChannel.MethodCallHandler,

docs/Usage/Storage Access Framework.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ final Stream<PartialDocumentFile> onNewFileLoaded = documentFileOfMyGrantedUri.l
9090
onNewFileLoaded.listen((file) => files.add(file), onDone: () => print('All files were loaded'));
9191
```
9292

93+
### <samp>getRealPathFromUri</samp>
94+
95+
Helper method to generate the file path of the given `uri`.
96+
97+
See [Get real path from URI, Android KitKat new storage access framework](https://stackoverflow.com/questions/20067508/get-real-path-from-uri-android-kitkat-new-storage-access-framework/20559175#20559175) for details.
98+
99+
```dart
100+
/// Any valid Uri.
101+
final Uri myUri = ...;
102+
103+
final String? file = await getRealPathFromUri(myUri);
104+
```
105+
93106
## Mirror methods
94107

95108
Mirror methods are available to provide an way to call a native method without using any abstraction, available mirror methods:

lib/shared_storage.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export './environment.dart';
2+
export './media_store.dart';
3+
export './saf.dart';

0 commit comments

Comments
 (0)