diff --git a/lib/components/dialogs/bootstrap_dialog.dart b/lib/components/dialogs/bootstrap_dialog.dart index 66cadc96..a694c34a 100644 --- a/lib/components/dialogs/bootstrap_dialog.dart +++ b/lib/components/dialogs/bootstrap_dialog.dart @@ -1,6 +1,7 @@ import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:famedlysdk/encryption.dart'; import 'package:famedlysdk/encryption/utils/bootstrap.dart'; +import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/components/dialogs/adaptive_flat_button.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:fluffychat/utils/platform_infos.dart'; @@ -8,16 +9,21 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; -import '../matrix.dart'; - class BootstrapDialog extends StatefulWidget { - const BootstrapDialog({Key key, @required this.l10n}) : super(key: key); + const BootstrapDialog({ + Key key, + @required this.l10n, + @required this.client, + this.easyMode = false, + }) : super(key: key); Future show(BuildContext context) => PlatformInfos.isCupertinoStyle ? showCupertinoDialog(context: context, builder: (context) => this) : showDialog(context: context, builder: (context) => this); final L10n l10n; + final Client client; + final bool easyMode; @override _BootstrapDialogState createState() => _BootstrapDialogState(); @@ -28,17 +34,17 @@ class _BootstrapDialogState extends State { @override Widget build(BuildContext context) { - bootstrap ??= Matrix.of(context) - .client - .encryption + bootstrap ??= widget.client.encryption .bootstrap(onUpdate: () => setState(() => null)); final buttons = []; Widget body; + var titleText = widget.l10n.cachedKeys; switch (bootstrap.state) { case BootstrapState.loading: body = LinearProgressIndicator(); + titleText = widget.l10n.loadingPleaseWait; break; case BootstrapState.askWipeSsss: body = Text('Wipe chat backup?'); @@ -208,7 +214,7 @@ class _BootstrapDialogState extends State { break; } - final title = Text('Chat backup'); + final title = Text(titleText); if (PlatformInfos.isCupertinoStyle) { return CupertinoAlertDialog( title: title, diff --git a/lib/components/matrix.dart b/lib/components/matrix.dart index 74520ab6..9ba33221 100644 --- a/lib/components/matrix.dart +++ b/lib/components/matrix.dart @@ -139,13 +139,18 @@ class MatrixState extends State { final stage = uiaRequest.nextStages.first; switch (stage) { case AuthenticationTypes.password: - final input = await showTextInputDialog(context: context, textFields: [ - DialogTextField( - minLines: 1, - maxLines: 1, - obscureText: true, - ) - ]); + final input = await showTextInputDialog( + context: context, + title: L10n.of(context).pleaseEnterYourPassword, + textFields: [ + DialogTextField( + minLines: 1, + maxLines: 1, + obscureText: true, + hintText: '******', + ) + ], + ); if (input?.isEmpty ?? true) return; return uiaRequest.completeStage( AuthenticationPassword( diff --git a/lib/views/invitation_selection.dart b/lib/views/invitation_selection.dart index 8bc511d0..eb1193d2 100644 --- a/lib/views/invitation_selection.dart +++ b/lib/views/invitation_selection.dart @@ -78,9 +78,7 @@ class _InvitationSelectionState extends State { void searchUser(BuildContext context, String text) async { coolDown?.cancel(); if (text.isEmpty) { - setState(() { - foundProfiles = []; - }); + setState(() => foundProfiles = []); } currentSearchTerm = text; if (currentSearchTerm.isEmpty) return; diff --git a/lib/views/settings.dart b/lib/views/settings.dart index b074e4b5..b7d29f63 100644 --- a/lib/views/settings.dart +++ b/lib/views/settings.dart @@ -486,109 +486,6 @@ class _SettingsState extends State { title: Text(L10n.of(context).appLock), onTap: () => _setAppLockAction(context), ), - ListTile( - trailing: Icon(Icons.compare_arrows_outlined), - title: Text(client.encryption.crossSigning.enabled - ? L10n.of(context).crossSigningEnabled - : L10n.of(context).crossSigningDisabled), - subtitle: client.encryption.crossSigning.enabled - ? Text(client.isUnknownSession - ? L10n.of(context).unknownSessionVerify - : L10n.of(context).sessionVerified + - ', ' + - (crossSigningCached == null - ? '⌛' - : (crossSigningCached - ? L10n.of(context).keysCached - : L10n.of(context).keysMissing))) - : null, - onTap: () async { - if (!client.encryption.crossSigning.enabled) { - return BootstrapDialog(l10n: L10n.of(context)) - .show(context); - } - if (client.isUnknownSession) { - final input = await showTextInputDialog( - context: context, - title: L10n.of(context).askSSSSVerify, - textFields: [ - DialogTextField( - hintText: L10n.of(context).passphraseOrKey, - obscureText: true, - minLines: 1, - maxLines: 1, - ) - ], - ); - if (input != null) { - final valid = await showFutureLoadingDialog( - context: context, - future: () async { - // make sure the loading spinner shows before we test the keys - await Future.delayed(Duration(milliseconds: 100)); - var valid = false; - try { - await client.encryption.crossSigning - .selfSign(recoveryKey: input.single); - valid = true; - } catch (_) { - try { - await client.encryption.crossSigning - .selfSign(passphrase: input.single); - valid = true; - } catch (_) { - valid = false; - } - } - return valid; - }); - - if (valid.result == true) { - await showOkAlertDialog( - context: context, - message: L10n.of(context).verifiedSession, - ); - setState(() { - crossSigningCachedFuture = null; - crossSigningCached = null; - megolmBackupCachedFuture = null; - megolmBackupCached = null; - }); - } else { - await showOkAlertDialog( - context: context, - message: L10n.of(context).incorrectPassphraseOrKey, - ); - } - } - } - if (!(await client.encryption.crossSigning.isCached())) { - await requestSSSSCache(context); - } - }, - ), - ListTile( - trailing: Icon(Icons.wb_cloudy_outlined), - title: Text(client.encryption.keyManager.enabled - ? L10n.of(context).onlineKeyBackupEnabled - : L10n.of(context).onlineKeyBackupDisabled), - subtitle: client.encryption.keyManager.enabled - ? Text(megolmBackupCached == null - ? '⌛' - : (megolmBackupCached - ? L10n.of(context).keysCached - : L10n.of(context).keysMissing)) - : null, - onTap: () async { - if (!client.encryption.keyManager.enabled) { - return BootstrapDialog(l10n: L10n.of(context)) - .show(context); - } - if (!(await client.encryption.keyManager.isCached())) { - await requestSSSSCache(context); - } - }, - ), ListTile( title: Text(L10n.of(context).yourPublicKey), onTap: () => showOkAlertDialog( @@ -598,6 +495,16 @@ class _SettingsState extends State { ), trailing: Icon(Icons.vpn_key_outlined), ), + ListTile( + title: Text(L10n.of(context).cachedKeys), + trailing: Icon(Icons.wb_cloudy_outlined), + subtitle: Text( + '${client.encryption.keyManager.enabled ? L10n.of(context).onlineKeyBackupEnabled : L10n.of(context).onlineKeyBackupDisabled}\n${client.encryption.crossSigning.enabled ? L10n.of(context).crossSigningEnabled : L10n.of(context).crossSigningDisabled}'), + onTap: () => BootstrapDialog( + l10n: L10n.of(context), + client: Matrix.of(context).client, + ).show(context), + ), }, Divider(thickness: 1), ListTile(