feat: Automatic key requests and better key error dialog

This commit is contained in:
Christian Pauly 2022-09-08 09:12:08 +02:00
parent 345ff51e6f
commit 1b857d461e
6 changed files with 53 additions and 23 deletions

View File

@ -2890,5 +2890,7 @@
}
},
"user": "User",
"custom": "Custom"
"custom": "Custom",
"whyIsThisMessageEncrypted": "Why is this message unreadable?",
"noKeyForThisMessage": "This can happen if the message was sent before you have signed in to your account at this device.\n\nIt is also possible that the sender has blocked your device or something went wrong with the internet connection.\n\nAre you able to read the message on another session? Then you can transfer the message from it! Go to Settings > Devices and make sure that your devices have verified each other. When you open the room the next time and both sessions are in the foreground, the keys will be transmitted automatically.\n\nDo you not want to loose the keys when logging out or switching devices? Make sure that you have enabled the chat backup in the settings."
}

View File

@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>

View File

@ -450,7 +450,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@ -539,7 +539,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@ -588,7 +588,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;

View File

@ -235,7 +235,7 @@ class ChatController extends State<Chat> {
});
}
filteredEvents = timeline!.getFilteredEvents(unfolded: unfolded);
timeline!.requestKeys();
timeline!.requestKeys(onlineKeyBackupOnly: false);
return true;
}

View File

@ -1,12 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:matrix/matrix.dart';
import 'package:matrix_link_text/link_text.dart';
import 'package:fluffychat/pages/chat/events/video_player.dart';
import 'package:fluffychat/utils/date_time_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/matrix.dart';
import '../../../config/app_config.dart';
import '../../../utils/platform_infos.dart';
@ -29,35 +30,62 @@ class MessageContent extends StatelessWidget {
: super(key: key);
void _verifyOrRequestKey(BuildContext context) async {
final l10n = L10n.of(context)!;
if (event.content['can_request_session'] != true) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
event.type == EventTypes.Encrypted
? L10n.of(context)!.needPantalaimonWarning
? l10n.needPantalaimonWarning
: event.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
MatrixLocals(l10n),
),
)));
return;
}
final client = Matrix.of(context).client;
if (client.isUnknownSession && client.encryption!.crossSigning.enabled) {
await BootstrapDialog(
final success = await BootstrapDialog(
client: Matrix.of(context).client,
).show(context);
final timeline = await event.room.getTimeline();
timeline.requestKeys();
timeline.cancelSubscriptions();
} else {
final success = await showFutureLoadingDialog(
context: context,
future: () => event.requestKey(),
);
if (success.error == null) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(L10n.of(context)!.requestToReadOlderMessages)));
}
if (success != true) return;
}
event.requestKey();
final sender = event.senderFromMemoryOrFallback;
await showModalBottomSheet(
context: context,
builder: (context) => Scaffold(
appBar: AppBar(
leading: CloseButton(onPressed: Navigator.of(context).pop),
title: Text(
l10n.whyIsThisMessageEncrypted,
style: const TextStyle(fontSize: 16),
),
),
body: SafeArea(
child: ListView(
padding: const EdgeInsets.all(16),
children: [
ListTile(
contentPadding: EdgeInsets.zero,
leading: Avatar(
mxContent: sender.avatarUrl,
name: sender.calcDisplayname(),
),
title: Text(sender.calcDisplayname()),
subtitle: Text(event.originServerTs.localizedTime(context)),
trailing: const Icon(Icons.lock_outlined),
),
const Divider(),
Text(
event.calcLocalizedBodyFallback(
MatrixLocals(l10n),
),
)
],
),
),
),
);
}
@override

View File

@ -175,7 +175,7 @@ class MatrixLocals extends MatrixLocalizations {
String get needPantalaimonWarning => l10n.needPantalaimonWarning;
@override
String get noPermission => l10n.noPermission;
String get noPermission => l10n.noKeyForThisMessage;
@override
String redactedAnEvent(String senderName) {