fix: Video calls

This commit is contained in:
Christian Pauly 2021-01-16 16:39:07 +01:00
parent a5e95539e3
commit 672eca6302
4 changed files with 25 additions and 29 deletions

View File

@ -5,9 +5,7 @@ import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:url_launcher/url_launcher.dart';
import '../app_config.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'matrix.dart';
@ -30,19 +28,6 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
super.dispose();
}
void startCallAction(BuildContext context) async {
final url =
'${AppConfig.jitsiInstance}${Uri.encodeComponent(widget.room.id.localpart)}';
final success = await showFutureLoadingDialog(
context: context,
future: () => widget.room.sendEvent({
'msgtype': Matrix.callNamespace,
'body': url,
}));
if (success.error != null) return;
await launch(url);
}
@override
Widget build(BuildContext context) {
notificationChangeSub ??= Matrix.of(context)
@ -110,9 +95,6 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
future: () =>
widget.room.setPushRuleState(PushRuleState.notify));
break;
case 'call':
startCallAction(context);
break;
case 'details':
if (AdaptivePageLayout.of(context).viewDataStack.length < 3) {
await AdaptivePageLayout.of(context)

View File

@ -320,14 +320,6 @@ class MatrixState extends State<Matrix> {
LoadingDialog.defaultBackLabel = L10n.of(context).close;
LoadingDialog.defaultOnError = (Object e) => e.toLocalizedString(context);
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;
@ -437,7 +429,7 @@ class MatrixState extends State<Matrix> {
void dispose() {
onRoomKeyRequestSub?.cancel();
onKeyVerificationRequestSub?.cancel();
onJitsiCallSub?.cancel();
onLoginStateChanged?.cancel();
onNotification?.cancel();
onFocusSub?.cancel();
onBlurSub?.cancel();

View File

@ -147,7 +147,7 @@ class MessageContent extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(Icons.phone_outlined),
Icon(Icons.phone_outlined, color: Colors.green),
SizedBox(width: 8),
Text(L10n.of(context).videoCall),
],

View File

@ -7,6 +7,7 @@ import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:emoji_picker/emoji_picker.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:file_picker_cross/file_picker_cross.dart';
import 'package:fluffychat/app_config.dart';
import 'package:fluffychat/components/avatar.dart';
import 'package:fluffychat/components/chat_settings_popup_menu.dart';
import 'package:fluffychat/components/connection_status_header.dart';
@ -33,6 +34,7 @@ import 'package:pedantic/pedantic.dart';
import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:swipe_to_action/swipe_to_action.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';
import '../components/dialogs/send_file_dialog.dart';
import '../components/input_bar.dart';
@ -89,6 +91,20 @@ class _ChatState extends State<Chat> {
bool get _canLoadMore => timeline.events.last.type != EventTypes.RoomCreate;
void startCallAction(BuildContext context) async {
final url =
'${AppConfig.jitsiInstance}${Uri.encodeComponent(Matrix.of(context).client.generateUniqueTransactionId())}';
final success = await showFutureLoadingDialog(
context: context,
future: () => room.sendEvent({
'msgtype': Matrix.callNamespace,
'body': url,
}));
if (success.error != null) return;
await launch(url);
}
void requestHistory() async {
if (_canLoadMore) {
try {
@ -554,7 +570,13 @@ class _ChatState extends State<Chat> {
onPressed: () => redactEventsAction(context),
),
]
: <Widget>[ChatSettingsPopupMenu(room, !room.isDirectChat)],
: <Widget>[
IconButton(
icon: Icon(Icons.call_outlined),
onPressed: () => startCallAction(context),
),
ChatSettingsPopupMenu(room, !room.isDirectChat),
],
),
floatingActionButton: showScrollDownButton
? Padding(