Merge branch 'krille/sdk-update' into 'main'

refactor: SDK update

See merge request ChristianPauly/fluffychat-flutter!279
This commit is contained in:
Christian Pauly 2020-11-21 08:50:29 +00:00
commit 76e9d638e4
6 changed files with 115 additions and 187 deletions

View File

@ -261,16 +261,11 @@ class InputBar extends StatelessWidget {
maxLines: maxLines, maxLines: maxLines,
keyboardType: keyboardType, keyboardType: keyboardType,
autofocus: autofocus, autofocus: autofocus,
onSubmitted: (text) { onSubmitted: onSubmitted,
// fix for library for now
onSubmitted(text);
},
focusNode: focusNode, focusNode: focusNode,
controller: controller, controller: controller,
decoration: decoration, decoration: decoration,
onChanged: (text) { onChanged: onChanged,
onChanged(text);
},
textCapitalization: TextCapitalization.sentences, textCapitalization: TextCapitalization.sentences,
), ),
suggestionsCallback: getSuggestions, suggestionsCallback: getSuggestions,

View File

@ -38,12 +38,9 @@ class Matrix extends StatefulWidget {
final String clientName; final String clientName;
final Client client;
final Store store; final Store store;
Matrix({this.child, this.clientName, this.client, this.store, Key key}) Matrix({this.child, this.clientName, this.store, Key key}) : super(key: key);
: super(key: key);
@override @override
MatrixState createState() => MatrixState(); MatrixState createState() => MatrixState();
@ -90,8 +87,7 @@ class MatrixState extends State<Matrix> {
void _initWithStore() async { void _initWithStore() async {
var initLoginState = client.onLoginStateChanged.stream.first; var initLoginState = client.onLoginStateChanged.stream.first;
try { try {
client.database = await getDatabase(client); client.init();
await client.connect();
final firstLoginState = await initLoginState; final firstLoginState = await initLoginState;
if (firstLoginState == LoginState.logged) { if (firstLoginState == LoginState.logged) {
if (PlatformInfos.isMobile) { if (PlatformInfos.isMobile) {
@ -264,85 +260,84 @@ class MatrixState extends State<Matrix> {
void initMatrix() { void initMatrix() {
store = widget.store ?? Store(); store = widget.store ?? Store();
if (widget.client == null) {
debugPrint('[Matrix] Init matrix client');
final Set verificationMethods = <KeyVerificationMethod>{
KeyVerificationMethod.numbers
};
if (PlatformInfos.isMobile) {
// emojis don't show in web somehow
verificationMethods.add(KeyVerificationMethod.emoji);
}
client = Client(widget.clientName,
enableE2eeRecovery: true,
verificationMethods: verificationMethods,
importantStateEvents: <String>{
'im.ponies.room_emotes', // we want emotes to work properly
});
onJitsiCallSub ??= client.onEvent.stream
.where((e) =>
e.type == EventUpdateType.timeline &&
e.eventType == 'm.room.message' &&
e.content['content']['msgtype'] == Matrix.callNamespace &&
e.content['sender'] != client.userID)
.listen(onJitsiCall);
onRoomKeyRequestSub ??= final Set verificationMethods = <KeyVerificationMethod>{
client.onRoomKeyRequest.stream.listen((RoomKeyRequest request) async { KeyVerificationMethod.numbers
final room = request.room; };
if (request.sender != room.client.userID) { if (PlatformInfos.isMobile) {
return; // ignore share requests by others // emojis don't show in web somehow
} verificationMethods.add(KeyVerificationMethod.emoji);
final sender = room.getUserByMXIDSync(request.sender);
if (await showOkCancelAlertDialog(
context: context,
title: L10n.of(context).requestToReadOlderMessages,
message:
'${sender.id}\n\n${L10n.of(context).device}:\n${request.requestingDevice.deviceId}\n\n${L10n.of(context).identity}:\n${request.requestingDevice.curve25519Key.beautified}',
okLabel: L10n.of(context).verify,
cancelLabel: L10n.of(context).deny,
) ==
OkCancelResult.ok) {
await request.forwardKey();
}
});
onKeyVerificationRequestSub ??= client.onKeyVerificationRequest.stream
.listen((KeyVerification request) async {
var hidPopup = false;
request.onUpdate = () {
if (!hidPopup &&
{KeyVerificationState.done, KeyVerificationState.error}
.contains(request.state)) {
Navigator.of(context, rootNavigator: true).pop('dialog');
}
hidPopup = true;
};
if (await showOkCancelAlertDialog(
context: context,
title: L10n.of(context).newVerificationRequest,
message: L10n.of(context).askVerificationRequest(request.userId),
) ==
OkCancelResult.ok) {
request.onUpdate = null;
hidPopup = true;
await request.acceptVerification();
await Navigator.of(context).push(
AppRoute.defaultRoute(
context,
KeyVerificationView(request: request),
),
);
} else {
request.onUpdate = null;
hidPopup = true;
await request.rejectVerification();
}
});
_initWithStore();
} else {
client = widget.client;
client.connect();
} }
client = Client(
widget.clientName,
enableE2eeRecovery: true,
verificationMethods: verificationMethods,
importantStateEvents: <String>{
'im.ponies.room_emotes', // we want emotes to work properly
},
databaseBuilder: getDatabase,
);
onJitsiCallSub ??= client.onEvent.stream
.where((e) =>
e.type == EventUpdateType.timeline &&
e.eventType == 'm.room.message' &&
e.content['content']['msgtype'] == Matrix.callNamespace &&
e.content['sender'] != client.userID)
.listen(onJitsiCall);
onRoomKeyRequestSub ??=
client.onRoomKeyRequest.stream.listen((RoomKeyRequest request) async {
final room = request.room;
if (request.sender != room.client.userID) {
return; // ignore share requests by others
}
final sender = room.getUserByMXIDSync(request.sender);
if (await showOkCancelAlertDialog(
context: context,
title: L10n.of(context).requestToReadOlderMessages,
message:
'${sender.id}\n\n${L10n.of(context).device}:\n${request.requestingDevice.deviceId}\n\n${L10n.of(context).identity}:\n${request.requestingDevice.curve25519Key.beautified}',
okLabel: L10n.of(context).verify,
cancelLabel: L10n.of(context).deny,
) ==
OkCancelResult.ok) {
await request.forwardKey();
}
});
onKeyVerificationRequestSub ??= client.onKeyVerificationRequest.stream
.listen((KeyVerification request) async {
var hidPopup = false;
request.onUpdate = () {
if (!hidPopup &&
{KeyVerificationState.done, KeyVerificationState.error}
.contains(request.state)) {
Navigator.of(context, rootNavigator: true).pop('dialog');
}
hidPopup = true;
};
if (await showOkCancelAlertDialog(
context: context,
title: L10n.of(context).newVerificationRequest,
message: L10n.of(context).askVerificationRequest(request.userId),
) ==
OkCancelResult.ok) {
request.onUpdate = null;
hidPopup = true;
await request.acceptVerification();
await Navigator.of(context).push(
AppRoute.defaultRoute(
context,
KeyVerificationView(request: request),
),
);
} else {
request.onUpdate = null;
hidPopup = true;
await request.rejectVerification();
}
});
_initWithStore();
if (kIsWeb) { if (kIsWeb) {
onFocusSub = html.window.onFocus.listen((_) => webHasFocus = true); onFocusSub = html.window.onFocus.listen((_) => webHasFocus = true);
onBlurSub = html.window.onBlur.listen((_) => webHasFocus = false); onBlurSub = html.window.onBlur.listen((_) => webHasFocus = false);

View File

@ -4,6 +4,7 @@ import 'dart:io';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/sentry_controller.dart'; import 'package:fluffychat/utils/sentry_controller.dart';
import 'package:fluffychat/views/homeserver_picker.dart'; import 'package:fluffychat/views/homeserver_picker.dart';
import 'package:flushbar/flushbar_helper.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -46,6 +47,14 @@ class App extends StatelessWidget {
future: future:
Matrix.of(context).client.onLoginStateChanged.stream.first, Matrix.of(context).client.onLoginStateChanged.stream.first,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasError) {
WidgetsBinding.instance
.addPostFrameCallback((_) => FlushbarHelper.createError(
title: L10n.of(context).oopsSomethingWentWrong,
message: snapshot.error.toString(),
).show(context));
return HomeserverPicker();
}
if (!snapshot.hasData) { if (!snapshot.hasData) {
return Scaffold( return Scaffold(
body: Center( body: Center(

View File

@ -183,9 +183,7 @@ abstract class FirebaseController {
tempClient = true; tempClient = true;
final platform = kIsWeb ? 'Web' : Platform.operatingSystem; final platform = kIsWeb ? 'Web' : Platform.operatingSystem;
final clientName = 'FluffyChat $platform'; final clientName = 'FluffyChat $platform';
client = Client(clientName); client = Client(clientName, databaseBuilder: getDatabase)..init();
client.database = await getDatabase(client);
client.connect();
debugPrint('[Push] Use a temp client'); debugPrint('[Push] Use a temp client');
await client.onLoginStateChanged.stream await client.onLoginStateChanged.stream
.firstWhere((l) => l == LoginState.logged) .firstWhere((l) => l == LoginState.logged)

View File

@ -63,7 +63,7 @@ packages:
name: asn1lib name: asn1lib
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.5" version: "0.8.1"
async: async:
dependency: transitive dependency: transitive
description: description:
@ -99,6 +99,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
catex:
dependency: transitive
description:
name: catex
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+6"
characters: characters:
dependency: transitive dependency: transitive
description: description:
@ -196,7 +203,7 @@ packages:
name: encrypt name: encrypt
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.2" version: "4.1.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -208,8 +215,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: b1709ca8c3409f58ed711cff3fbe329e9b3c3a9c ref: "0697d47cc2791419ecf5dbc8840ac95bb6689e68"
resolved-ref: b1709ca8c3409f58ed711cff3fbe329e9b3c3a9c resolved-ref: "0697d47cc2791419ecf5dbc8840ac95bb6689e68"
url: "https://gitlab.com/famedly/famedlysdk.git" url: "https://gitlab.com/famedly/famedlysdk.git"
source: git source: git
version: "0.0.1" version: "0.0.1"
@ -356,20 +363,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_math:
dependency: transitive
description:
name: flutter_math
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+2"
flutter_matrix_html: flutter_matrix_html:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_matrix_html name: flutter_matrix_html
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.13" version: "0.1.12"
flutter_olm: flutter_olm:
dependency: "direct main" dependency: "direct main"
description: description:
@ -554,7 +554,7 @@ packages:
name: markdown name: markdown
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.8" version: "3.0.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -568,7 +568,7 @@ packages:
name: matrix_file_e2ee name: matrix_file_e2ee
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.4" version: "1.0.5"
matrix_link_text: matrix_link_text:
dependency: "direct main" dependency: "direct main"
description: description:
@ -613,13 +613,6 @@ packages:
url: "https://gitlab.com/famedly/libraries/native_imaging.git" url: "https://gitlab.com/famedly/libraries/native_imaging.git"
source: git source: git
version: "0.0.1" version: "0.0.1"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4"
node_interop: node_interop:
dependency: transitive dependency: transitive
description: description:
@ -745,7 +738,7 @@ packages:
name: pedantic name: pedantic
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0-nullsafety.1" version: "1.10.0-nullsafety.2"
permission_handler: permission_handler:
dependency: "direct main" dependency: "direct main"
description: description:
@ -794,14 +787,14 @@ packages:
name: pointycastle name: pointycastle
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "2.0.0"
pool: pool:
dependency: transitive dependency: transitive
description: description:
name: pool name: pool
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.5.0-nullsafety.1" version: "1.5.0-nullsafety.2"
process: process:
dependency: transitive dependency: transitive
description: description:
@ -809,13 +802,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.13" version: "3.0.13"
provider:
dependency: transitive
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.2+2"
pub_semver: pub_semver:
dependency: transitive dependency: transitive
description: description:
@ -911,14 +897,14 @@ packages:
name: source_map_stack_trace name: source_map_stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0-nullsafety.2" version: "2.1.0-nullsafety.3"
source_maps: source_maps:
dependency: transitive dependency: transitive
description: description:
name: source_maps name: source_maps
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.10.10-nullsafety.1" version: "0.10.10-nullsafety.2"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
@ -1024,13 +1010,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.5.9" version: "0.5.9"
tuple:
dependency: transitive
description:
name: tuple
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -1193,5 +1172,5 @@ packages:
source: hosted source: hosted
version: "0.1.2" version: "0.1.2"
sdks: sdks:
dart: ">=2.10.2 <=2.11.0-161.0.dev" dart: ">=2.10.2 <2.11.0"
flutter: ">=1.22.2 <2.0.0" flutter: ">=1.22.2 <2.0.0"

View File

@ -1,16 +1,6 @@
name: fluffychat name: fluffychat
description: Chat with your friends. description: Chat with your friends.
publish_to: none
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.22.0+49 version: 0.22.0+49
environment: environment:
@ -23,7 +13,7 @@ dependencies:
famedlysdk: famedlysdk:
git: git:
url: https://gitlab.com/famedly/famedlysdk.git url: https://gitlab.com/famedly/famedlysdk.git
ref: b1709ca8c3409f58ed711cff3fbe329e9b3c3a9c ref: 0697d47cc2791419ecf5dbc8840ac95bb6689e68
localstorage: ^3.0.3+6 localstorage: ^3.0.3+6
file_picker_cross: 4.2.2 file_picker_cross: 4.2.2
@ -50,7 +40,7 @@ dependencies:
mime_type: ^0.3.2 mime_type: ^0.3.2
flushbar: ^1.10.4 flushbar: ^1.10.4
adaptive_dialog: ^0.9.0+1 adaptive_dialog: ^0.9.0+1
flutter_matrix_html: ^0.1.13 flutter_matrix_html: ^0.1.12
moor: ^3.4.0 moor: ^3.4.0
sqlite3_flutter_libs: ^0.2.0 sqlite3_flutter_libs: ^0.2.0
sqlite3: ^0.1.8 sqlite3: ^0.1.8
@ -71,7 +61,7 @@ dependencies:
sentry: ">=3.0.0 <4.0.0" sentry: ">=3.0.0 <4.0.0"
scroll_to_index: ^1.0.6 scroll_to_index: ^1.0.6
swipe_to_action: ^0.1.0 swipe_to_action: ^0.1.0
flutter_svg: ^0.19.1 flutter_svg: 0.19.1 # Because fluffychat depends on flutter_svg >=0.19.2 which requires Flutter SDK version >=1.24.0-6.0.pre <2.0.0, version solving failed.
flutter_cache_manager: ^2.0.0 flutter_cache_manager: ^2.0.0
dev_dependencies: dev_dependencies:
@ -87,49 +77,11 @@ flutter_icons:
ios: false ios: false
image_path: "assets/logo.png" image_path: "assets/logo.png"
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter: flutter:
# Adds code generation (synthetic package) support
generate: true generate: true
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets: assets:
- assets/ - assets/
- assets/sounds/ - assets/sounds/
- assets/js/ - assets/js/
- assets/js/package/ - assets/js/package/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages