mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 14:59:29 +01:00
chore: Make webRTC opt-in
This commit is contained in:
parent
5df9dc0db8
commit
20d787ffe4
@ -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"
|
||||
}
|
||||
|
@ -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/#/';
|
||||
|
@ -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';
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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(
|
||||
|
@ -431,7 +431,11 @@ class MatrixState extends State<Matrix> 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<Matrix> 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));
|
||||
|
@ -32,9 +32,7 @@ class _SettingsSwitchListTileState extends State<SettingsSwitchListTile> {
|
||||
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(() {});
|
||||
},
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user