Visually disable call buttons/prohibit calling on insufficient permissions
Signed-off-by: Marinus Enzinger <marinus@enzingerm.de>
This commit is contained in:
parent
6486b9e5cd
commit
84df86df37
@ -6,6 +6,7 @@ Features ✨:
|
|||||||
|
|
||||||
Improvements 🙌:
|
Improvements 🙌:
|
||||||
- Add "show password" in import Megolm keys dialog
|
- Add "show password" in import Megolm keys dialog
|
||||||
|
- Visually disable call buttons in menu and prohibit calling when permissions are insufficient (#2112)
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- Long message cannot be sent/takes infinite time & blocks other messages #1397
|
- Long message cannot be sent/takes infinite time & blocks other messages #1397
|
||||||
|
@ -610,6 +610,16 @@ class RoomDetailFragment @Inject constructor(
|
|||||||
it.isVisible = roomDetailViewModel.isMenuItemVisible(it.itemId)
|
it.isVisible = roomDetailViewModel.isMenuItemVisible(it.itemId)
|
||||||
}
|
}
|
||||||
withState(roomDetailViewModel) { state ->
|
withState(roomDetailViewModel) { state ->
|
||||||
|
// Set the visual state of the call buttons (voice/video) to enabled/disabled according to user permissions
|
||||||
|
val callButtonsEnabled = when (state.asyncRoomSummary.invoke()?.joinedMembersCount) {
|
||||||
|
1 -> false
|
||||||
|
2 -> state.isAllowedToStartWebRTCCall
|
||||||
|
else -> state.isAllowedToManageWidgets
|
||||||
|
}
|
||||||
|
setOf(R.id.voice_call, R.id.video_call).forEach {
|
||||||
|
menu.findItem(it).icon?.alpha = if (callButtonsEnabled) 0xFF else 0x40
|
||||||
|
}
|
||||||
|
|
||||||
val matrixAppsMenuItem = menu.findItem(R.id.open_matrix_apps)
|
val matrixAppsMenuItem = menu.findItem(R.id.open_matrix_apps)
|
||||||
val widgetsCount = state.activeRoomWidgets.invoke()?.size ?: 0
|
val widgetsCount = state.activeRoomWidgets.invoke()?.size ?: 0
|
||||||
if (widgetsCount > 0) {
|
if (widgetsCount > 0) {
|
||||||
@ -687,6 +697,8 @@ class RoomDetailFragment @Inject constructor(
|
|||||||
// webRtcPeerConnectionManager.endCall()
|
// webRtcPeerConnectionManager.endCall()
|
||||||
// safeStartCall(it, isVideoCall)
|
// safeStartCall(it, isVideoCall)
|
||||||
// }
|
// }
|
||||||
|
} else if (!state.isAllowedToStartWebRTCCall) {
|
||||||
|
showDialogWithMessage(getString(R.string.no_permissions_to_start_webrtc_call))
|
||||||
} else {
|
} else {
|
||||||
safeStartCall(isVideoCall)
|
safeStartCall(isVideoCall)
|
||||||
}
|
}
|
||||||
|
@ -181,10 +181,12 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||||||
.subscribe {
|
.subscribe {
|
||||||
val canSendMessage = PowerLevelsHelper(it).isUserAllowedToSend(session.myUserId, false, EventType.MESSAGE)
|
val canSendMessage = PowerLevelsHelper(it).isUserAllowedToSend(session.myUserId, false, EventType.MESSAGE)
|
||||||
val isAllowedToManageWidgets = session.widgetService().hasPermissionsToHandleWidgets(room.roomId)
|
val isAllowedToManageWidgets = session.widgetService().hasPermissionsToHandleWidgets(room.roomId)
|
||||||
|
val isAllowedToStartWebRTCCall = PowerLevelsHelper(it).isUserAllowedToSend(session.myUserId, false, EventType.CALL_INVITE)
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
canSendMessage = canSendMessage,
|
canSendMessage = canSendMessage,
|
||||||
isAllowedToManageWidgets = isAllowedToManageWidgets
|
isAllowedToManageWidgets = isAllowedToManageWidgets,
|
||||||
|
isAllowedToStartWebRTCCall = isAllowedToStartWebRTCCall
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,8 @@ data class RoomDetailViewState(
|
|||||||
val canShowJumpToReadMarker: Boolean = true,
|
val canShowJumpToReadMarker: Boolean = true,
|
||||||
val changeMembershipState: ChangeMembershipState = ChangeMembershipState.Unknown,
|
val changeMembershipState: ChangeMembershipState = ChangeMembershipState.Unknown,
|
||||||
val canSendMessage: Boolean = true,
|
val canSendMessage: Boolean = true,
|
||||||
val isAllowedToManageWidgets: Boolean = false
|
val isAllowedToManageWidgets: Boolean = false,
|
||||||
|
val isAllowedToStartWebRTCCall: Boolean = true
|
||||||
) : MvRxState {
|
) : MvRxState {
|
||||||
|
|
||||||
constructor(args: RoomDetailArgs) : this(
|
constructor(args: RoomDetailArgs) : this(
|
||||||
|
@ -89,6 +89,7 @@
|
|||||||
<string name="missing_permissions_error">"Due to missing permissions, this action is not possible.</string>
|
<string name="missing_permissions_error">"Due to missing permissions, this action is not possible.</string>
|
||||||
<string name="missing_permissions_to_start_conf_call">You need permission to invite to start a conference in this room</string>
|
<string name="missing_permissions_to_start_conf_call">You need permission to invite to start a conference in this room</string>
|
||||||
<string name="no_permissions_to_start_conf_call">You do not have permission to start a conference call in this room</string>
|
<string name="no_permissions_to_start_conf_call">You do not have permission to start a conference call in this room</string>
|
||||||
|
<string name="no_permissions_to_start_webrtc_call">You do not have permission to start a call in this room</string>
|
||||||
<string name="conference_call_in_progress">A conference is already in progress!</string>
|
<string name="conference_call_in_progress">A conference is already in progress!</string>
|
||||||
<string name="video_meeting">Start video meeting</string>
|
<string name="video_meeting">Start video meeting</string>
|
||||||
<string name="audio_meeting">Start audio meeting</string>
|
<string name="audio_meeting">Start audio meeting</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user