Skip to content

Commit

Permalink
Merge pull request #716 from 100mslive/dev
Browse files Browse the repository at this point in the history
Release :: v1.2.13
  • Loading branch information
AniketSK authored May 31, 2024
2 parents bad37dd + 06dca24 commit ac4146e
Show file tree
Hide file tree
Showing 22 changed files with 599 additions and 114 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.59"
implementation "live.100ms:hms-noise-cancellation-android:$hmsVersion"

// Navigation
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion room-kit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.59"
implementation "com.otaliastudios:zoomlayout:1.9.0"
// To add dependencies of specific module
implementation "live.100ms:android-sdk:$hmsVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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() {

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<HMSNotification>().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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,13 @@ class MeetingFragment : Fragment() {
)
}
},
onNoiseClicked = meetingViewModel::toggleNoiseCancellation
onNoiseClicked = meetingViewModel::toggleNoiseCancellation,
openRealTimeClosedCaptions = {
ClosedCaptionsForEveryone().show(
childFragmentManager,
ClosedCaptionsForEveryone.TAG
)
}
).show(
childFragmentManager, AudioSwitchBottomSheetTAG
)
Expand Down
Loading

0 comments on commit ac4146e

Please sign in to comment.