mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 09:45:14 +00:00
fix: Start on Android and Linux
This commit is contained in:
parent
a1c5e9a061
commit
ad21986ae8
5 changed files with 44 additions and 21 deletions
1
android/app/proguard-rules.pro
vendored
1
android/app/proguard-rules.pro
vendored
|
@ -7,3 +7,4 @@
|
|||
-keep class io.flutter.** { *; }
|
||||
-keep class io.flutter.plugins.** { *; }
|
||||
-dontwarn io.flutter.embedding.**
|
||||
-keep class net.sqlcipher.** { *; }
|
|
@ -10,6 +10,7 @@ import 'package:encrypt/encrypt.dart';
|
|||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart' as ffi;
|
||||
import 'package:sqflite_sqlcipher/sqflite.dart' as sqflite;
|
||||
|
||||
class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
||||
|
@ -27,10 +28,8 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
|||
static Future<FluffyBoxDatabase> databaseBuilder(Client client) async {
|
||||
Logs().d('Open FluffyBox...');
|
||||
String? password;
|
||||
if (!kIsWeb && (Platform.isAndroid || Platform.isIOS)) {
|
||||
try {
|
||||
// Workaround for secure storage is calling Platform.operatingSystem on web
|
||||
if (kIsWeb) throw MissingPluginException();
|
||||
|
||||
const secureStorage = FlutterSecureStorage();
|
||||
final containsEncryptionKey =
|
||||
await secureStorage.containsKey(key: _cipherStorageKey);
|
||||
|
@ -48,6 +47,7 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
|||
} on MissingPluginException catch (_) {
|
||||
Logs().i('FluffyBox encryption is not supported on this platform');
|
||||
}
|
||||
}
|
||||
|
||||
final db = FluffyBoxDatabase(
|
||||
'fluffybox_${client.clientName.replaceAll(' ', '_').toLowerCase()}',
|
||||
|
@ -63,7 +63,18 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
|||
String? password,
|
||||
) async {
|
||||
final path = await _findDatabasePath(client);
|
||||
return await sqflite.openDatabase(path, password: password);
|
||||
try {
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
//opensqflite.open.overrideFor(sqlite3.OperatingSystem.android, openCipherOnAndroid);
|
||||
final db = await sqflite.openDatabase(path, password: password);
|
||||
return db;
|
||||
}
|
||||
final db = await ffi.databaseFactoryFfi.openDatabase(path);
|
||||
return db;
|
||||
} catch (_) {
|
||||
File(path).delete();
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<String> _findDatabasePath(Client client) async {
|
||||
|
|
|
@ -1319,7 +1319,7 @@ packages:
|
|||
source: hosted
|
||||
version: "2.0.1+1"
|
||||
sqflite_common_ffi:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sqflite_common_ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
|
@ -1332,6 +1332,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
sqlcipher_flutter_libs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sqlcipher_flutter_libs
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.5.1"
|
||||
sqlite3:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -67,7 +67,9 @@ dependencies:
|
|||
sentry: ^6.0.1
|
||||
share: ^2.0.4
|
||||
slugify: ^2.0.0
|
||||
sqflite_common_ffi: ^2.1.0
|
||||
sqflite_sqlcipher: ^2.1.0
|
||||
sqlcipher_flutter_libs: ^0.5.1
|
||||
swipe_to_action: ^0.2.0
|
||||
uni_links: ^0.5.1
|
||||
unifiedpush: ^1.0.6
|
||||
|
|
|
@ -67,6 +67,8 @@ parts:
|
|||
stage-packages:
|
||||
- libsecret-1-dev
|
||||
- libjsoncpp-dev
|
||||
- libsqlite3-0
|
||||
- libsqlite3-dev
|
||||
gnome-3-28-extension:
|
||||
build-packages:
|
||||
- gcc
|
||||
|
|
Loading…
Reference in a new issue