From 10cbb13c2600e41cb6dd63ca23ca7352cff36ba1 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Sun, 5 Nov 2023 00:59:07 +0800 Subject: [PATCH] desktop: screen sharing in video calls (#3310) * desktop: screen sharing * use async function * fit/fill of the video * disconnect camera button from screen share * enable video on audio call * temp * Revert "temp" This reverts commit 8f8a2f7f8820852253c1258234c51e33108424dd. * Revert "enable video on audio call" This reverts commit 120068d09afd78d65d14b1063d8f7bb9a6b04695. * different logic --------- Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --- .../simplex/common/views/chat/ChatView.kt | 47 +++++++---- .../resources/assets/www/android/call.html | 1 + .../commonMain/resources/assets/www/call.js | 77 ++++++++++++++++- .../resources/assets/www/desktop/call.html | 6 +- .../www/desktop/images/ic_screen_share.svg | 1 + .../desktop/images/ic_stop_screen_share.svg | 1 + .../resources/assets/www/desktop/ui.js | 23 ++++- .../simplex-chat-webrtc/src/android/call.html | 1 + packages/simplex-chat-webrtc/src/call.ts | 83 ++++++++++++++++++- .../simplex-chat-webrtc/src/desktop/call.html | 6 +- .../src/desktop/images/ic_screen_share.svg | 1 + .../desktop/images/ic_stop_screen_share.svg | 1 + .../simplex-chat-webrtc/src/desktop/ui.ts | 23 ++++- 13 files changed, 243 insertions(+), 28 deletions(-) create mode 100644 apps/multiplatform/common/src/commonMain/resources/assets/www/desktop/images/ic_screen_share.svg create mode 100644 apps/multiplatform/common/src/commonMain/resources/assets/www/desktop/images/ic_stop_screen_share.svg create mode 100644 packages/simplex-chat-webrtc/src/desktop/images/ic_screen_share.svg create mode 100644 packages/simplex-chat-webrtc/src/desktop/images/ic_stop_screen_share.svg diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt index e724dfd7cb..2e46a13870 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt @@ -589,18 +589,30 @@ fun ChatInfoToolbar( if (chat.chatInfo is ChatInfo.Direct && chat.chatInfo.contact.allowsFeature(ChatFeature.Calls)) { if (activeCall == null) { barButtons.add { - IconButton( - { + if (appPlatform.isAndroid) { + IconButton({ showMenu.value = false startCall(CallMediaType.Audio) - }, - enabled = chat.chatInfo.contact.ready && chat.chatInfo.contact.active - ) { - Icon( - painterResource(MR.images.ic_call_500), - stringResource(MR.strings.icon_descr_more_button), - tint = if (chat.chatInfo.contact.ready && chat.chatInfo.contact.active) MaterialTheme.colors.primary else MaterialTheme.colors.secondary - ) + }, enabled = chat.chatInfo.contact.ready && chat.chatInfo.contact.active + ) { + Icon( + painterResource(MR.images.ic_call_500), + stringResource(MR.strings.icon_descr_audio_call).capitalize(Locale.current), + tint = if (chat.chatInfo.contact.ready && chat.chatInfo.contact.active) MaterialTheme.colors.primary else MaterialTheme.colors.secondary + ) + } + } else { + IconButton({ + showMenu.value = false + startCall(CallMediaType.Video) + }, enabled = chat.chatInfo.contact.ready && chat.chatInfo.contact.active + ) { + Icon( + painterResource(MR.images.ic_videocam), + stringResource(MR.strings.icon_descr_video_call).capitalize(Locale.current), + tint = if (chat.chatInfo.contact.ready && chat.chatInfo.contact.active) MaterialTheme.colors.primary else MaterialTheme.colors.secondary + ) + } } } } else if (activeCall?.contact?.id == chat.id) { @@ -634,10 +646,17 @@ fun ChatInfoToolbar( } if (chat.chatInfo.contact.ready && chat.chatInfo.contact.active && activeCall == null) { menuItems.add { - ItemAction(stringResource(MR.strings.icon_descr_video_call).capitalize(Locale.current), painterResource(MR.images.ic_videocam), onClick = { - showMenu.value = false - startCall(CallMediaType.Video) - }) + if (appPlatform.isAndroid) { + ItemAction(stringResource(MR.strings.icon_descr_video_call).capitalize(Locale.current), painterResource(MR.images.ic_videocam), onClick = { + showMenu.value = false + startCall(CallMediaType.Video) + }) + } else { + ItemAction(stringResource(MR.strings.icon_descr_audio_call).capitalize(Locale.current), painterResource(MR.images.ic_call_500), onClick = { + showMenu.value = false + startCall(CallMediaType.Audio) + }) + } } } } else if (chat.chatInfo is ChatInfo.Group && chat.chatInfo.groupInfo.canAddMembers) { diff --git a/apps/multiplatform/common/src/commonMain/resources/assets/www/android/call.html b/apps/multiplatform/common/src/commonMain/resources/assets/www/android/call.html index 46910bfaf1..7b51a05151 100644 --- a/apps/multiplatform/common/src/commonMain/resources/assets/www/android/call.html +++ b/apps/multiplatform/common/src/commonMain/resources/assets/www/android/call.html @@ -11,6 +11,7 @@ autoplay playsinline poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAEUlEQVR42mNk+M+AARiHsiAAcCIKAYwFoQ8AAAAASUVORK5CYII=" + onclick="javascript:toggleRemoteVideoFitFill()" >
+
@@ -39,7 +43,7 @@