mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Open element call widget.
This commit is contained in:
parent
0d4697b7e1
commit
da780ac56f
5 changed files with 19 additions and 7 deletions
|
@ -117,4 +117,6 @@ sealed class RoomDetailAction : VectorViewModelAction {
|
|||
|
||||
// Live Location
|
||||
object StopLiveLocationSharing : RoomDetailAction()
|
||||
|
||||
object OpenElementCallWidget : RoomDetailAction()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 -> {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue