Open element call widget.

This commit is contained in:
Onuray Sahin 2022-07-21 16:26:10 +03:00
parent 0d4697b7e1
commit da780ac56f
5 changed files with 19 additions and 7 deletions

View file

@ -117,4 +117,6 @@ sealed class RoomDetailAction : VectorViewModelAction {
// Live Location
object StopLiveLocationSharing : RoomDetailAction()
object OpenElementCallWidget : RoomDetailAction()
}

View file

@ -93,8 +93,7 @@ data class RoomDetailViewState(
return asyncRoomSummary.invoke()?.isDirect ?: true ||
// When there is only one member, a warning will be displayed when the user
// clicks on the menu item to start a call
asyncRoomSummary.invoke()?.joinedMembersCount == 1 ||
hasActiveElementCallWidget()
asyncRoomSummary.invoke()?.joinedMembersCount == 1
}
fun isSearchAvailable() = asyncRoomSummary()?.isEncrypted == false

View file

@ -47,6 +47,11 @@ class StartCallActionsHandler(
}
private fun handleCallRequest(isVideoCall: Boolean) = withState(timelineViewModel) { state ->
if (state.hasActiveElementCallWidget() && !isVideoCall) {
timelineViewModel.handle(RoomDetailAction.OpenElementCallWidget)
return@withState
}
val roomSummary = state.asyncRoomSummary.invoke() ?: return@withState
when (roomSummary.joinedMembersCount) {
1 -> {

View file

@ -1088,12 +1088,11 @@ class TimelineFragment @Inject constructor(
val hasCallInRoom = callManager.getCallsByRoomId(state.roomId).isNotEmpty() || state.jitsiState.hasJoined
val callButtonsEnabled = !hasCallInRoom && when (state.asyncRoomSummary.invoke()?.joinedMembersCount) {
1 -> false
2 -> state.isAllowedToStartWebRTCCall || state.hasActiveElementCallWidget()
else -> state.isAllowedToManageWidgets || state.hasActiveElementCallWidget()
}
setOf(R.id.voice_call, R.id.video_call).forEach {
menu.findItem(it).icon?.alpha = if (callButtonsEnabled) 0xFF else 0x40
2 -> state.isAllowedToStartWebRTCCall
else -> state.isAllowedToManageWidgets
}
menu.findItem(R.id.video_call).icon?.alpha = if (callButtonsEnabled) 0xFF else 0x40
menu.findItem(R.id.voice_call).icon?.alpha = if (callButtonsEnabled || state.hasActiveElementCallWidget()) 0xFF else 0x40
val matrixAppsMenuItem = menu.findItem(R.id.open_matrix_apps)
val widgetsCount = state.activeRoomWidgets.invoke()?.size ?: 0

View file

@ -467,6 +467,13 @@ class TimelineViewModel @AssistedInject constructor(
}
is RoomDetailAction.EndPoll -> handleEndPoll(action.eventId)
RoomDetailAction.StopLiveLocationSharing -> handleStopLiveLocationSharing()
RoomDetailAction.OpenElementCallWidget -> handleOpenElementCallWidget()
}
}
private fun handleOpenElementCallWidget() = withState { state ->
if (state.hasActiveElementCallWidget()) {
_viewEvents.post(RoomDetailViewEvents.OpenElementCallWidget)
}
}