From d388d8267c18d97fb9dc6892e2967f62080c6c1a Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sat, 15 Feb 2020 09:20:08 +0100 Subject: [PATCH] Enable libolm --- lib/i18n/i18n.dart | 3 + lib/utils/event_extension.dart | 7 ++- lib/views/app_info.dart | 80 +++++++++++++++++++++++++ lib/views/chat_encryption_settings.dart | 11 +++- lib/views/settings.dart | 11 ++++ 5 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 lib/views/app_info.dart diff --git a/lib/i18n/i18n.dart b/lib/i18n/i18n.dart index 70a0bdc..c427380 100644 --- a/lib/i18n/i18n.dart +++ b/lib/i18n/i18n.dart @@ -657,6 +657,9 @@ class I18n { String get visibilityOfTheChatHistory => Intl.message("Visibility of the chat history"); + String get warningEncryptionInBeta => Intl.message( + "End to end encryption is currently in Beta! Use at your own risk!"); + String get wednesday => Intl.message("Wednesday"); String get whoIsAllowedToJoinThisGroup => diff --git a/lib/utils/event_extension.dart b/lib/utils/event_extension.dart index debe7f0..0ffccc4 100644 --- a/lib/utils/event_extension.dart +++ b/lib/utils/event_extension.dart @@ -162,9 +162,10 @@ extension LocalizedBody on Event { break; case EventTypes.Encryption: localizedBody = - I18n.of(context).activatedEndToEndEncryption(senderName) + - ". " + - I18n.of(context).needPantalaimonWarning; + I18n.of(context).activatedEndToEndEncryption(senderName); + if (!room.client.encryptionEnabled) { + localizedBody += ". " + I18n.of(context).needPantalaimonWarning; + } break; case EventTypes.Encrypted: localizedBody = I18n.of(context).couldNotDecryptMessage; diff --git a/lib/views/app_info.dart b/lib/views/app_info.dart new file mode 100644 index 0000000..1b46ef7 --- /dev/null +++ b/lib/views/app_info.dart @@ -0,0 +1,80 @@ +import 'package:famedlysdk/famedlysdk.dart'; +import 'package:fluffychat/components/adaptive_page_layout.dart'; +import 'package:fluffychat/components/matrix.dart'; +import 'package:fluffychat/i18n/i18n.dart'; +import 'package:fluffychat/views/chat_list.dart'; +import 'package:flutter/material.dart'; +import 'package:olm/olm.dart' as olm; +import 'package:fluffychat/utils/beautify_string_extension.dart'; + +class AppInfoView extends StatelessWidget { + @override + Widget build(BuildContext context) { + return AdaptivePageLayout( + primaryPage: FocusPage.SECOND, + firstScaffold: ChatList(), + secondScaffold: AppInfo(), + ); + } +} + +class AppInfo extends StatelessWidget { + @override + Widget build(BuildContext context) { + Client client = Matrix.of(context).client; + return Scaffold( + appBar: AppBar( + title: Text("About FluffyChat"), + ), + body: ListView( + children: [ + ListTile( + title: Text(I18n.of(context).yourOwnUsername + ":"), + subtitle: Text(client.userID), + ), + ListTile( + title: Text("Homeserver:"), + subtitle: Text(client.homeserver), + ), + ListTile( + title: Text("Supported versions:"), + subtitle: Text(client.matrixVersions.toString()), + ), + ListTile( + title: Text("Lazy Loading members enabled:"), + subtitle: Text(client.lazyLoadMembers.toString()), + ), + ListTile( + title: Text("Device name:"), + subtitle: Text(client.deviceName), + ), + ListTile( + title: Text("Device ID:"), + subtitle: Text(client.deviceID), + ), + ListTile( + title: Text("Encryption enabled:"), + subtitle: Text(client.encryptionEnabled.toString()), + ), + if (client.encryptionEnabled) + Column( + children: [ + ListTile( + title: Text("Your public fingerprint key:"), + subtitle: Text(client.fingerprintKey.beautified), + ), + ListTile( + title: Text("Your public identity key:"), + subtitle: Text(client.identityKey.beautified), + ), + ListTile( + title: Text("LibOlm version:"), + subtitle: Text(olm.get_library_version().join(".")), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/views/chat_encryption_settings.dart b/lib/views/chat_encryption_settings.dart index 7dc89b5..5ff4303 100644 --- a/lib/views/chat_encryption_settings.dart +++ b/lib/views/chat_encryption_settings.dart @@ -84,9 +84,18 @@ class _ChatEncryptionSettingsState extends State { ListTile( trailing: Icon(Icons.info), subtitle: Text( - I18n.of(context).needPantalaimonWarning, + Matrix.of(context).encryptionEnabled + ? I18n.of(context).warningEncryptionInBeta + : I18n.of(context).needPantalaimonWarning, ), ), + if (room.encrypted) + ListTile( + title: Text("Outbound MegOlm session ID:"), + subtitle: Text( + room.outboundGroupSession?.session_id()?.beautified ?? + "None"), + ), Divider(height: 1), if (room.encrypted) ListTile( diff --git a/lib/views/settings.dart b/lib/views/settings.dart index 437c99d..170b37f 100644 --- a/lib/views/settings.dart +++ b/lib/views/settings.dart @@ -6,6 +6,7 @@ import 'package:fluffychat/components/content_banner.dart'; import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/utils/app_route.dart'; +import 'package:fluffychat/views/app_info.dart'; import 'package:fluffychat/views/chat_list.dart'; import 'package:fluffychat/views/sign_up.dart'; import 'package:flutter/foundation.dart'; @@ -132,6 +133,16 @@ class _SettingsState extends State { ), ), ), + ListTile( + leading: Icon(Icons.info), + title: Text(I18n.of(context).fluffychat), + onTap: () => Navigator.of(context).push( + AppRoute.defaultRoute( + context, + AppInfoView(), + ), + ), + ), ListTile( leading: Icon(Icons.sentiment_very_satisfied), title: Text(I18n.of(context).donate),