diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 480fc0ee..f11796e1 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2730,5 +2730,6 @@ "voiceCall": "Voice call", "unsupportedAndroidVersion": "Unsupported Android version", "unsupportedAndroidVersionLong": "This feature required a never Android version. Please check for updates or Lineage OS support.", - "videoCallsBetaWarning": "Please note that video calls are currently in beta. They might not work as expected or work at all on all platforms." + "videoCallsBetaWarning": "Please note that video calls are currently in beta. They might not work as expected or work at all on all platforms.", + "experimentalVideoCalls": "Experimental video calls" } diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index 1786dc14..be644416 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -38,6 +38,7 @@ abstract class AppConfig { static bool hideUnknownEvents = true; static bool autoplayImages = true; static bool sendOnEnter = false; + static bool experimentalVoip = false; static const bool hideTypingUsernames = false; static const bool hideAllStateEvents = false; static const String inviteLinkPrefix = 'https://matrix.to/#/'; diff --git a/lib/config/setting_keys.dart b/lib/config/setting_keys.dart index f4d86533..0e7c0d53 100644 --- a/lib/config/setting_keys.dart +++ b/lib/config/setting_keys.dart @@ -23,4 +23,5 @@ abstract class SettingKeys { 'chat.fluffychat.dont_ask_bootstrap'; static const String autoplayImages = 'chat.fluffy.autoplay_images'; static const String sendOnEnter = 'chat.fluffy.send_on_enter'; + static const String experimentalVoip = 'chat.fluffy.experimental_voip'; } diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index bfb425a6..d2939e37 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -113,7 +113,7 @@ class ChatView extends StatelessWidget { ]; } else { return [ - if (Matrix.of(context).webrtcIsSupported && + if (Matrix.of(context).voipPlugin != null && controller.room!.isDirectChat) IconButton( onPressed: controller.onPhoneButtonTap, diff --git a/lib/pages/settings_chat/settings_chat_view.dart b/lib/pages/settings_chat/settings_chat_view.dart index cc6b4167..ec482733 100644 --- a/lib/pages/settings_chat/settings_chat_view.dart +++ b/lib/pages/settings_chat/settings_chat_view.dart @@ -7,6 +7,7 @@ import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/config/setting_keys.dart'; import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/widgets/layouts/max_width_body.dart'; +import 'package:fluffychat/widgets/matrix.dart'; import 'package:fluffychat/widgets/settings_switch_list_tile.dart'; import 'settings_chat.dart'; @@ -42,18 +43,23 @@ class SettingsChatView extends StatelessWidget { storeKey: SettingKeys.hideUnknownEvents, defaultValue: AppConfig.hideUnknownEvents, ), - SettingsSwitchListTile.adaptive( - title: L10n.of(context)!.autoplayImages, - onChanged: (b) => AppConfig.autoplayImages = b, - storeKey: SettingKeys.autoplayImages, - defaultValue: AppConfig.autoplayImages, - ), if (PlatformInfos.isMobile) SettingsSwitchListTile.adaptive( - title: L10n.of(context)!.sendOnEnter, - onChanged: (b) => AppConfig.sendOnEnter = b, - storeKey: SettingKeys.sendOnEnter, - defaultValue: AppConfig.sendOnEnter, + title: L10n.of(context)!.autoplayImages, + onChanged: (b) => AppConfig.autoplayImages = b, + storeKey: SettingKeys.autoplayImages, + defaultValue: AppConfig.autoplayImages, + ), + if (Matrix.of(context).webrtcIsSupported) + SettingsSwitchListTile.adaptive( + title: L10n.of(context)!.experimentalVideoCalls, + onChanged: (b) { + AppConfig.experimentalVoip = b; + Matrix.of(context).createVoipPlugin(); + return; + }, + storeKey: SettingKeys.experimentalVoip, + defaultValue: AppConfig.experimentalVoip, ), const Divider(height: 1), ListTile( diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index bb5a5c01..c1a5a57b 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -431,7 +431,11 @@ class MatrixState extends State with WidgetsBindingObserver { createVoipPlugin(); } - void createVoipPlugin() { + void createVoipPlugin() async { + if (await store.getItemBool(SettingKeys.experimentalVoip) == false) { + voipPlugin = null; + return; + } voipPlugin = webrtcIsSupported ? VoipPlugin(client: client, context: context) : null; } @@ -482,6 +486,9 @@ class MatrixState extends State with WidgetsBindingObserver { store .getItemBool(SettingKeys.sendOnEnter, AppConfig.sendOnEnter) .then((value) => AppConfig.sendOnEnter = value); + store + .getItemBool(SettingKeys.experimentalVoip, AppConfig.experimentalVoip) + .then((value) => AppConfig.experimentalVoip = value); store.getItem(SettingKeys.chatColor).then((value) { if (value != null && int.tryParse(value) != null) { AppConfig.chatColor = Color(int.parse(value)); diff --git a/lib/widgets/settings_switch_list_tile.dart b/lib/widgets/settings_switch_list_tile.dart index 3fc5f2b4..11e3b5ad 100644 --- a/lib/widgets/settings_switch_list_tile.dart +++ b/lib/widgets/settings_switch_list_tile.dart @@ -32,9 +32,7 @@ class _SettingsSwitchListTileState extends State { title: Text(widget.title), onChanged: (bool newValue) async { widget.onChanged?.call(newValue); - await Matrix.of(context) - .store - .setItem(widget.storeKey, newValue.toString()); + await Matrix.of(context).store.setItemBool(widget.storeKey, newValue); setState(() {}); }, ),