29 changed files with 870 additions and 0 deletions
@ -0,0 +1,31 @@ |
|||||||
|
# Miscellaneous |
||||||
|
*.class |
||||||
|
*.log |
||||||
|
*.pyc |
||||||
|
*.swp |
||||||
|
.DS_Store |
||||||
|
.atom/ |
||||||
|
.buildlog/ |
||||||
|
.history |
||||||
|
.svn/ |
||||||
|
migrate_working_dir/ |
||||||
|
|
||||||
|
# IntelliJ related |
||||||
|
*.iml |
||||||
|
*.ipr |
||||||
|
*.iws |
||||||
|
.idea/ |
||||||
|
|
||||||
|
# The .vscode folder contains launch configuration and tasks you configure in |
||||||
|
# VS Code which you may wish to be included in version control, so this line |
||||||
|
# is commented out by default. |
||||||
|
#.vscode/ |
||||||
|
|
||||||
|
# Flutter/Dart/Pub related |
||||||
|
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. |
||||||
|
/pubspec.lock |
||||||
|
**/doc/api/ |
||||||
|
.dart_tool/ |
||||||
|
.packages |
||||||
|
build/ |
||||||
|
/.metadata |
@ -0,0 +1,45 @@ |
|||||||
|
# path_provider_aurora |
||||||
|
|
||||||
|
The Aurora OS implementation of [`path_provider`](https://pub.dev/packages/path_provider). |
||||||
|
Documentation for setting permissions can be found [here](https://developer.auroraos.ru/doc/software_development/reference/user_data). |
||||||
|
|
||||||
|
## Usage |
||||||
|
|
||||||
|
This package is not an _endorsed_ implementation of `path_provider`. |
||||||
|
Therefore, you have to include `path_provider_aurora` alongside `path_provider` as dependencies in your `pubspec.yaml` file. |
||||||
|
|
||||||
|
**pubspec.yaml** |
||||||
|
|
||||||
|
```yaml |
||||||
|
dependencies: |
||||||
|
path_provider: ^2.0.14 |
||||||
|
path_provider_aurora: ^0.0.0 # @todo Not published |
||||||
|
``` |
||||||
|
|
||||||
|
***.dart** |
||||||
|
|
||||||
|
```dart |
||||||
|
import 'package:path_provider/path_provider.dart'; |
||||||
|
|
||||||
|
final Directory tempDir = await getTemporaryDirectory(); |
||||||
|
|
||||||
|
final Directory appDocumentsDir = await getApplicationDocumentsDirectory(); |
||||||
|
|
||||||
|
final Directory? downloadsDir = await getDownloadsDirectory(); |
||||||
|
``` |
||||||
|
|
||||||
|
## Supported APIs |
||||||
|
|
||||||
|
- [x] `getTemporaryDirectory` |
||||||
|
- [ ] `getApplicationSupportDirectory` |
||||||
|
- [ ] `getLibraryDirectory` |
||||||
|
- [x] `getApplicationDocumentsDirectory` |
||||||
|
- [ ] `getExternalStorageDirectory` |
||||||
|
- [ ] `getExternalCacheDirectories` |
||||||
|
- [x] `getExternalStorageDirectories` (There is no concept of External in Aurora OS, but this interface allows you to get the pictures/music/movies directory) |
||||||
|
- [x] `getDownloadsDirectory` |
||||||
|
|
||||||
|
## Extra methods |
||||||
|
|
||||||
|
PathProviderAurora.getApplicationOrg(); |
||||||
|
PathProviderAurora.getApplicationName(); |
@ -0,0 +1 @@ |
|||||||
|
include: package:flutter_lints/flutter.yaml |
@ -0,0 +1,23 @@ |
|||||||
|
cmake_minimum_required(VERSION 3.10) |
||||||
|
|
||||||
|
set(PROJECT_NAME path_provider_aurora) |
||||||
|
set(PLUGIN_NAME path_provider_aurora_platform_plugin) |
||||||
|
|
||||||
|
project(${PROJECT_NAME} LANGUAGES CXX) |
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17) |
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON) |
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-psabi") |
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3") |
||||||
|
|
||||||
|
find_package(PkgConfig REQUIRED) |
||||||
|
pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) |
||||||
|
|
||||||
|
add_library(${PLUGIN_NAME} SHARED path_provider_aurora_plugin.cpp) |
||||||
|
|
||||||
|
set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) |
||||||
|
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::FlutterEmbedder) |
||||||
|
|
||||||
|
target_include_directories(${PLUGIN_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) |
||||||
|
target_compile_definitions(${PLUGIN_NAME} PRIVATE PLUGIN_IMPL) |
@ -0,0 +1,24 @@ |
|||||||
|
#ifndef FLUTTER_PLUGIN_PATH_PROVIDER_AURORA_PLUGIN_H |
||||||
|
#define FLUTTER_PLUGIN_PATH_PROVIDER_AURORA_PLUGIN_H |
||||||
|
|
||||||
|
#include <flutter/plugin-interface.h> |
||||||
|
|
||||||
|
#ifdef PLUGIN_IMPL |
||||||
|
#define PLUGIN_EXPORT __attribute__((visibility("default"))) |
||||||
|
#else |
||||||
|
#define PLUGIN_EXPORT |
||||||
|
#endif |
||||||
|
|
||||||
|
class PLUGIN_EXPORT PathProviderAuroraPlugin final : public PluginInterface |
||||||
|
{ |
||||||
|
public: |
||||||
|
void RegisterWithRegistrar(PluginRegistrar ®istrar) override; |
||||||
|
|
||||||
|
private: |
||||||
|
void onMethodCall(const MethodCall &call); |
||||||
|
void onGetApplicationOrg(const MethodCall &call); |
||||||
|
void onGetApplicationName(const MethodCall &call); |
||||||
|
void unimplemented(const MethodCall &call); |
||||||
|
}; |
||||||
|
|
||||||
|
#endif /* FLUTTER_PLUGIN_PATH_PROVIDER_AURORA_PLUGIN_H */ |
@ -0,0 +1,43 @@ |
|||||||
|
#include <path_provider_aurora/path_provider_aurora_plugin.h> |
||||||
|
#include <flutter/method-channel.h> |
||||||
|
#include <flutter/application.h> |
||||||
|
#include <sys/utsname.h> |
||||||
|
|
||||||
|
void PathProviderAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) |
||||||
|
{ |
||||||
|
registrar.RegisterMethodChannel("path_provider_aurora", |
||||||
|
MethodCodecType::Standard, |
||||||
|
[this](const MethodCall &call) { this->onMethodCall(call); }); |
||||||
|
} |
||||||
|
|
||||||
|
void PathProviderAuroraPlugin::onMethodCall(const MethodCall &call) |
||||||
|
{ |
||||||
|
const auto &method = call.GetMethod(); |
||||||
|
|
||||||
|
if (method == "getApplicationOrg") { |
||||||
|
onGetApplicationOrg(call); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (method == "getApplicationName") { |
||||||
|
onGetApplicationName(call); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
unimplemented(call); |
||||||
|
} |
||||||
|
|
||||||
|
void PathProviderAuroraPlugin::onGetApplicationOrg(const MethodCall &call) |
||||||
|
{ |
||||||
|
call.SendSuccessResponse(Application::GetID().orgname); |
||||||
|
} |
||||||
|
|
||||||
|
void PathProviderAuroraPlugin::onGetApplicationName(const MethodCall &call) |
||||||
|
{ |
||||||
|
call.SendSuccessResponse(Application::GetID().appname); |
||||||
|
} |
||||||
|
|
||||||
|
void PathProviderAuroraPlugin::unimplemented(const MethodCall &call) |
||||||
|
{ |
||||||
|
call.SendSuccessResponse(nullptr); |
||||||
|
} |
After Width: | Height: | Size: 157 KiB |
@ -0,0 +1,45 @@ |
|||||||
|
# Miscellaneous |
||||||
|
*.class |
||||||
|
*.log |
||||||
|
*.pyc |
||||||
|
*.swp |
||||||
|
.DS_Store |
||||||
|
.atom/ |
||||||
|
.buildlog/ |
||||||
|
.history |
||||||
|
.svn/ |
||||||
|
migrate_working_dir/ |
||||||
|
|
||||||
|
# IntelliJ related |
||||||
|
*.iml |
||||||
|
*.ipr |
||||||
|
*.iws |
||||||
|
.idea/ |
||||||
|
|
||||||
|
# The .vscode folder contains launch configuration and tasks you configure in |
||||||
|
# VS Code which you may wish to be included in version control, so this line |
||||||
|
# is commented out by default. |
||||||
|
#.vscode/ |
||||||
|
|
||||||
|
# Flutter/Dart/Pub related |
||||||
|
**/doc/api/ |
||||||
|
**/ios/Flutter/.last_build_id |
||||||
|
.dart_tool/ |
||||||
|
.flutter-plugins |
||||||
|
.flutter-plugins-dependencies |
||||||
|
.packages |
||||||
|
.pub-cache/ |
||||||
|
.pub/ |
||||||
|
/build/ |
||||||
|
|
||||||
|
# Symbolication related |
||||||
|
app.*.symbols |
||||||
|
|
||||||
|
# Obfuscation related |
||||||
|
app.*.map.json |
||||||
|
|
||||||
|
# Android Studio will place build artifacts here |
||||||
|
/android/app/debug |
||||||
|
/android/app/profile |
||||||
|
/android/app/release |
||||||
|
pubspec.lock |
@ -0,0 +1,21 @@ |
|||||||
|
# path_provider_aurora_example |
||||||
|
|
||||||
|
Demonstrates how to use the path_provider_aurora plugin. |
||||||
|
|
||||||
|
## Build |
||||||
|
|
||||||
|
```shell |
||||||
|
# Add an alias if it doesn't already exist |
||||||
|
alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter |
||||||
|
# Get dependencies |
||||||
|
flutter-aurora pub get |
||||||
|
# Run build |
||||||
|
flutter-aurora build aurora --release # [--release|--debug|--profile] |
||||||
|
``` |
||||||
|
|
||||||
|
You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` |
||||||
|
More information in `build_example.sh`. |
||||||
|
|
||||||
|
### Preview example |
||||||
|
|
||||||
|
 |
@ -0,0 +1 @@ |
|||||||
|
include: package:flutter_lints/flutter.yaml |
@ -0,0 +1 @@ |
|||||||
|
flutter/ephemeral |
@ -0,0 +1,47 @@ |
|||||||
|
cmake_minimum_required(VERSION 3.10) |
||||||
|
project(com.example.path_provider_aurora_example LANGUAGES CXX) |
||||||
|
|
||||||
|
include(GNUInstallDirs) |
||||||
|
|
||||||
|
set(BINARY_NAME ${CMAKE_PROJECT_NAME}) |
||||||
|
set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) |
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17) |
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON) |
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra") |
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3") |
||||||
|
|
||||||
|
set(CMAKE_SKIP_RPATH OFF) |
||||||
|
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") |
||||||
|
|
||||||
|
find_package(PkgConfig REQUIRED) |
||||||
|
pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) |
||||||
|
|
||||||
|
add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) |
||||||
|
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder) |
||||||
|
target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) |
||||||
|
|
||||||
|
include(flutter/generated_plugins.cmake) |
||||||
|
|
||||||
|
set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) |
||||||
|
set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) |
||||||
|
set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) |
||||||
|
|
||||||
|
add_custom_command(TARGET ${BINARY_NAME} POST_BUILD |
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy |
||||||
|
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so |
||||||
|
${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) |
||||||
|
|
||||||
|
install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) |
||||||
|
install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) |
||||||
|
install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) |
||||||
|
|
||||||
|
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
||||||
|
install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) |
||||||
|
|
||||||
|
foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) |
||||||
|
install(FILES icons/${ICONS_SIZE}.png |
||||||
|
RENAME ${BINARY_NAME}.png |
||||||
|
DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) |
||||||
|
endforeach(ICONS_SIZE) |
@ -0,0 +1,12 @@ |
|||||||
|
[Desktop Entry] |
||||||
|
Type=Application |
||||||
|
Name=path_provider_aurora_example |
||||||
|
Comment=Demonstrates how to use the path_provider_aurora plugin. |
||||||
|
Icon=com.example.path_provider_aurora_example |
||||||
|
Exec=/usr/bin/com.example.path_provider_aurora_example |
||||||
|
X-Nemo-Application-Type=silica-qt5 |
||||||
|
|
||||||
|
[X-Application] |
||||||
|
Permissions=UserDirs |
||||||
|
OrganizationName=com.example |
||||||
|
ApplicationName=path_provider_aurora_example |
@ -0,0 +1,16 @@ |
|||||||
|
//
|
||||||
|
// Generated file. Do not edit.
|
||||||
|
//
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
|
#include <flutter/application.h> |
||||||
|
#include <path_provider_aurora/path_provider_aurora_plugin.h> |
||||||
|
|
||||||
|
#include "generated_plugin_registrant.h" |
||||||
|
|
||||||
|
void RegisterPlugins() { |
||||||
|
Application::RegisterPlugins({ |
||||||
|
std::make_shared<PathProviderAuroraPlugin>(), |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
//
|
||||||
|
// Generated file. Do not edit.
|
||||||
|
//
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
|
#ifndef GENERATED_PLUGIN_REGISTRANT |
||||||
|
#define GENERATED_PLUGIN_REGISTRANT |
||||||
|
|
||||||
|
void RegisterPlugins(); |
||||||
|
|
||||||
|
#endif /* GENERATED_PLUGIN_REGISTRANT */ |
@ -0,0 +1,32 @@ |
|||||||
|
# |
||||||
|
# Generated file, do not edit. |
||||||
|
# |
||||||
|
set(ROOT_PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}") |
||||||
|
|
||||||
|
function(add_library TARGET) |
||||||
|
_add_library(${TARGET} ${ARGN}) |
||||||
|
|
||||||
|
if(NOT "${TARGET}" MATCHES "^PkgConfig::.*") |
||||||
|
add_custom_command(TARGET ${TARGET} POST_BUILD |
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy |
||||||
|
"$<TARGET_FILE:${TARGET}>" |
||||||
|
"${ROOT_PROJECT_BINARY_DIR}/bundle/lib/$<TARGET_FILE_NAME:${TARGET}>") |
||||||
|
endif(NOT "${TARGET}" MATCHES "^PkgConfig::.*") |
||||||
|
endfunction() |
||||||
|
|
||||||
|
list(APPEND FLUTTER_PLATFORM_PLUGIN_LIST |
||||||
|
path_provider_aurora |
||||||
|
) |
||||||
|
|
||||||
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST |
||||||
|
xdga_directories |
||||||
|
) |
||||||
|
|
||||||
|
foreach(PLUGIN ${FLUTTER_PLATFORM_PLUGIN_LIST}) |
||||||
|
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${PLUGIN}/aurora plugins/${PLUGIN}) |
||||||
|
target_link_libraries(${BINARY_NAME} PRIVATE ${PLUGIN}_platform_plugin) |
||||||
|
endforeach(PLUGIN) |
||||||
|
|
||||||
|
foreach(FFI_PLUGIN ${FLUTTER_FFI_PLUGIN_LIST}) |
||||||
|
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${FFI_PLUGIN}/aurora plugins/${FFI_PLUGIN}) |
||||||
|
endforeach(FFI_PLUGIN) |
After Width: | Height: | Size: 9.7 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 6.5 KiB |
@ -0,0 +1,10 @@ |
|||||||
|
#include <flutter/application.h> |
||||||
|
#include "generated_plugin_registrant.h" |
||||||
|
|
||||||
|
int main(int argc, char *argv[]) { |
||||||
|
Application::Initialize(argc, argv); |
||||||
|
Application::SetPixelRatio(1.8); |
||||||
|
RegisterPlugins(); |
||||||
|
Application::Launch(); |
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ |
||||||
|
%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ |
||||||
|
|
||||||
|
Name: com.example.path_provider_aurora_example |
||||||
|
Summary: Demonstrates how to use the path_provider_aurora plugin. |
||||||
|
Version: 0.1.0 |
||||||
|
Release: 1 |
||||||
|
License: Proprietary |
||||||
|
Source0: %{name}-%{version}.tar.zst |
||||||
|
|
||||||
|
BuildRequires: cmake |
||||||
|
BuildRequires: pkgconfig(flutter-embedder) |
||||||
|
|
||||||
|
%description |
||||||
|
%{summary}. |
||||||
|
|
||||||
|
%prep |
||||||
|
%autosetup |
||||||
|
|
||||||
|
%build |
||||||
|
%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} |
||||||
|
%make_build |
||||||
|
|
||||||
|
%install |
||||||
|
%make_install |
||||||
|
|
||||||
|
%files |
||||||
|
%{_bindir}/%{name} |
||||||
|
%{_datadir}/%{name}/* |
||||||
|
%{_datadir}/applications/%{name}.desktop |
||||||
|
%{_datadir}/icons/hicolor/*/apps/%{name}.png |
@ -0,0 +1,249 @@ |
|||||||
|
import 'dart:io'; |
||||||
|
|
||||||
|
import 'package:flutter/material.dart'; |
||||||
|
import 'package:path_provider/path_provider.dart'; |
||||||
|
import 'package:path_provider_aurora/path_provider_aurora.dart'; |
||||||
|
|
||||||
|
void main() { |
||||||
|
runApp(const MyApp()); |
||||||
|
} |
||||||
|
|
||||||
|
class MyApp extends StatefulWidget { |
||||||
|
const MyApp({super.key}); |
||||||
|
|
||||||
|
@override |
||||||
|
State<MyApp> createState() => _MyAppState(); |
||||||
|
} |
||||||
|
|
||||||
|
class _MyAppState extends State<MyApp> { |
||||||
|
String? _error; |
||||||
|
String? _applicationOrg; |
||||||
|
String? _applicationName; |
||||||
|
String? _pathApplicationSupportDirectory; |
||||||
|
String? _pathTempDirectory; |
||||||
|
String? _pathApplicationDocumentsPath; |
||||||
|
String? _pathDownloadsPath; |
||||||
|
String? _pathPictures; |
||||||
|
String? _pathMusic; |
||||||
|
String? _pathMovies; |
||||||
|
|
||||||
|
@override |
||||||
|
void initState() { |
||||||
|
super.initState(); |
||||||
|
loadPathDirectory(); |
||||||
|
} |
||||||
|
|
||||||
|
/// Asynchronous function receiving directory paths |
||||||
|
Future<void> loadPathDirectory() async { |
||||||
|
try { |
||||||
|
// Get names |
||||||
|
String? applicationOrg = await PathProviderAurora.getApplicationOrg(); |
||||||
|
String? applicationName = await PathProviderAurora.getApplicationName(); |
||||||
|
|
||||||
|
// Get directories |
||||||
|
Directory? applicationSupportDirectory = await getApplicationSupportDirectory(); |
||||||
|
Directory? tempDirectory = await getTemporaryDirectory(); |
||||||
|
Directory? pathApplicationDocumentsPath = await getApplicationDocumentsDirectory(); |
||||||
|
Directory? pathDownloadsPath = await getDownloadsDirectory(); |
||||||
|
List<Directory>? pathPictures = await getExternalStorageDirectories(type: StorageDirectory.pictures); |
||||||
|
List<Directory>? pathMusic = await getExternalStorageDirectories(type: StorageDirectory.music); |
||||||
|
List<Directory>? pathMovies = await getExternalStorageDirectories(type: StorageDirectory.movies); |
||||||
|
|
||||||
|
// Update state variable |
||||||
|
setState(() { |
||||||
|
_applicationOrg = applicationOrg; |
||||||
|
_applicationName = applicationName; |
||||||
|
|
||||||
|
_pathApplicationSupportDirectory = applicationSupportDirectory.path; |
||||||
|
_pathTempDirectory = tempDirectory.path; |
||||||
|
_pathApplicationDocumentsPath = pathApplicationDocumentsPath.path; |
||||||
|
_pathDownloadsPath = pathDownloadsPath?.path; |
||||||
|
_pathPictures = pathPictures?.first.path; |
||||||
|
_pathMusic = pathMusic?.first.path; |
||||||
|
_pathMovies = pathMovies?.first.path; |
||||||
|
}); |
||||||
|
} on Exception catch (e) { |
||||||
|
setState(() { |
||||||
|
_error = e.toString(); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@override |
||||||
|
Widget build(BuildContext context) { |
||||||
|
const textStyleWhite = TextStyle(fontSize: 18, color: Colors.white); |
||||||
|
const textStyleTitle = TextStyle(fontSize: 20, color: Colors.black); |
||||||
|
const textStylePath = TextStyle(fontSize: 18, color: Colors.black54); |
||||||
|
|
||||||
|
const spaceMedium = SizedBox(height: 20); |
||||||
|
const spaceSmall = SizedBox(height: 10); |
||||||
|
|
||||||
|
return MaterialApp( |
||||||
|
home: Scaffold( |
||||||
|
appBar: AppBar( |
||||||
|
title: const Text('Example path_provider'), |
||||||
|
), |
||||||
|
body: Stack( |
||||||
|
children: [ |
||||||
|
// Error message |
||||||
|
Visibility( |
||||||
|
visible: _error != null, |
||||||
|
child: Center( |
||||||
|
child: Padding( |
||||||
|
padding: const EdgeInsets.all(16), |
||||||
|
child: Container( |
||||||
|
padding: const EdgeInsets.all(20), |
||||||
|
decoration: const BoxDecoration( |
||||||
|
color: Colors.redAccent, |
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10.0)), |
||||||
|
), |
||||||
|
child: Text( |
||||||
|
_error ?? '', |
||||||
|
style: textStyleWhite, |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
// List directories path |
||||||
|
Visibility( |
||||||
|
visible: _error == null, |
||||||
|
child: SingleChildScrollView( |
||||||
|
child: Padding( |
||||||
|
padding: const EdgeInsets.all(16), |
||||||
|
child: Center( |
||||||
|
child: Column( |
||||||
|
children: [ |
||||||
|
// Info |
||||||
|
Container( |
||||||
|
padding: const EdgeInsets.all(20), |
||||||
|
decoration: const BoxDecoration( |
||||||
|
color: Colors.green, |
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10.0)), |
||||||
|
), |
||||||
|
child: const Text( |
||||||
|
'Demo application demonstration implementation of path_provider', |
||||||
|
style: textStyleWhite, |
||||||
|
textAlign: TextAlign.center, |
||||||
|
), |
||||||
|
), |
||||||
|
const SizedBox(height: 30), |
||||||
|
|
||||||
|
// ApplicationOrg |
||||||
|
const Text( |
||||||
|
'Application Org', |
||||||
|
style: textStyleTitle, |
||||||
|
), |
||||||
|
spaceSmall, |
||||||
|
Text( |
||||||
|
_applicationOrg ?? 'Not found.', |
||||||
|
style: textStylePath, |
||||||
|
), |
||||||
|
|
||||||
|
spaceMedium, |
||||||
|
// ApplicationName |
||||||
|
const Text( |
||||||
|
'Application Name', |
||||||
|
style: textStyleTitle, |
||||||
|
), |
||||||
|
spaceSmall, |
||||||
|
Text( |
||||||
|
_applicationName ?? 'Not found.', |
||||||
|
style: textStylePath, |
||||||
|
), |
||||||
|
|
||||||
|
spaceMedium, |
||||||
|
// TempDirectory |
||||||
|
const Text( |
||||||
|
'ApplicationSupportDirectory', |
||||||
|
style: textStyleTitle, |
||||||
|
), |
||||||
|
spaceSmall, |
||||||
|
Text( |
||||||
|
_pathApplicationSupportDirectory ?? 'Not found.', |
||||||
|
style: textStylePath, |
||||||
|
), |
||||||
|
|
||||||
|
spaceMedium, |
||||||
|
// TempDirectory |
||||||
|
const Text( |
||||||
|
'TempDirectory', |
||||||
|
style: textStyleTitle, |
||||||
|
), |
||||||
|
spaceSmall, |
||||||
|
Text( |
||||||
|
_pathTempDirectory ?? 'Not found.', |
||||||
|
style: textStylePath, |
||||||
|
), |
||||||
|
spaceMedium, |
||||||
|
|
||||||
|
// ApplicationDocumentsPath |
||||||
|
const Text( |
||||||
|
'ApplicationDocumentsPath', |
||||||
|
style: textStyleTitle, |
||||||
|
), |
||||||
|
spaceSmall, |
||||||
|
Text( |
||||||
|
_pathApplicationDocumentsPath ?? 'Not found.', |
||||||
|
style: textStylePath, |
||||||
|
), |
||||||
|
spaceMedium, |
||||||
|
|
||||||
|
// DownloadsPath |
||||||
|
const Text( |
||||||
|
'DownloadsPath', |
||||||
|
style: textStyleTitle, |
||||||
|
), |
||||||
|
spaceSmall, |
||||||
|
Text( |
||||||
|
_pathDownloadsPath ?? 'Not found.', |
||||||
|
style: textStylePath, |
||||||
|
), |
||||||
|
spaceMedium, |
||||||
|
|
||||||
|
// Pictures |
||||||
|
const Text( |
||||||
|
'Pictures', |
||||||
|
style: textStyleTitle, |
||||||
|
), |
||||||
|
spaceSmall, |
||||||
|
Text( |
||||||
|
_pathPictures ?? 'Not found.', |
||||||
|
style: textStylePath, |
||||||
|
), |
||||||
|
spaceMedium, |
||||||
|
|
||||||
|
// Music |
||||||
|
const Text( |
||||||
|
'Music', |
||||||
|
style: textStyleTitle, |
||||||
|
), |
||||||
|
spaceSmall, |
||||||
|
Text( |
||||||
|
_pathMusic ?? 'Not found.', |
||||||
|
style: textStylePath, |
||||||
|
), |
||||||
|
spaceMedium, |
||||||
|
|
||||||
|
// Movies |
||||||
|
const Text( |
||||||
|
'Movies', |
||||||
|
style: textStyleTitle, |
||||||
|
), |
||||||
|
spaceSmall, |
||||||
|
Text( |
||||||
|
_pathMovies ?? 'Not found.', |
||||||
|
style: textStylePath, |
||||||
|
), |
||||||
|
], |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
], |
||||||
|
), |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
name: path_provider_aurora_example |
||||||
|
description: Demonstrates how to use the path_provider_aurora plugin. |
||||||
|
|
||||||
|
publish_to: 'none' |
||||||
|
|
||||||
|
environment: |
||||||
|
sdk: '>=2.18.6 <3.0.0' |
||||||
|
|
||||||
|
dependencies: |
||||||
|
flutter: |
||||||
|
sdk: flutter |
||||||
|
path_provider: ^2.0.7 |
||||||
|
path_provider_aurora: |
||||||
|
path: ../ |
||||||
|
cupertino_icons: ^1.0.2 |
||||||
|
|
||||||
|
dev_dependencies: |
||||||
|
flutter_test: |
||||||
|
sdk: flutter |
||||||
|
flutter_lints: ^2.0.0 |
||||||
|
|
||||||
|
flutter: |
||||||
|
uses-material-design: true |
@ -0,0 +1,81 @@ |
|||||||
|
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; |
||||||
|
import 'package:xdga_directories/xdga_directories.dart' as xdga_directories; |
||||||
|
import 'package:path/path.dart' as p; |
||||||
|
|
||||||
|
import 'path_provider_aurora_platform_interface.dart'; |
||||||
|
|
||||||
|
/// The aurora implementation of [PathProviderPlatform] |
||||||
|
/// |
||||||
|
/// This class implements the `package:path_provider` functionality for Aurora. |
||||||
|
class PathProviderAurora extends PathProviderPlatform { |
||||||
|
/// Registers this class as the default instance of [PathProviderPlatform] |
||||||
|
static void registerWith() { |
||||||
|
PathProviderPlatform.instance = PathProviderAurora(); |
||||||
|
} |
||||||
|
|
||||||
|
/// Get application name |
||||||
|
static Future<String?> getApplicationName() { |
||||||
|
return PathProviderAuroraPlatform.instance.getApplicationName(); |
||||||
|
} |
||||||
|
|
||||||
|
/// Get application org |
||||||
|
static Future<String?> getApplicationOrg() { |
||||||
|
return PathProviderAuroraPlatform.instance.getApplicationOrg(); |
||||||
|
} |
||||||
|
|
||||||
|
/// Path to a directory where the application may place application support files. |
||||||
|
@override |
||||||
|
Future<String?> getApplicationSupportPath() async { |
||||||
|
String? org = await getApplicationOrg(); |
||||||
|
String? name = await getApplicationName(); |
||||||
|
// QStandardPaths::AppDataLocation |
||||||
|
return p.join(xdga_directories.getAppDataLocation(), org, name); |
||||||
|
} |
||||||
|
|
||||||
|
/// Path to the temporary directory on the device that is not backed up and is |
||||||
|
/// suitable for storing caches of downloaded files. |
||||||
|
@override |
||||||
|
Future<String> getTemporaryPath() async { |
||||||
|
String? org = await getApplicationOrg(); |
||||||
|
String? name = await getApplicationName(); |
||||||
|
// QStandardPaths::CacheLocation |
||||||
|
return p.join(xdga_directories.getCacheLocation(), org, name); |
||||||
|
} |
||||||
|
|
||||||
|
/// Path to a directory where the application may place data that is |
||||||
|
/// user-generated, or that cannot otherwise be recreated by your application. |
||||||
|
@override |
||||||
|
Future<String> getApplicationDocumentsPath() async { |
||||||
|
// QStandardPaths::DocumentsLocation |
||||||
|
return xdga_directories.getDocumentsLocation(); |
||||||
|
} |
||||||
|
|
||||||
|
/// Path to the directory where downloaded files can be stored. |
||||||
|
/// This is typically only relevant on desktop operating systems. |
||||||
|
@override |
||||||
|
Future<String> getDownloadsPath() async { |
||||||
|
// QStandardPaths::DownloadLocation |
||||||
|
return xdga_directories.getDownloadLocation(); |
||||||
|
} |
||||||
|
|
||||||
|
/// Paths to directories where application specific data can be stored. |
||||||
|
/// These paths typically reside on external storage like separate partitions |
||||||
|
/// or SD cards. Phones may have multiple storage directories available. |
||||||
|
@override |
||||||
|
Future<List<String>?> getExternalStoragePaths({ |
||||||
|
/// Optional parameter. See [StorageDirectory] for more informations on |
||||||
|
/// how this type translates to Android storage directories. |
||||||
|
StorageDirectory? type, |
||||||
|
}) async { |
||||||
|
switch (type) { |
||||||
|
case StorageDirectory.pictures: |
||||||
|
return [xdga_directories.getPicturesLocation()]; // QStandardPaths::PicturesLocation |
||||||
|
case StorageDirectory.music: |
||||||
|
return [xdga_directories.getMusicLocation()]; // QStandardPaths::MusicLocation |
||||||
|
case StorageDirectory.movies: |
||||||
|
return [xdga_directories.getMoviesLocation()]; // QStandardPaths::MoviesLocation |
||||||
|
default: |
||||||
|
throw UnimplementedError('Type "$type" not supported.'); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
import 'package:flutter/foundation.dart'; |
||||||
|
import 'package:flutter/services.dart'; |
||||||
|
|
||||||
|
import 'path_provider_aurora_platform_interface.dart'; |
||||||
|
|
||||||
|
/// An implementation of [PathProviderAuroraPlatform] that uses method channels. |
||||||
|
class MethodChannelPathProviderAurora extends PathProviderAuroraPlatform { |
||||||
|
/// The method channel used to interact with the native platform. |
||||||
|
@visibleForTesting |
||||||
|
final methodChannel = const MethodChannel('path_provider_aurora'); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<String?> getApplicationOrg() async { |
||||||
|
return await methodChannel.invokeMethod<String>('getApplicationOrg'); |
||||||
|
} |
||||||
|
|
||||||
|
@override |
||||||
|
Future<String?> getApplicationName() async { |
||||||
|
return await methodChannel.invokeMethod<String>('getApplicationName'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
import 'package:plugin_platform_interface/plugin_platform_interface.dart'; |
||||||
|
|
||||||
|
import 'path_provider_aurora_method_channel.dart'; |
||||||
|
|
||||||
|
abstract class PathProviderAuroraPlatform extends PlatformInterface { |
||||||
|
/// Constructs a PathProviderAuroraPlatform. |
||||||
|
PathProviderAuroraPlatform() : super(token: _token); |
||||||
|
|
||||||
|
static final Object _token = Object(); |
||||||
|
|
||||||
|
static PathProviderAuroraPlatform _instance = MethodChannelPathProviderAurora(); |
||||||
|
|
||||||
|
/// The default instance of [PathProviderAuroraPlatform] to use. |
||||||
|
/// |
||||||
|
/// Defaults to [MethodChannelPathProviderAurora]. |
||||||
|
static PathProviderAuroraPlatform get instance => _instance; |
||||||
|
|
||||||
|
/// Platform-specific implementations should set this with their own |
||||||
|
/// platform-specific class that extends [PathProviderAuroraPlatform] when |
||||||
|
/// they register themselves. |
||||||
|
static set instance(PathProviderAuroraPlatform instance) { |
||||||
|
PlatformInterface.verifyToken(instance, _token); |
||||||
|
_instance = instance; |
||||||
|
} |
||||||
|
|
||||||
|
Future<String?> getApplicationOrg() { |
||||||
|
throw UnimplementedError('getApplicationOrg() has not been implemented.'); |
||||||
|
} |
||||||
|
|
||||||
|
Future<String?> getApplicationName() { |
||||||
|
throw UnimplementedError('getApplicationName() has not been implemented.'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
name: path_provider_aurora |
||||||
|
description: The Aurora OS implementation of path_provider. |
||||||
|
version: 0.0.1 |
||||||
|
|
||||||
|
environment: |
||||||
|
sdk: '>=2.18.6 <3.0.0' |
||||||
|
flutter: ">=2.5.0" |
||||||
|
|
||||||
|
dependencies: |
||||||
|
flutter: |
||||||
|
sdk: flutter |
||||||
|
path: ^1.8.2 |
||||||
|
plugin_platform_interface: ^2.0.2 |
||||||
|
path_provider_platform_interface: ^2.0.6 |
||||||
|
xdga_directories: |
||||||
|
git: |
||||||
|
url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git |
||||||
|
ref: dev |
||||||
|
path: packages/xdga_directories |
||||||
|
# xdga_directories: |
||||||
|
# path: ../../xdga_directories |
||||||
|
|
||||||
|
dev_dependencies: |
||||||
|
flutter_test: |
||||||
|
sdk: flutter |
||||||
|
flutter_lints: ^2.0.0 |
||||||
|
|
||||||
|
flutter: |
||||||
|
plugin: |
||||||
|
implements: path_provider |
||||||
|
platforms: |
||||||
|
aurora: |
||||||
|
dartPluginClass: PathProviderAurora |
||||||
|
pluginClass: PathProviderAuroraPlugin |
@ -0,0 +1,34 @@ |
|||||||
|
import 'package:flutter/services.dart'; |
||||||
|
import 'package:flutter_test/flutter_test.dart'; |
||||||
|
import 'package:path_provider_aurora/path_provider_aurora_method_channel.dart'; |
||||||
|
|
||||||
|
void main() { |
||||||
|
MethodChannelPathProviderAurora platform = MethodChannelPathProviderAurora(); |
||||||
|
const MethodChannel channel = MethodChannel('path_provider_aurora'); |
||||||
|
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized(); |
||||||
|
|
||||||
|
setUp(() { |
||||||
|
channel.setMockMethodCallHandler((MethodCall methodCall) async { |
||||||
|
switch (methodCall.method) { |
||||||
|
case 'getApplicationOrg': |
||||||
|
return 'com.example'; |
||||||
|
case 'getApplicationName': |
||||||
|
return 'path_provider_aurora'; |
||||||
|
} |
||||||
|
return ''; |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
tearDown(() { |
||||||
|
channel.setMockMethodCallHandler(null); |
||||||
|
}); |
||||||
|
|
||||||
|
test('onGetApplicationOrg', () async { |
||||||
|
expect(await platform.getApplicationOrg(), 'com.example'); |
||||||
|
}); |
||||||
|
|
||||||
|
test('onGetApplicationName', () async { |
||||||
|
expect(await platform.getApplicationName(), 'path_provider_aurora'); |
||||||
|
}); |
||||||
|
} |
Loading…
Reference in new issue