From e1a8802df4b7f21c6bac6ffb99eefa946d7c0d7c Mon Sep 17 00:00:00 2001 From: Aniket Kadam Date: Tue, 21 May 2024 12:05:20 +0530 Subject: [PATCH 01/10] Formatting changes only Signed-off-by: Aniket Kadam --- .../src/main/res/layout/layout_chat_merge.xml | 140 +++++++++--------- 1 file changed, 69 insertions(+), 71 deletions(-) diff --git a/room-kit/src/main/res/layout/layout_chat_merge.xml b/room-kit/src/main/res/layout/layout_chat_merge.xml index 47f712190..42c79bf34 100644 --- a/room-kit/src/main/res/layout/layout_chat_merge.xml +++ b/room-kit/src/main/res/layout/layout_chat_merge.xml @@ -52,11 +52,11 @@ + android:paddingHorizontal="24dp" + tools:visibility="gone"> + + android:layout_weight="1"> - + + + + + + + android:padding="@dimen/spacing_d1" + android:text="@string/blocked_from_sending_messages" + android:textSize="14sp" + android:visibility="gone" /> - - - - - - - + android:gravity="center_vertical" + android:hint="@string/send_messages_to_everyone" + android:minHeight="24dp" + android:paddingHorizontal="@dimen/spacing_d1" + android:textSize="14sp" /> - + + android:src="@drawable/hand_on" /> + android:layout_marginLeft="@dimen/twelve_dp" + android:padding="@dimen/twelve_dp" + android:src="@drawable/hls_hamburger_menu" /> From 0d1bedaa3be2c1dba2d5c389742c3793094bfd18 Mon Sep 17 00:00:00 2001 From: Aniket Kadam Date: Fri, 24 May 2024 20:06:13 +0530 Subject: [PATCH 02/10] Update versions Signed-off-by: Aniket Kadam --- app/build.gradle | 2 +- gradle.properties | 6 +++--- room-kit/build.gradle | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ad5128ac2..70266decd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -62,7 +62,7 @@ dependencies { implementation "live.100ms:room-kit:$HMS_ROOM_KIT_VERSION" //100ms noise cancellation dep - def hmsVersion = "2.9.57" + def hmsVersion = "2.9.58" implementation "live.100ms:hms-noise-cancellation-android:$hmsVersion" // Navigation diff --git a/gradle.properties b/gradle.properties index 15a0860a1..c277b5a52 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,8 +19,8 @@ android.useAndroidX=true android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official -100MS_APP_VERSION_CODE=373 -100MS_APP_VERSION_NAME=5.0.7 +100MS_APP_VERSION_CODE=374 +100MS_APP_VERSION_NAME=5.0.8 hmsRoomKitGroup=live.100ms -HMS_ROOM_KIT_VERSION=1.2.12 +HMS_ROOM_KIT_VERSION=1.2.13 android.suppressUnsupportedCompileSdk=33 diff --git a/room-kit/build.gradle b/room-kit/build.gradle index 6d4ac5ca1..52225b8cc 100644 --- a/room-kit/build.gradle +++ b/room-kit/build.gradle @@ -72,7 +72,7 @@ dependencies { implementation 'com.google.android.material:material:1.10.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.percentlayout:percentlayout:1.0.0' - def hmsVersion = "2.9.57" + def hmsVersion = "2.9.58" implementation "com.otaliastudios:zoomlayout:1.9.0" // To add dependencies of specific module implementation "live.100ms:android-sdk:$hmsVersion" From 5bd33794e5135187629c4dc539aaeec6693a0cc1 Mon Sep 17 00:00:00 2001 From: Gulzar Date: Tue, 28 May 2024 13:49:21 +0530 Subject: [PATCH 03/10] added changes --- .../ui/meeting/videogrid/ScreenShareFragement.kt | 16 ++++++++++------ .../meeting/videogrid/VideoGridPageFragment.kt | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/ScreenShareFragement.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/ScreenShareFragement.kt index 443807e60..b2ce36dd5 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/ScreenShareFragement.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/ScreenShareFragement.kt @@ -40,7 +40,7 @@ class ScreenShareFragement : BottomSheetDialogFragment() { requireActivity().application ) } - + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { @@ -129,12 +129,16 @@ class ScreenShareFragement : BottomSheetDialogFragment() { meetingViewModel.tracks.observe(viewLifecycleOwner) { meetingTrack -> Log.d(TAG,"Looking for trackId: ${arguments?.getString(SCREEN_SHARE_TRACK_ID)}") - val track = meetingTrack.find { it.video?.trackId == arguments?.getString(SCREEN_SHARE_TRACK_ID) }?.video - if (track != null) { - binding.localVideoView.addTrack(track) - } else { - dismissAllowingStateLoss() + synchronized(meetingTrack) { + val track = meetingTrack.find { it.video?.trackId == arguments?.getString(SCREEN_SHARE_TRACK_ID) }?.video + if (track != null) { + binding.localVideoView.addTrack(track) + } else { + dismissAllowingStateLoss() + } } + + } } diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridPageFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridPageFragment.kt index 8e60e6e36..c2447ae30 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridPageFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/videogrid/VideoGridPageFragment.kt @@ -108,7 +108,7 @@ class VideoGridPageFragment : VideoGridBaseFragment() { } } else { meetingViewModel.tracks.observe(viewLifecycleOwner) { track -> - synchronized(meetingViewModel._tracks) { + synchronized(track) { val screenShareTrack = track.filter { it.isScreen }.toList() renderCurrentPage(screenShareTrack, isForceUpdate = true) From 823c9b473eb9a28f80ece2599d1af1cf7ffe7ea9 Mon Sep 17 00:00:00 2001 From: Gulzar Date: Wed, 29 May 2024 12:53:06 +0530 Subject: [PATCH 04/10] Update MultipleLeaveOptionBottomSheet.kt --- .../meeting/bottomsheets/MultipleLeaveOptionBottomSheet.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/bottomsheets/MultipleLeaveOptionBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/bottomsheets/MultipleLeaveOptionBottomSheet.kt index a093effcf..b25b101f6 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/bottomsheets/MultipleLeaveOptionBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/bottomsheets/MultipleLeaveOptionBottomSheet.kt @@ -78,12 +78,7 @@ class MultipleLeaveOptionBottomSheet() : BottomSheetDialogFragment() { dismissAllowingStateLoss() } - binding.endSessionLayout.visibility = if(meetingViewModel.streamingState.value != HMSStreamingState.STARTED ) { - View.GONE - } else { - View.VISIBLE - } - } + binding.endSessionLayout.visibility = View.VISIBLE } private fun updateLayout() { if (meetingViewModel.hmsSDK.getLocalPeer()?.hmsRole?.permission?.endRoom == true) { From 959cb78c1517592a09e348e0a1ed4270701c0c03 Mon Sep 17 00:00:00 2001 From: Aniket Kadam Date: Thu, 30 May 2024 14:58:53 +0530 Subject: [PATCH 05/10] AN 1578 live transcriptions 2 0 allow runtime toggle (#719) Real time closed captions UI --- .../ui/meeting/ClosedCaptionsForEveryone.kt | 241 ++++++++++++++++++ .../hms/roomkit/ui/meeting/MeetingFragment.kt | 8 +- .../roomkit/ui/meeting/MeetingViewModel.kt | 49 +++- .../ui/meeting/SessionOptionBottomSheet.kt | 25 +- .../ui/meeting/TranscriptionUseCase.kt | 5 - .../ui/meeting/activespeaker/HlsFragment.kt | 17 +- .../roomkit/ui/meeting/compose/Variables.kt | 18 ++ .../TranscriptionNotifications.kt | 54 ++++ .../src/main/res/drawable/outline_cross.xml | 10 + .../transcription_cc_disable_success.xml | 16 ++ .../transcription_cc_enable_success.xml | 10 + .../drawable/transcription_error_triangle.xml | 16 ++ .../res/drawable/transcription_loader.xml | 10 + 13 files changed, 463 insertions(+), 16 deletions(-) create mode 100644 room-kit/src/main/java/live/hms/roomkit/ui/meeting/ClosedCaptionsForEveryone.kt create mode 100644 room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt create mode 100644 room-kit/src/main/res/drawable/outline_cross.xml create mode 100644 room-kit/src/main/res/drawable/transcription_cc_disable_success.xml create mode 100644 room-kit/src/main/res/drawable/transcription_cc_enable_success.xml create mode 100644 room-kit/src/main/res/drawable/transcription_error_triangle.xml create mode 100644 room-kit/src/main/res/drawable/transcription_loader.xml diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/ClosedCaptionsForEveryone.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/ClosedCaptionsForEveryone.kt new file mode 100644 index 000000000..6d85e7ebb --- /dev/null +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/ClosedCaptionsForEveryone.kt @@ -0,0 +1,241 @@ +package live.hms.roomkit.ui.meeting + +import android.content.DialogInterface +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.ViewCompositionStrategy +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.fragment.app.activityViewModels +import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.bottomsheet.BottomSheetDialog +import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import live.hms.roomkit.R +import live.hms.roomkit.ui.meeting.compose.Variables +import live.hms.video.sdk.models.TranscriptionState +import live.hms.video.sdk.models.TranscriptionsMode + +class ClosedCaptionsForEveryone : BottomSheetDialogFragment() { + + companion object { + val TAG = "ClosedCaptionsForEveryoneBottomFragment" + } + + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + dialog?.let { + val sheet = it as BottomSheetDialog + sheet.behavior.state = BottomSheetBehavior.STATE_EXPANDED + } + } + private val meetingViewModel: MeetingViewModel by activityViewModels { + MeetingViewModelFactory( + requireActivity().application + ) + } + + private fun getCurrentScreen() : ScreenInfo { + val transcriptionStarted = meetingViewModel.hmsSDK.getRoom()?.transcriptions?.find { it.mode == TranscriptionsMode.CAPTION && it.state == TranscriptionState.STARTED } != null + return getScreen(transcriptionStarted) + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + return ComposeView(requireContext()).apply { + // Dispose the Composition when viewLifecycleOwner is destroyed + setViewCompositionStrategy( + ViewCompositionStrategy.DisposeOnLifecycleDestroyed(viewLifecycleOwner) + ) + + setContent { + EnableCaptionsDisplay( + onEnableForEveryoneClicked = { + meetingViewModel.toggleCaptionsForEveryone(true) + dismissAllowingStateLoss() + }, + hideForMeClicked = { + meetingViewModel.toggleCaptions() + dismissAllowingStateLoss() + }, + disableForEveryoneClicked = { + meetingViewModel.toggleCaptionsForEveryone(false) + dismissAllowingStateLoss() + }, + close = { + dismissAllowingStateLoss() }, + screen = getCurrentScreen() + ) + } + } + } + + override fun getTheme(): Int { + return R.style.AppBottomSheetDialogTheme + } + + private fun getScreen(isEnabled: Boolean) : ScreenInfo = + if(isEnabled) { + ScreenInfo( + title = "Closed Captions (CC) ", + description = "This will disable Closed Captions for everyone in this room. You can enable it again.", + isEnable = false + ) + } else { + ScreenInfo( + title = "Enable Closed Captions (CC) for this session?", + description = "This will enable Closed Captions for everyone in this room. You can disable it later.", + isEnable = true + ) + } +} + +@Composable +fun EnableCaptionsDisplay(onEnableForEveryoneClicked : () -> Unit, + hideForMeClicked : () -> Unit, + disableForEveryoneClicked : () -> Unit, + close : () -> Unit, + screen : ScreenInfo) { + Column( + modifier = Modifier + .fillMaxWidth() + .wrapContentHeight() + .background( + color = Variables.SurfaceDim, + shape = RoundedCornerShape(topStart = Variables.Spacing2, topEnd = Variables.Spacing2) + ) + .padding( + start = Variables.Spacing3, + end = Variables.Spacing3, + top = Variables.Spacing3, + bottom = Variables.Spacing4 + ) + , + verticalArrangement = Arrangement.spacedBy(Variables.Spacing2, Alignment.Top), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.Start), + verticalAlignment = Alignment.Top, + ) { + + Text( + modifier = Modifier.weight(1f), + text = screen.title, style = TextStyle( + fontSize = 20.sp, + lineHeight = 24.sp, + fontFamily = FontFamily(Font(live.hms.roomkit.R.font.inter_bold)), + fontWeight = FontWeight(600), + color = Variables.OnSecondaryHigh, + letterSpacing = 0.15.sp, + ) + ) + Image( + modifier = Modifier + .padding(1.dp) + .size(24.dp) + .clickable { close() }, + painter = painterResource(id = live.hms.roomkit.R.drawable.outline_cross), + contentDescription = "Close", + contentScale = ContentScale.None + ) + } + if(screen.isEnable) { + EnableButton("Enable for Everyone", Variables.PrimaryDefault, onEnableForEveryoneClicked) + } else { + EnableButton( + text = "Hide For Me", + backgroundColor = Variables.SecondaryDefault, + onEnableClicked = hideForMeClicked) + EnableButton( + text = "Disable For Everyone", + backgroundColor = Variables.AlertErrorDefault, + onEnableClicked = disableForEveryoneClicked) + } + DescriptionText(text = screen.description) + } +} + +@Composable +fun EnableButton( + text: String, + backgroundColor: Color, + onEnableClicked: () -> Unit +) { + Row( + modifier = Modifier + .fillMaxWidth() + .height(48.dp) + .background(color = backgroundColor, shape = RoundedCornerShape(size = 8.dp)) + .padding(start = 16.dp, top = 8.dp, end = 16.dp, bottom = 8.dp), + horizontalArrangement = Arrangement.spacedBy(0.dp, Alignment.CenterHorizontally), + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + modifier = Modifier.clickable { onEnableClicked.invoke() }, + text = text, + // Desktop/Button-Semibold-16px + style = TextStyle( + fontSize = 16.sp, + lineHeight = 24.sp, + fontFamily = FontFamily(Font(live.hms.roomkit.R.font.inter_bold)), + fontWeight = FontWeight(600), + color = Variables.OnPrimaryHigh, + textAlign = TextAlign.Center, + letterSpacing = 0.5.sp, + ) + ) + } + +} +@Composable +fun DescriptionText(text : String) { + Text( + text = text, + + // Desktop/Body 2-Regular-14px + style = TextStyle( + fontSize = 14.sp, + lineHeight = 20.sp, + fontFamily = FontFamily(Font(live.hms.roomkit.R.font.inter_regular)), + fontWeight = FontWeight(400), + color = Variables.OnSurfaceMedium, + letterSpacing = 0.25.sp, + ) + ) +} + +data class ScreenInfo( + val title : String, + val description : String, + val isEnable : Boolean +) diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingFragment.kt index 38fa3ff5d..e24a2b1f8 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingFragment.kt @@ -1257,7 +1257,13 @@ class MeetingFragment : Fragment() { ) } }, - onNoiseClicked = meetingViewModel::toggleNoiseCancellation + onNoiseClicked = meetingViewModel::toggleNoiseCancellation, + openRealTimeClosedCaptions = { + ClosedCaptionsForEveryone().show( + childFragmentManager, + ClosedCaptionsForEveryone.TAG + ) + } ).show( childFragmentManager, AudioSwitchBottomSheetTAG ) diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt index e586c5295..0e2caf2c0 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt @@ -25,6 +25,7 @@ import live.hms.roomkit.ui.meeting.chat.Recipient import live.hms.roomkit.ui.meeting.participants.ParticipantPreviousRoleChangeUseCase import live.hms.roomkit.ui.notification.HMSNotification import live.hms.roomkit.ui.notification.HMSNotificationType +import live.hms.roomkit.ui.notification.TranscriptionNotifications import live.hms.roomkit.ui.polls.PollCreationInfo import live.hms.roomkit.ui.polls.QuestionUi import live.hms.roomkit.ui.settings.SettingsFragment.Companion.REAR_FACING_CAMERA @@ -1093,6 +1094,18 @@ class MeetingViewModel( Log.d(TAG, "join:onRoomUpdate type=$type, room=$hmsRoom") when (type) { + HMSRoomUpdate.TRANSCRIPTIONS_UPDATED -> { + Log.d("RealTimeTranscription", "In updated: $type ${hmsRoom.transcriptions.map { "${it.mode}/${it.state}" }}") + val started = hmsRoom.transcriptions.find { it.mode == TranscriptionsMode.CAPTION }?.state == TranscriptionState.STARTED + areCaptionsEnabledByUser.postValue(started) + when(hmsRoom.transcriptions.find { it.mode == TranscriptionsMode.CAPTION }?.state) { + TranscriptionState.STARTED -> hmsNotificationEvent.postValue(TranscriptionNotifications().transcriptionStarted()) + TranscriptionState.STOPPED -> hmsNotificationEvent.postValue(TranscriptionNotifications().transcriptionStopped()) + TranscriptionState.INITIALIZED, + TranscriptionState.FAILED, + null -> {} // no notification to send + } + } HMSRoomUpdate.ROOM_PEER_COUNT_UPDATED -> { peerCount.postValue(hmsRoom.peerCount) } @@ -2539,6 +2552,7 @@ class MeetingViewModel( fun isAllowedToHideMessages() : Boolean = prebuiltInfoContainer.isAllowedToHideMessages() + fun canToggleCaptions() = hmsSDK.getLocalPeer()?.hmsRole?.permission?.transcriptions?.find { it.mode == TranscriptionsMode.CAPTION }?.admin == true fun togglePauseChat() { val newState = chatPauseState.value!! val localPeer = hmsSDK.getLocalPeer() @@ -2632,8 +2646,7 @@ class MeetingViewModel( fun displayNoiseCancellationButton() : Boolean = hmsSDK.isNoiseCancellationAvailable() == AvailabilityStatus.Available && ( hmsSDK.getLocalPeer()?.let { !isHlsPeer(it.hmsRole) } ?: false ) fun handRaiseAvailable() = prebuiltInfoContainer.handRaiseAvailable() - fun areCaptionsAvailable() = transcriptionUseCase.receivedOneCaption || // temporary until they migrate - hmsSDK.getRoom()?.transcriptions?.find { it.state == TranscriptionState.STARTED } != null + fun areCaptionsAvailable() = hmsSDK.getLocalPeer()?.hmsRole?.permission?.transcriptions?.find { it.mode == TranscriptionsMode.CAPTION }?.read == true fun setWhiteBoardFullScreenMode(isShown : Boolean) { showWhiteBoardFullScreen.value = isShown } @@ -2681,6 +2694,38 @@ class MeetingViewModel( fun captionsEnabledByUser(): Boolean = areCaptionsEnabledByUser.value == true + fun toggleCaptionsForEveryone(enable: Boolean) { + if (enable) { + hmsNotificationEvent.postValue(TranscriptionNotifications().startingTranscriptionsForEveryone()) + hmsSDK.startRealTimeTranscription( + TranscriptionsMode.CAPTION, + object : HMSActionResultListener { + override fun onError(error: HMSException) { + hmsNotificationEvent.postValue(TranscriptionNotifications().unableToStartTranscriptions()) + } + + override fun onSuccess() { + Log.d("RealTimeTranscription","Start succeeded") + } + + }) + } else { + hmsNotificationEvent.postValue(TranscriptionNotifications().stoppingTranscriptionsForEveryone()) + hmsSDK.stopRealTimeTranscription( + TranscriptionsMode.CAPTION, + object : HMSActionResultListener { + override fun onError(error: HMSException) { + hmsNotificationEvent.postValue(TranscriptionNotifications().unableToStopTranscription()) + } + + override fun onSuccess() { + Log.d("RealTimeTranscription","Stop succeeded") + } + + }) + } + } + private var reEnableCaptions = false fun tempHideCaptions() { if(captionsEnabledByUser()) { diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt index bb8b155c4..76e81e74d 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt @@ -8,6 +8,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.activityViewModels +import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog @@ -15,12 +16,15 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.xwray.groupie.Group import com.xwray.groupie.GroupieAdapter import com.xwray.groupie.Section +import kotlinx.coroutines.launch import live.hms.roomkit.R import live.hms.roomkit.databinding.BottomSheetOptionBinding import live.hms.roomkit.ui.GridOptionItem import live.hms.roomkit.ui.theme.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.getColorOrDefault import live.hms.roomkit.util.viewLifecycle +import live.hms.video.sdk.models.TranscriptionState +import live.hms.video.sdk.models.TranscriptionsMode import live.hms.video.sdk.models.enums.HMSRecordingState import live.hms.video.whiteboard.State @@ -33,13 +37,13 @@ class SessionOptionBottomSheet( private val onNameChange: () -> Unit, private val showPolls: () -> Unit, private val disableHandRaiseDisplay : Boolean = false, - private val onNoiseClicked : (() -> Unit)? = null + private val onNoiseClicked : (() -> Unit)? = null, + private val openRealTimeClosedCaptions : () -> Unit ) : BottomSheetDialogFragment() { private var binding by viewLifecycle() val gridOptionAdapter = GroupieAdapter() - private val meetingViewModel: MeetingViewModel by activityViewModels { MeetingViewModelFactory( requireActivity().application @@ -115,11 +119,20 @@ class SessionOptionBottomSheet( }, isSelected = false ) + val captionServerStarted = meetingViewModel.hmsSDK.getRoom()?.transcriptions?.find { it.mode == TranscriptionsMode.CAPTION }?.state == TranscriptionState.STARTED val captionsButton = GridOptionItem("Show Captions", R.drawable.closed_captions_session_options, { - meetingViewModel.toggleCaptions() - dismiss() - }, isSelected = meetingViewModel.captionsEnabledByUser(), + // If you have the admin rights only + if( meetingViewModel.canToggleCaptions() && (meetingViewModel.captionsEnabledByUser() || !captionServerStarted)) { + openRealTimeClosedCaptions() + dismissAllowingStateLoss() + } else { + meetingViewModel.toggleCaptions() + dismissAllowingStateLoss() + } + + /*dismiss()*/ + }, isSelected = meetingViewModel.captionsEnabledByUser() && captionServerStarted, selectedTitle = "Hide Captions") val noiseButton = GridOptionItem("Reduce Noise", R.drawable.reduce_noise_session_option, { @@ -191,7 +204,7 @@ class SessionOptionBottomSheet( } if (meetingViewModel.isAllowedToBrowserRecord()) add(recordingOption) - if(meetingViewModel.areCaptionsAvailable()) + if(meetingViewModel.areCaptionsAvailable() && ( meetingViewModel.canToggleCaptions() || captionServerStarted)) add(captionsButton) if(!meetingViewModel.disableNameEdit()) { add(changeName) diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/TranscriptionUseCase.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/TranscriptionUseCase.kt index 6b9107869..cc9184a81 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/TranscriptionUseCase.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/TranscriptionUseCase.kt @@ -26,8 +26,6 @@ class TranscriptionUseCase( ) { private val TAG = "TranscriptionUseCase" val captions : MutableLiveData> = MutableLiveData(null) - var receivedOneCaption = false - private set private val CLEAR_AFTER_SILENCE_MILLIS = 5000L private val EXTRA_SUBTITLE_DELETION_TIME = 20_000L private var singleCancelJob : Job? = null @@ -42,9 +40,6 @@ class TranscriptionUseCase( } suspend fun newCaption(transcripts: HmsTranscripts) : Unit = editLock.withLock { - if(!receivedOneCaption) { - receivedOneCaption = true - } // Log.d(TAG,"processing started") clearAllTranscriptionAfterSilence() // update peer names into the map diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/activespeaker/HlsFragment.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/activespeaker/HlsFragment.kt index 750e00d21..6f867c41d 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/activespeaker/HlsFragment.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/activespeaker/HlsFragment.kt @@ -112,6 +112,7 @@ import live.hms.roomkit.databinding.HlsFragmentLayoutBinding import live.hms.roomkit.databinding.LayoutChatMergeBinding import live.hms.roomkit.hideKeyboard import live.hms.roomkit.setOnSingleClickListener +import live.hms.roomkit.ui.meeting.ClosedCaptionsForEveryone import live.hms.roomkit.ui.meeting.HlsVideoQualitySelectorBottomSheet import live.hms.roomkit.ui.meeting.MeetingFragment import live.hms.roomkit.ui.meeting.MeetingFragmentDirections @@ -309,7 +310,13 @@ private const val MILLI_SECONDS_FROM_LIVE = 10_000 onNameChange = { }, showPolls = { openPolls() }, onRecordingClicked = {}, - disableHandRaiseDisplay = true + disableHandRaiseDisplay = true, + openRealTimeClosedCaptions = { + ClosedCaptionsForEveryone().show( + childFragmentManager, + ClosedCaptionsForEveryone.TAG + ) + } ).show( childFragmentManager, MeetingFragment.AudioSwitchBottomSheetTAG ) @@ -1233,7 +1240,13 @@ fun ChatUI( onNameChange = { }, showPolls = { openPolls() }, onRecordingClicked = {}, - disableHandRaiseDisplay = true + disableHandRaiseDisplay = true, + openRealTimeClosedCaptions = { + ClosedCaptionsForEveryone().show( + childFragmentManager, + ClosedCaptionsForEveryone.TAG + ) + } ).show( childFragmentManager, MeetingFragment.AudioSwitchBottomSheetTAG ) diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/compose/Variables.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/compose/Variables.kt index 3cd194c70..f3bcef399 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/compose/Variables.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/compose/Variables.kt @@ -1,12 +1,15 @@ package live.hms.roomkit.ui.meeting.compose import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import live.hms.roomkit.ui.theme.HMSPrebuiltTheme import live.hms.roomkit.ui.theme.getColorOrDefault class Variables { companion object { + val Spacing3: Dp = 24.dp + val Spacing4: Dp = 32.dp val Spacing2 = 16.dp val Spacing1 = 8.dp val Spacing0 = 4.dp @@ -15,6 +18,19 @@ class Variables { HMSPrebuiltTheme.getColours()?.primaryDefault, HMSPrebuiltTheme.getDefaults().primary_default)) + val SecondaryDefault : Color = Color(getColorOrDefault( + HMSPrebuiltTheme.getColours()?.secondaryDefault, + HMSPrebuiltTheme.getDefaults().secondary_default)) + + val AlertErrorDefault : Color = Color(getColorOrDefault( + HMSPrebuiltTheme.getColours()?.alertErrorDefault, + "0xFFC74E5B")) + + val OnPrimaryHigh : Color = Color(getColorOrDefault( + HMSPrebuiltTheme.getColours()?.onPrimaryHigh, + HMSPrebuiltTheme.getDefaults().onprimary_high_emp + )) + val OnSurfaceHigh: Color = Color(getColorOrDefault( HMSPrebuiltTheme.getColours()?.onSurfaceHigh, HMSPrebuiltTheme.getDefaults().onsurface_high_emp @@ -36,5 +52,7 @@ class Variables { HMSPrebuiltTheme.getColours()?.backgroundDim, HMSPrebuiltTheme.getDefaults().background_dim )).copy(alpha = 0.64f) // backrground dim is always 64% transparent. + + val SurfaceDim: Color = Color(0xFF11131A) } } diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt b/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt new file mode 100644 index 000000000..157d857fa --- /dev/null +++ b/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt @@ -0,0 +1,54 @@ +package live.hms.roomkit.ui.notification + +import live.hms.roomkit.R + +class TranscriptionNotifications { + + fun transcriptionStarted() : HMSNotification { + val message = "Closed Captioning enabled for everyone." + return HMSNotification( + title = message, + icon = R.drawable.transcription_cc_enable_success + ) + } + + fun transcriptionStopped() : HMSNotification { + val message = "Closed Captioning disabled for everyone." + return HMSNotification( + title = message, + icon = R.drawable.transcription_cc_disable_success + ) + } + fun startingTranscriptionsForEveryone() : HMSNotification{ + val message = "Enabling Closed Captioning for everyone\n" + "By continuing to be in this meeting, you consent to being recorded." + + return HMSNotification( + title = message, + icon = R.drawable.transcription_loader + ) + } + + fun stoppingTranscriptionsForEveryone() : HMSNotification { + val message = "Disabling Closed Captioning for everyone." + return HMSNotification( + title = message, + icon = R.drawable.transcription_loader + ) + } + + fun unableToStopTranscription() : HMSNotification { + val message = "Failed to disable Closed Captions." + return HMSNotification( + title = message, + icon = R.drawable.transcription_error_triangle + ) + } + + fun unableToStartTranscriptions() : HMSNotification { + val message = "Failed to enable Closed Captions." + return HMSNotification( + title = message, + icon = R.drawable.transcription_error_triangle + ) + } +} \ No newline at end of file diff --git a/room-kit/src/main/res/drawable/outline_cross.xml b/room-kit/src/main/res/drawable/outline_cross.xml new file mode 100644 index 000000000..0dc4ae2bd --- /dev/null +++ b/room-kit/src/main/res/drawable/outline_cross.xml @@ -0,0 +1,10 @@ + + + diff --git a/room-kit/src/main/res/drawable/transcription_cc_disable_success.xml b/room-kit/src/main/res/drawable/transcription_cc_disable_success.xml new file mode 100644 index 000000000..1fa02857e --- /dev/null +++ b/room-kit/src/main/res/drawable/transcription_cc_disable_success.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/room-kit/src/main/res/drawable/transcription_cc_enable_success.xml b/room-kit/src/main/res/drawable/transcription_cc_enable_success.xml new file mode 100644 index 000000000..b54751e4c --- /dev/null +++ b/room-kit/src/main/res/drawable/transcription_cc_enable_success.xml @@ -0,0 +1,10 @@ + + + diff --git a/room-kit/src/main/res/drawable/transcription_error_triangle.xml b/room-kit/src/main/res/drawable/transcription_error_triangle.xml new file mode 100644 index 000000000..baca1737b --- /dev/null +++ b/room-kit/src/main/res/drawable/transcription_error_triangle.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/room-kit/src/main/res/drawable/transcription_loader.xml b/room-kit/src/main/res/drawable/transcription_loader.xml new file mode 100644 index 000000000..90991016d --- /dev/null +++ b/room-kit/src/main/res/drawable/transcription_loader.xml @@ -0,0 +1,10 @@ + + + From 6ceb5d5e846020a497059d08b75aa555671bbb90 Mon Sep 17 00:00:00 2001 From: Aniket Kadam Date: Thu, 30 May 2024 15:07:25 +0530 Subject: [PATCH 06/10] Update text (#722) Signed-off-by: Aniket Kadam --- .../hms/roomkit/ui/notification/TranscriptionNotifications.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt b/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt index 157d857fa..0f05d4e0f 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt @@ -20,7 +20,7 @@ class TranscriptionNotifications { ) } fun startingTranscriptionsForEveryone() : HMSNotification{ - val message = "Enabling Closed Captioning for everyone\n" + "By continuing to be in this meeting, you consent to being recorded." + val message = "Enabling Closed Captioning for everyone." return HMSNotification( title = message, From 77448a233790131c07decf3dc67cd04558b7f6a8 Mon Sep 17 00:00:00 2001 From: Aniket Kadam Date: Thu, 30 May 2024 15:58:54 +0530 Subject: [PATCH 07/10] Autoremove notifications Signed-off-by: Aniket Kadam --- .../hms/roomkit/ui/meeting/MeetingActivity.kt | 36 ++++++++++++++++--- .../ui/notification/HMSNotification.kt | 4 ++- .../TranscriptionNotifications.kt | 23 ++++++++---- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingActivity.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingActivity.kt index 56393fbbd..6c7388cd0 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingActivity.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingActivity.kt @@ -1,6 +1,5 @@ package live.hms.roomkit.ui.meeting -import android.Manifest.permission.BLUETOOTH_CONNECT import android.Manifest.permission.POST_NOTIFICATIONS import android.os.Bundle import android.view.View @@ -15,6 +14,7 @@ import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.NavHostFragment import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.DiffUtil +import kotlinx.coroutines.delay import kotlinx.coroutines.launch import live.hms.roomkit.R import live.hms.roomkit.animation.RootViewDeferringInsetsCallback @@ -34,8 +34,6 @@ import live.hms.roomkit.util.ROOM_CODE import live.hms.roomkit.util.ROOM_PREBUILT import live.hms.roomkit.util.TOKEN import live.hms.roomkit.util.init -import live.hms.video.error.HMSException -import live.hms.video.sdk.HMSActionResultListener class MeetingActivity : AppCompatActivity() { @@ -124,8 +122,14 @@ class MeetingActivity : AppCompatActivity() { .show() } - meetingViewModel.hmsNotificationEvent.observe(this) { - triggerNotification(it) + meetingViewModel.hmsNotificationEvent.observe(this) { notification -> + triggerNotification(notification) + notification.autoRemoveTypeAfterMillis?.let { + lifecycleScope.launch { + delay(it) + tryRemovingAllNotificationsOfType(notification.type) + } + } } meetingViewModel.hmsRemoveNotificationEvent.observe(this) { @@ -189,6 +193,28 @@ class MeetingActivity : AppCompatActivity() { result.dispatchUpdatesTo(hmsNotificationAdapter) } + private fun tryRemovingAllNotificationsOfType(HMSNotificationType: HMSNotificationType) { + + if (hmsNotificationAdapter.getItems().isEmpty()) { + return + } + + val old = hmsNotificationAdapter.getItems() + + val getMatchingNotfictionTypeIndexToRemove = hmsNotificationAdapter.getItems().filter { it.type == HMSNotificationType } + if (getMatchingNotfictionTypeIndexToRemove.isEmpty()) + return + + val new = mutableListOf().apply { + addAll(old) + removeAll(getMatchingNotfictionTypeIndexToRemove) + + } + val callback = HMSNotificationDiffCallBack(old, new) + val result = DiffUtil.calculateDiff(callback) + hmsNotificationAdapter.setItems(new) + result.dispatchUpdatesTo(hmsNotificationAdapter) + } private fun tryRemovingNotification(HMSNotificationType: HMSNotificationType) { if (hmsNotificationAdapter.getItems().isEmpty()) { diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/notification/HMSNotification.kt b/room-kit/src/main/java/live/hms/roomkit/ui/notification/HMSNotification.kt index 896ebca48..3678093d8 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/notification/HMSNotification.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/notification/HMSNotification.kt @@ -3,7 +3,6 @@ package live.hms.roomkit.ui.notification import androidx.annotation.DrawableRes import live.hms.roomkit.R import live.hms.video.sdk.models.HMSPeer -import org.w3c.dom.Text data class HMSNotification( val id: String = System.currentTimeMillis().toString(), @@ -13,6 +12,7 @@ data class HMSNotification( @DrawableRes val icon: Int = R.drawable.person_icon, val type: HMSNotificationType = HMSNotificationType.Default, val actionButtonText: String = "", + val autoRemoveTypeAfterMillis : Long? = null ) sealed class HMSNotificationType { @@ -23,4 +23,6 @@ sealed class HMSNotificationType { object RecordingFailedToStart : HMSNotificationType() data class BringOnStage(val handRaisePeer: HMSPeer,val onStageRole: String) : HMSNotificationType() data class OpenPollOrQuiz(val pollId: String) : HMSNotificationType() + + object RealTimeTranscription : HMSNotificationType() } \ No newline at end of file diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt b/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt index 0f05d4e0f..6887b4bcf 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/notification/TranscriptionNotifications.kt @@ -3,12 +3,15 @@ package live.hms.roomkit.ui.notification import live.hms.roomkit.R class TranscriptionNotifications { + private val removeDelay = 3000L fun transcriptionStarted() : HMSNotification { val message = "Closed Captioning enabled for everyone." return HMSNotification( title = message, - icon = R.drawable.transcription_cc_enable_success + icon = R.drawable.transcription_cc_enable_success, + autoRemoveTypeAfterMillis = removeDelay, + type = HMSNotificationType.RealTimeTranscription ) } @@ -16,7 +19,9 @@ class TranscriptionNotifications { val message = "Closed Captioning disabled for everyone." return HMSNotification( title = message, - icon = R.drawable.transcription_cc_disable_success + icon = R.drawable.transcription_cc_disable_success, + autoRemoveTypeAfterMillis = removeDelay, + type = HMSNotificationType.RealTimeTranscription ) } fun startingTranscriptionsForEveryone() : HMSNotification{ @@ -24,7 +29,8 @@ class TranscriptionNotifications { return HMSNotification( title = message, - icon = R.drawable.transcription_loader + icon = R.drawable.transcription_loader, + type = HMSNotificationType.RealTimeTranscription ) } @@ -32,7 +38,8 @@ class TranscriptionNotifications { val message = "Disabling Closed Captioning for everyone." return HMSNotification( title = message, - icon = R.drawable.transcription_loader + icon = R.drawable.transcription_loader, + type = HMSNotificationType.RealTimeTranscription ) } @@ -40,7 +47,9 @@ class TranscriptionNotifications { val message = "Failed to disable Closed Captions." return HMSNotification( title = message, - icon = R.drawable.transcription_error_triangle + icon = R.drawable.transcription_error_triangle, + autoRemoveTypeAfterMillis = removeDelay, + type = HMSNotificationType.RealTimeTranscription ) } @@ -48,7 +57,9 @@ class TranscriptionNotifications { val message = "Failed to enable Closed Captions." return HMSNotification( title = message, - icon = R.drawable.transcription_error_triangle + icon = R.drawable.transcription_error_triangle, + autoRemoveTypeAfterMillis = removeDelay, + type = HMSNotificationType.RealTimeTranscription ) } } \ No newline at end of file From cbf5beebb45672426a0e418e1d3831cce6d8fdc3 Mon Sep 17 00:00:00 2001 From: Aniket Kadam Date: Thu, 30 May 2024 19:40:53 +0530 Subject: [PATCH 08/10] Text fix (#724) Signed-off-by: Aniket Kadam --- .../live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt index 76e81e74d..45f287bb1 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/SessionOptionBottomSheet.kt @@ -120,7 +120,7 @@ class SessionOptionBottomSheet( ) val captionServerStarted = meetingViewModel.hmsSDK.getRoom()?.transcriptions?.find { it.mode == TranscriptionsMode.CAPTION }?.state == TranscriptionState.STARTED - val captionsButton = GridOptionItem("Show Captions", R.drawable.closed_captions_session_options, + val captionsButton = GridOptionItem("Closed Captions", R.drawable.closed_captions_session_options, { // If you have the admin rights only if( meetingViewModel.canToggleCaptions() && (meetingViewModel.captionsEnabledByUser() || !captionServerStarted)) { @@ -133,7 +133,7 @@ class SessionOptionBottomSheet( /*dismiss()*/ }, isSelected = meetingViewModel.captionsEnabledByUser() && captionServerStarted, - selectedTitle = "Hide Captions") + selectedTitle = "Closed Captions") val noiseButton = GridOptionItem("Reduce Noise", R.drawable.reduce_noise_session_option, { onNoiseClicked?.invoke() From 20c48f0d0da277d83029367b3d1982c70bcc0181 Mon Sep 17 00:00:00 2001 From: Aniket Kadam Date: Fri, 31 May 2024 11:26:08 +0530 Subject: [PATCH 09/10] Update states according to slack discussion. (#725) https://100ms-live.slack.com/archives/C058M9FP4S0/p1717073438928689 Signed-off-by: Aniket Kadam --- .../hms/roomkit/ui/meeting/MeetingViewModel.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt index 0e2caf2c0..ef7af6759 100644 --- a/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt +++ b/room-kit/src/main/java/live/hms/roomkit/ui/meeting/MeetingViewModel.kt @@ -91,7 +91,7 @@ class MeetingViewModel( } val transcriptionsPositionUseCase = TranscriptionsPositionUseCase(viewModelScope) val transcriptionsPosition : LiveData = transcriptionsPositionUseCase.transcriptionsPosition.distinctUntilChanged() - val areCaptionsEnabledByUser : MutableLiveData = MutableLiveData(true) + val areCaptionsEnabledByUser : MutableLiveData = MutableLiveData(false) val captions : LiveData> = transcriptionUseCase.captions val launchParticipantsFromHls = SingleLiveEvent() @@ -1095,12 +1095,13 @@ class MeetingViewModel( when (type) { HMSRoomUpdate.TRANSCRIPTIONS_UPDATED -> { - Log.d("RealTimeTranscription", "In updated: $type ${hmsRoom.transcriptions.map { "${it.mode}/${it.state}" }}") - val started = hmsRoom.transcriptions.find { it.mode == TranscriptionsMode.CAPTION }?.state == TranscriptionState.STARTED - areCaptionsEnabledByUser.postValue(started) when(hmsRoom.transcriptions.find { it.mode == TranscriptionsMode.CAPTION }?.state) { TranscriptionState.STARTED -> hmsNotificationEvent.postValue(TranscriptionNotifications().transcriptionStarted()) - TranscriptionState.STOPPED -> hmsNotificationEvent.postValue(TranscriptionNotifications().transcriptionStopped()) + TranscriptionState.STOPPED -> { + hmsNotificationEvent.postValue(TranscriptionNotifications().transcriptionStopped()) + // Captions are always stopped for everyone when turned off. + areCaptionsEnabledByUser.postValue(false) + } TranscriptionState.INITIALIZED, TranscriptionState.FAILED, null -> {} // no notification to send @@ -2705,7 +2706,8 @@ class MeetingViewModel( } override fun onSuccess() { - Log.d("RealTimeTranscription","Start succeeded") + // Always enable transcriptions for the one who started them. + areCaptionsEnabledByUser.postValue(true) } }) @@ -2719,7 +2721,7 @@ class MeetingViewModel( } override fun onSuccess() { - Log.d("RealTimeTranscription","Stop succeeded") + } }) From 06dca244d427cd9714661168b7d44330863e3c31 Mon Sep 17 00:00:00 2001 From: Aniket Kadam Date: Fri, 31 May 2024 20:18:25 +0530 Subject: [PATCH 10/10] Update sdk version Signed-off-by: Aniket Kadam --- app/build.gradle | 2 +- room-kit/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 70266decd..f1d433114 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -62,7 +62,7 @@ dependencies { implementation "live.100ms:room-kit:$HMS_ROOM_KIT_VERSION" //100ms noise cancellation dep - def hmsVersion = "2.9.58" + def hmsVersion = "2.9.59" implementation "live.100ms:hms-noise-cancellation-android:$hmsVersion" // Navigation diff --git a/room-kit/build.gradle b/room-kit/build.gradle index 52225b8cc..f5170a369 100644 --- a/room-kit/build.gradle +++ b/room-kit/build.gradle @@ -72,7 +72,7 @@ dependencies { implementation 'com.google.android.material:material:1.10.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.percentlayout:percentlayout:1.0.0' - def hmsVersion = "2.9.58" + def hmsVersion = "2.9.59" implementation "com.otaliastudios:zoomlayout:1.9.0" // To add dependencies of specific module implementation "live.100ms:android-sdk:$hmsVersion"