diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..c3632079 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,21 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/external/share_plus_aurora/aurora/include/**", + "/home/mars/Aurora_Platform_SDK_4.0.2.303/targets/AuroraOS-4.0.2.303-base-armv7hl/usr/include/flutter-embedder/**", + "/home/mars/Aurora_Platform_SDK_4.0.2.303/targets/AuroraOS-4.0.2.303-base-armv7hl/usr/include/qt5/**", + "/home/mars/Aurora_Platform_SDK_4.0.2.303/targets/AuroraOS-4.0.2.303-base-armv7hl/usr/include/auroraapp" + ], + "defines": [], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++14", + "intelliSenseMode": "linux-clang-x64", + "configurationProvider": "ms-vscode.cmake-tools" + } + ], + "version": 4 +} diff --git a/.vscode/launch.json b/.vscode/launch.json index 2e5a1bfb..5ac5b511 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,24 +2,16 @@ "version": "0.2.0", "configurations": [ { - "name": "app", - "cwd": "packages/app", + "name": "Attach with GDB", + "type": "cppdbg", "request": "launch", - "type": "dart" - }, - { - "name": "app (profile mode)", - "cwd": "packages/app", - "request": "launch", - "type": "dart", - "flutterMode": "profile" - }, - { - "name": "app (release mode)", - "cwd": "packages/app", - "request": "launch", - "type": "dart", - "flutterMode": "release" + "program": "./packages/app/build/aurora/psdk_4.0.2.303/aurora-arm/debug/su.markow.nextcloud-neon", + "MIMode": "gdb", + "miDebuggerPath": "/home/mars/.local/opt/gdb-14.1/bin/gdb", + "miDebuggerServerAddress": "192.168.1.95:10005", + "useExtendedRemote": true, + "cwd": "${workspaceRoot}", + "visualizerFile": "/home/mars/.config/Code/User/workspaceStorage/fea3d830734d8233dc16614e19dcbb1c/tonka3000.qtvsctools/qt.natvis.xml" } ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 60b29350..c4ba6b3e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,79 @@ }, "files.associations": { "*.arb": "json", - } + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "chrono": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "coroutine": "cpp", + "cstdint": "cpp", + "deque": "cpp", + "forward_list": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "ostream": "cpp", + "ranges": "cpp", + "shared_mutex": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "cinttypes": "cpp", + "typeindex": "cpp", + "typeinfo": "cpp", + "valarray": "cpp", + "variant": "cpp", + "qdbusconnectioninterface": "cpp" + }, + "cmake.sourceDirectory": "/home/mars/dev/aurora/neon/external/share_plus_aurora/aurora" } diff --git a/packages/app/aurora/desktop/su.markow.nextcloud-neon.desktop b/packages/app/aurora/desktop/su.markow.nextcloud-neon.desktop index 47092c67..a89f7977 100644 --- a/packages/app/aurora/desktop/su.markow.nextcloud-neon.desktop +++ b/packages/app/aurora/desktop/su.markow.nextcloud-neon.desktop @@ -4,9 +4,25 @@ Name=nextcloud-neon Comment=A new Flutter project. Icon=su.markow.nextcloud-neon Exec=/usr/bin/su.markow.nextcloud-neon -X-Nemo-Application-Type=silica-qt5 +#X-Nemo-Application-Type=silica-qt5 +#X-Share-Methods=files; +#X-Maemo-Service=su.markow.nextcloud-neon +#X-Maemo-Method=su.markow.nextcloud-neon.activateWindow [X-Application] -Permissions=UserDirs;Internet;Camera +Permissions=SecureStorage;UserDirs;Internet;Camera;Sharing OrganizationName=su.markow ApplicationName=nextcloud-neon +#ExecDBus=/usr/bin/su.markow.nextcloud-neon --dbus-launch + +[X-Sailjail] +Permissions=Sensors;SecureStorage;PushNotifications;DeviceInfo;Audio;Bluetooth;Camera;Internet;Location;MediaIndexing;Microphone;RemovableMedia;UserDirs +OrganizationName=su.markow +ApplicationName=nextcloud-neon +#ExecDBus=usr/bin/su.markow.nextcloud --dbus-launch + +#[X-Share Method files] +#Description=Nextcloud file share +#Description[ru]=Nextcloud обмена изображениями +#Capabilities=*/* +#SupportsMultipleFiles=yes diff --git a/packages/app/aurora/main.cpp b/packages/app/aurora/main.cpp index 331e26ef..2fe8bfbd 100644 --- a/packages/app/aurora/main.cpp +++ b/packages/app/aurora/main.cpp @@ -1,7 +1,10 @@ #include #include "generated_plugin_registrant.h" +#include int main(int argc, char *argv[]) { + //freopen("/home/defaultuser/Downloads/nextcloud.debug.out.txt", "w", stdout); + //freopen("/home/defaultuser/Downloads/nextcloud.debug.err.txt", "w", stderr); Application::Initialize(argc, argv); RegisterPlugins(); Application::Launch(); diff --git a/packages/app/aurora/rpm/su.markow.nextcloud-neon.spec b/packages/app/aurora/rpm/su.markow.nextcloud-neon.spec index 35e85b3b..60f43090 100644 --- a/packages/app/aurora/rpm/su.markow.nextcloud-neon.spec +++ b/packages/app/aurora/rpm/su.markow.nextcloud-neon.spec @@ -12,6 +12,7 @@ BuildRequires: cmake BuildRequires: pkgconfig(flutter-embedder) BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(streamcamera) +BuildRequires: pkgconfig(Qt5DBus) %description %{summary}. diff --git a/packages/app/linux/flutter/generated_plugin_registrant.cc b/packages/app/linux/flutter/generated_plugin_registrant.cc index 9db402be..c2d2a92c 100644 --- a/packages/app/linux/flutter/generated_plugin_registrant.cc +++ b/packages/app/linux/flutter/generated_plugin_registrant.cc @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -20,6 +21,9 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); file_selector_plugin_register_with_registrar(file_selector_linux_registrar); + g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); + flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); g_autoptr(FlPluginRegistrar) screen_retriever_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); diff --git a/packages/app/linux/flutter/generated_plugins.cmake b/packages/app/linux/flutter/generated_plugins.cmake index 92928726..bd40a488 100644 --- a/packages/app/linux/flutter/generated_plugins.cmake +++ b/packages/app/linux/flutter/generated_plugins.cmake @@ -5,6 +5,7 @@ list(APPEND FLUTTER_PLUGIN_LIST dynamic_color file_selector_linux + flutter_secure_storage_linux screen_retriever tray_manager url_launcher_linux diff --git a/packages/app/pubspec.lock b/packages/app/pubspec.lock index 962bdd0c..e2dfd87d 100644 --- a/packages/app/pubspec.lock +++ b/packages/app/pubspec.lock @@ -249,6 +249,14 @@ packages: relative: true source: path version: "1.0.0" + encrypt: + dependency: transitive + description: + name: encrypt + sha256: "62d9aa4670cc2a8798bab89b39fc71b6dfbacf615de6cf5001fb39f7e4a996a2" + url: "https://pub.dev" + source: hosted + version: "5.0.3" fake_async: dependency: transitive description: @@ -280,14 +288,31 @@ packages: relative: true source: path version: "1.0.0" - file_picker: + file_manager: dependency: transitive + description: + name: file_manager + sha256: "72c3ec25614ca7a115995db5ca6a7fe84ab3e9b9280e7ab25ab50b9c892f437e" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + file_picker: + dependency: "direct main" description: name: file_picker sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6" url: "https://pub.dev" source: hosted version: "6.1.1" + file_picker_aurora: + dependency: "direct main" + description: + path: "packages/file_picker/file_picker_aurora" + ref: file_picker_aurora + resolved-ref: fbcaeb1e3a8cb5118737529dd9d21eba1ff29913 + url: "https://gitlab.com/hooky-mars/flutter-plugins.git" + source: git + version: "0.0.1" file_selector_linux: dependency: transitive description: @@ -431,6 +456,63 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.17" + flutter_secure_storage: + dependency: "direct main" + description: + name: flutter_secure_storage + sha256: "22dbf16f23a4bcf9d35e51be1c84ad5bb6f627750565edd70dab70f3ff5fff8f" + url: "https://pub.dev" + source: hosted + version: "8.1.0" + flutter_secure_storage_aurora: + dependency: "direct main" + description: + path: "packages/flutter_secure_storage/flutter_secure_storage_aurora" + ref: "flutter_secure_storage_aurora-0.0.1" + resolved-ref: "569e04ade1870ee39b64a75dd2258fa463725de8" + url: "https://gitlab.com/omprussia/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + flutter_secure_storage_linux: + dependency: transitive + description: + name: flutter_secure_storage_linux + sha256: "3d5032e314774ee0e1a7d0a9f5e2793486f0dff2dd9ef5a23f4e3fb2a0ae6a9e" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + flutter_secure_storage_macos: + dependency: transitive + description: + name: flutter_secure_storage_macos + sha256: bd33935b4b628abd0b86c8ca20655c5b36275c3a3f5194769a7b3f37c905369c + url: "https://pub.dev" + source: hosted + version: "3.0.1" + flutter_secure_storage_platform_interface: + dependency: transitive + description: + name: flutter_secure_storage_platform_interface + sha256: "0d4d3a5dd4db28c96ae414d7ba3b8422fd735a8255642774803b2532c9a61d7e" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + flutter_secure_storage_web: + dependency: transitive + description: + name: flutter_secure_storage_web + sha256: "30f84f102df9dcdaa2241866a958c2ec976902ebdaa8883fbfe525f1f2f3cf20" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_secure_storage_windows: + dependency: transitive + description: + name: flutter_secure_storage_windows + sha256: "38f9501c7cb6f38961ef0e1eacacee2b2d4715c63cc83fe56449c4d3d0b47255" + url: "https://pub.dev" + source: hosted + version: "2.1.1" flutter_svg: dependency: transitive description: @@ -775,8 +857,8 @@ packages: dependency: transitive description: path: "packages/package_info_plus/package_info_plus_aurora" - ref: master - resolved-ref: "9c83303f10ec396bbb008e983659382ef69d4577" + ref: "package_info_plus_aurora-0.0.1" + resolved-ref: "5d3895d6b876a7c5239d66569ee1c59175713d34" url: "https://gitlab.com/omprussia/flutter/flutter-plugins.git" source: git version: "0.0.1" @@ -808,10 +890,10 @@ packages: dependency: "direct main" description: name: path_provider - sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa + sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" path_provider_android: dependency: transitive description: @@ -824,8 +906,8 @@ packages: dependency: "direct main" description: path: "packages/path_provider/path_provider_aurora" - ref: master - resolved-ref: "9c83303f10ec396bbb008e983659382ef69d4577" + ref: "path_provider_aurora-0.0.1" + resolved-ref: "4f2de1bfd4d111803553794327208609f1512016" url: "https://gitlab.com/omprussia/flutter/flutter-plugins.git" source: git version: "0.0.1" @@ -1045,6 +1127,15 @@ packages: url: "https://pub.dev" source: hosted version: "7.2.1" + share_plus_aurora: + dependency: transitive + description: + path: "packages/share_plus/share_plus_aurora" + ref: "share_plus_aurora-0.0.1" + resolved-ref: c089fd68e49a81017706de26d8897d91377bbbc3 + url: "https://gitlab.com/hooky-mars/flutter-plugins.git" + source: git + version: "0.0.1" share_plus_platform_interface: dependency: transitive description: @@ -1073,8 +1164,8 @@ packages: dependency: transitive description: path: "packages/shared_preferences/shared_preferences_aurora" - ref: master - resolved-ref: "9c83303f10ec396bbb008e983659382ef69d4577" + ref: "shared_preferences_aurora-0.0.1" + resolved-ref: "52c11f10424ea5c699a537a9a782eaa1bf596d5d" url: "https://gitlab.com/omprussia/flutter/flutter-plugins.git" source: git version: "0.0.1" @@ -1383,10 +1474,10 @@ packages: dependency: transitive description: name: uuid - sha256: df5a4d8f22ee4ccd77f8839ac7cb274ebc11ef9adcce8b92be14b797fe889921 + sha256: cd210a09f7c18cbe5a02511718e0334de6559871052c90a90c0cca46a4aa81c8 url: "https://pub.dev" source: hosted - version: "4.2.1" + version: "4.3.3" vector_graphics: dependency: "direct main" description: @@ -1527,8 +1618,8 @@ packages: dependency: transitive description: path: "packages/xdga_directories" - ref: master - resolved-ref: "9c83303f10ec396bbb008e983659382ef69d4577" + ref: "xdga_directories-0.0.1" + resolved-ref: "1869a4da50d080a8a7e8cc159783d83674a3490a" url: "https://gitlab.com/omprussia/flutter/flutter-plugins.git" source: git version: "0.0.1" @@ -1557,5 +1648,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" + dart: ">=3.2.2 <4.0.0" flutter: ">=3.13.0" diff --git a/packages/app/pubspec.yaml b/packages/app/pubspec.yaml index fe4f5b48..f5834528 100644 --- a/packages/app/pubspec.yaml +++ b/packages/app/pubspec.yaml @@ -9,6 +9,18 @@ environment: dependencies: flutter: sdk: flutter + flutter_secure_storage: ^8.0.0 + flutter_secure_storage_aurora: + git: + url: https://gitlab.com/omprussia/flutter/flutter-plugins.git + ref: flutter_secure_storage_aurora-0.0.1 + path: packages/flutter_secure_storage/flutter_secure_storage_aurora + file_picker: ^6.0.0 + file_picker_aurora: + git: + url: https://gitlab.com/hooky-mars/flutter-plugins.git + ref: file_picker_aurora + path: packages/file_picker/file_picker_aurora camera: ^0.10.5+5 camera_aurora: git: @@ -27,7 +39,7 @@ dependencies: path_provider_aurora: git: url: https://gitlab.com/omprussia/flutter/flutter-plugins.git - ref: master + ref: path_provider_aurora-0.0.1 path: packages/path_provider/path_provider_aurora neon: git: @@ -70,7 +82,8 @@ dev_dependencies: git: url: https://github.com/nextcloud/neon path: packages/nextcloud - shared_preferences: any + shared_preferences: ^2.1.2 + vector_graphics_compiler: any flutter: diff --git a/packages/neon/neon/lib/src/app.dart b/packages/neon/neon/lib/src/app.dart index 856eb204..58b37a40 100644 --- a/packages/neon/neon/lib/src/app.dart +++ b/packages/neon/neon/lib/src/app.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:collection/collection.dart'; import 'package:dynamic_color/dynamic_color.dart'; +import 'package:file_picker_aurora/app_router.dart'; import 'package:flutter/material.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart'; import 'package:meta/meta.dart'; @@ -54,7 +55,7 @@ class NeonApp extends StatefulWidget { // ignore: prefer_mixin class _NeonAppState extends State with WidgetsBindingObserver, tray.TrayListener, WindowListener { final _appRegex = RegExp(r'^app_([a-z]+)$', multiLine: true); - final _navigatorKey = GlobalKey(); + final _navigatorKey = FilePickerAuroraAppRouter.navigatorKey; late final Iterable _appImplementations; late final GlobalOptions _globalOptions; late final AccountsBloc _accountsBloc; diff --git a/packages/neon/neon/lib/src/pages/settings.dart b/packages/neon/neon/lib/src/pages/settings.dart index c2eb3098..762106a2 100644 --- a/packages/neon/neon/lib/src/pages/settings.dart +++ b/packages/neon/neon/lib/src/pages/settings.dart @@ -1,4 +1,5 @@ import 'package:file_picker/file_picker.dart'; +import 'package:file_picker_aurora/file_picker_aurora.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_material_design_icons/flutter_material_design_icons.dart'; @@ -270,6 +271,7 @@ class _SettingsPageState extends State { final settingsExportHelper = _buildSettingsExportHelper(context); try { + FilePickerAurora.registerWith(); final result = await FilePicker.platform.pickFiles( withReadStream: true, ); diff --git a/packages/neon/neon/lib/src/platform/android.dart b/packages/neon/neon/lib/src/platform/android.dart index 16fec76f..835467f8 100644 --- a/packages/neon/neon/lib/src/platform/android.dart +++ b/packages/neon/neon/lib/src/platform/android.dart @@ -23,10 +23,10 @@ class AndroidNeonPlatform implements NeonPlatform { bool get canUseCamera => true; @override - bool get canUsePushNotifications => true; + bool get canUsePushNotifications => false; @override - bool get canUseQuickActions => true; + bool get canUseQuickActions => false; @override bool get canUseSystemTray => false; diff --git a/packages/neon/neon/lib/src/platform/aurora.dart b/packages/neon/neon/lib/src/platform/aurora.dart index 3e8ae576..8ae820fc 100644 --- a/packages/neon/neon/lib/src/platform/aurora.dart +++ b/packages/neon/neon/lib/src/platform/aurora.dart @@ -21,10 +21,10 @@ class AuroraNeonPlatform implements NeonPlatform { bool get canUseCamera => true; @override - bool get canUsePushNotifications => true; + bool get canUsePushNotifications => false; @override - bool get canUseQuickActions => true; + bool get canUseQuickActions => false; @override bool get canUseSystemTray => false; @@ -39,7 +39,7 @@ class AuroraNeonPlatform implements NeonPlatform { bool get canUseSharing => true; @override - bool get shouldUseFileDialog => true; + bool get shouldUseFileDialog => false; @override Future get userAccessibleAppDataPath async { diff --git a/packages/neon/neon/lib/src/router.dart b/packages/neon/neon/lib/src/router.dart index 937c79e0..2dab1f52 100644 --- a/packages/neon/neon/lib/src/router.dart +++ b/packages/neon/neon/lib/src/router.dart @@ -7,7 +7,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:meta/meta.dart'; -import 'package:meta/meta_meta.dart'; import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/app_implementation.dart'; diff --git a/packages/neon/neon/lib/src/settings/models/storage.dart b/packages/neon/neon/lib/src/settings/models/storage.dart index 9dd1f394..b4fa60c2 100644 --- a/packages/neon/neon/lib/src/settings/models/storage.dart +++ b/packages/neon/neon/lib/src/settings/models/storage.dart @@ -1,6 +1,13 @@ +import 'dart:convert'; + +import 'package:collection/collection.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; import 'package:nextcloud/ids.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:flutter_secure_storage_aurora/flutter_secure_storage_aurora.dart'; /// Storage interface used by `Option`s. /// @@ -91,6 +98,162 @@ enum StorageKeys implements Storable { final String value; } +@internal +class SharedPreferencesAurora implements SharedPreferences { + static FlutterSecureStorage? _flutterSecureStorage; + static Map tmp = {}; + + static Future init() async { + FlutterSecureStorageAurora.setSecret('5872747ed1ceda3638qwerty8b2b18b20'); + _flutterSecureStorage = FlutterSecureStorage(); + tmp.addAll(await _flutterSecureStorage!.readAll()); + } + + @override + bool containsKey(final String key) => tmp.containsKey(key); + + @override + bool? getBool(final String key) { + if (tmp.containsKey(key)) { + return bool.parse(tmp[key]!); + } + + return null; + } + + @override + String? getString(final String key) => tmp[key]; + + @override + List? getStringList(final String key) { + if (tmp.containsKey(key)) { + final list = jsonDecode(tmp[key]!)['list'] as List; + final resut = List.empty(growable: true); + for (final item in list) { + resut.add(item as String); + } + + return resut; + } + + return null; + } + + @override + Future remove(final String key) async { + if (_flutterSecureStorage == null) { + throw StateError( + 'NeonStorage has not been initialized yet. Please make sure NeonStorage.init() has been called before and completed.', + ); + } + + tmp.remove(key); + await _flutterSecureStorage!.delete(key: key); + return true; + } + + @override + Future setBool(final String key, final bool value) async { + if (_flutterSecureStorage == null) { + throw StateError( + 'NeonStorage has not been initialized yet. Please make sure NeonStorage.init() has been called before and completed.', + ); + } + + tmp[key] = value.toString(); + await _flutterSecureStorage!.write(key: key, value: value.toString()); + return true; + } + + @override + Future setString(final String key, final String value) async { + if (_flutterSecureStorage == null) { + throw StateError( + 'NeonStorage has not been initialized yet. Please make sure NeonStorage.init() has been called before and completed.', + ); + } + + tmp[key] = value; + await _flutterSecureStorage!.write(key: key, value: value); + return true; + } + + @override + Future setStringList(final String key, final List value) async { + if (_flutterSecureStorage == null) { + throw StateError( + 'NeonStorage has not been initialized yet. Please make sure NeonStorage.init() has been called before and completed.', + ); + } + + final list = jsonEncode({'list': value}); + tmp[key] = list; + await _flutterSecureStorage!.write(key: key, value: list); + return true; + } + + @override + Future clear() async { + if (_flutterSecureStorage == null) { + throw StateError( + 'NeonStorage has not been initialized yet. Please make sure NeonStorage.init() has been called before and completed.', + ); + } + + tmp.clear(); + await _flutterSecureStorage!.deleteAll(); + return true; + } + + @override + Future commit() { + // TODO: implement commit + throw UnimplementedError(); + } + + @override + Object? get(String key) { + // TODO: implement get + throw UnimplementedError(); + } + + @override + double? getDouble(String key) { + // TODO: implement getDouble + throw UnimplementedError(); + } + + @override + int? getInt(String key) { + // TODO: implement getInt + throw UnimplementedError(); + } + + @override + Set getKeys() { + // TODO: implement getKeys + throw UnimplementedError(); + } + + @override + Future reload() { + // TODO: implement reload + throw UnimplementedError(); + } + + @override + Future setDouble(String key, double value) { + // TODO: implement setDouble + throw UnimplementedError(); + } + + @override + Future setInt(String key, int value) { + // TODO: implement setInt + throw UnimplementedError(); + } +} + /// Neon storage that manages the storage backend. /// /// [init] must be called and completed before accessing individual storages. @@ -122,7 +285,12 @@ final class NeonStorage { return; } - _sharedPreferences = await SharedPreferences.getInstance(); + if (TargetPlatform.aurora == defaultTargetPlatform) { + await SharedPreferencesAurora.init(); + _sharedPreferences = SharedPreferencesAurora(); + } else { + _sharedPreferences = await SharedPreferences.getInstance(); + } } /// Returns the database instance. diff --git a/packages/neon/neon/lib/src/utils/request_manager.dart b/packages/neon/neon/lib/src/utils/request_manager.dart index 5a08b242..dbc252fd 100644 --- a/packages/neon/neon/lib/src/utils/request_manager.dart +++ b/packages/neon/neon/lib/src/utils/request_manager.dart @@ -162,7 +162,11 @@ class RequestManager { final BehaviorSubject> subject, ) { final value = subject.valueOrNull?.copyWith(error: error, isLoading: false) ?? Result.error(error); - subject.add(value); + try { + subject.add(value); + } catch (e) { + print(e); + } } Future _emitCached( diff --git a/packages/neon/neon/lib/src/utils/save_file.dart b/packages/neon/neon/lib/src/utils/save_file.dart index d25c5286..4955f992 100644 --- a/packages/neon/neon/lib/src/utils/save_file.dart +++ b/packages/neon/neon/lib/src/utils/save_file.dart @@ -1,6 +1,7 @@ import 'dart:typed_data'; import 'package:file_picker/file_picker.dart'; +import 'package:file_picker_aurora/file_picker_aurora.dart'; import 'package:flutter_file_dialog/flutter_file_dialog.dart'; import 'package:neon/src/platform/platform.dart'; import 'package:universal_io/io.dart'; @@ -20,6 +21,7 @@ Future saveFileWithPickDialog(final String fileName, final Uint8List da ), ); } else { + FilePickerAurora.registerWith(); final result = await FilePicker.platform.saveFile( fileName: fileName, ); diff --git a/packages/neon/neon/pubspec.yaml b/packages/neon/neon/pubspec.yaml index 6675ee15..b27287f3 100644 --- a/packages/neon/neon/pubspec.yaml +++ b/packages/neon/neon/pubspec.yaml @@ -11,7 +11,13 @@ dependencies: crypto: ^3.0.0 cupertino_icons: ^1.0.0 dynamic_color: ^1.0.0 + file_manager: ^1.0.2 file_picker: ^6.0.0 + file_picker_aurora: + git: + url: https://gitlab.com/hooky-mars/flutter-plugins.git + ref: file_picker_aurora + path: packages/file_picker/file_picker_aurora filesize: ^2.0.0 flutter: sdk: flutter @@ -47,7 +53,7 @@ dependencies: shared_preferences_aurora: git: url: https://gitlab.com/omprussia/flutter/flutter-plugins.git - ref: master + ref: shared_preferences_aurora-0.0.1 path: packages/shared_preferences/shared_preferences_aurora sort_box: git: diff --git a/packages/neon/neon_files/lib/blocs/files.dart b/packages/neon/neon_files/lib/blocs/files.dart index 5ec0f9d5..d0c807ed 100644 --- a/packages/neon/neon_files/lib/blocs/files.dart +++ b/packages/neon/neon_files/lib/blocs/files.dart @@ -172,7 +172,9 @@ class FilesBloc extends InteractiveBloc implements FilesBlocEvents, FilesBlocSta } Future _cacheFile(final PathUri uri, final String etag) async { - final cacheDir = await getApplicationCacheDirectory(); + final cacheDir = TargetPlatform.aurora == defaultTargetPlatform + ? await getTemporaryDirectory() + : await getApplicationCacheDirectory(); final file = File(p.join(cacheDir.path, 'files', etag.replaceAll('"', ''), uri.name)); if (!file.existsSync()) { diff --git a/packages/neon/neon_files/lib/dialogs/choose_create.dart b/packages/neon/neon_files/lib/dialogs/choose_create.dart index 683fc80d..19d01e9c 100644 --- a/packages/neon/neon_files/lib/dialogs/choose_create.dart +++ b/packages/neon/neon_files/lib/dialogs/choose_create.dart @@ -16,6 +16,7 @@ class FilesChooseCreateDialog extends StatefulWidget { class _FilesChooseCreateDialogState extends State { Future uploadFromPick(final FileType type) async { + FilePickerAurora.registerWith(); final result = await FilePicker.platform.pickFiles( allowMultiple: true, type: type, diff --git a/packages/neon/neon_files/lib/neon_files.dart b/packages/neon/neon_files/lib/neon_files.dart index 31882f28..39c02fc9 100644 --- a/packages/neon/neon_files/lib/neon_files.dart +++ b/packages/neon/neon_files/lib/neon_files.dart @@ -29,7 +29,9 @@ import 'dart:async'; import 'package:collection/collection.dart'; import 'package:file_icons/file_icons.dart'; import 'package:file_picker/file_picker.dart'; +import 'package:file_picker_aurora/file_picker_aurora.dart'; import 'package:filesize/filesize.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_material_design_icons/flutter_material_design_icons.dart'; import 'package:go_router/go_router.dart'; diff --git a/packages/neon/neon_files/pubspec.yaml b/packages/neon/neon_files/pubspec.yaml index 75cab273..5424597d 100644 --- a/packages/neon/neon_files/pubspec.yaml +++ b/packages/neon/neon_files/pubspec.yaml @@ -13,6 +13,11 @@ dependencies: url: https://github.com/nextcloud/neon path: packages/file_icons file_picker: ^6.0.0 + file_picker_aurora: + git: + url: https://gitlab.com/hooky-mars/flutter-plugins.git + ref: file_picker_aurora + path: packages/file_picker/file_picker_aurora filesize: ^2.0.0 flutter: sdk: flutter @@ -33,9 +38,19 @@ dependencies: open_file: ^3.0.0 path: ^1.0.0 path_provider: ^2.0.0 + path_provider_aurora: + git: + url: https://gitlab.com/omprussia/flutter/flutter-plugins.git + ref: path_provider_aurora-0.0.1 + path: packages/path_provider/path_provider_aurora queue: ^3.0.0 rxdart: ^0.27.0 share_plus: ^7.0.0 + share_plus_aurora: + git: + url: https://gitlab.com/hooky-mars/flutter-plugins.git + ref: share_plus_aurora-0.0.1 + path: packages/share_plus/share_plus_aurora universal_io: ^2.0.0 dev_dependencies: