open room profile for admin when clicked on notification area for e2e pb

This commit is contained in:
Valere 2021-12-16 10:12:31 +01:00
parent 38fbfad8d5
commit 1fdb851845
6 changed files with 26 additions and 4 deletions

View File

@ -25,6 +25,7 @@ import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import androidx.core.text.italic
import im.vector.app.R
import im.vector.app.core.epoxy.onClick
import im.vector.app.core.error.ResourceLimitErrorFormatter
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.utils.DimensionConverter
@ -115,6 +116,9 @@ class NotificationAreaView @JvmOverloads constructor(
+resources.getString(R.string.room_unsupported_e2e_algorithm)
}
}
views.roomNotificationMessage.onClick {
delegate?.onMisconfiguredEncryptionClicked()
}
views.roomNotificationMessage.text = message
views.roomNotificationMessage.setTextColor(ThemeUtils.getColor(context, R.attr.vctr_content_secondary))
}
@ -193,5 +197,6 @@ class NotificationAreaView @JvmOverloads constructor(
*/
interface Delegate {
fun onTombstoneEventClicked()
fun onMisconfiguredEncryptionClicked()
}
}

View File

@ -42,6 +42,7 @@ sealed class RoomDetailAction : VectorViewModelAction {
object MarkAllAsRead : RoomDetailAction()
data class DownloadOrOpen(val eventId: String, val senderId: String?, val messageFileContent: MessageWithAttachmentContent) : RoomDetailAction()
object JoinAndOpenReplacementRoom : RoomDetailAction()
object OnClickMisconfiguredEncryption : RoomDetailAction()
object AcceptInvite : RoomDetailAction()
object RejectInvite : RoomDetailAction()

View File

@ -461,7 +461,8 @@ class RoomDetailFragment @Inject constructor(
is RoomDetailViewEvents.OpenRoom -> handleOpenRoom(it)
RoomDetailViewEvents.OpenInvitePeople -> navigator.openInviteUsersToRoom(requireContext(), roomDetailArgs.roomId)
RoomDetailViewEvents.OpenSetRoomAvatarDialog -> galleryOrCameraDialogHelper.show()
RoomDetailViewEvents.OpenRoomSettings -> handleOpenRoomSettings()
RoomDetailViewEvents.OpenRoomSettings -> handleOpenRoomSettings(RoomProfileActivity.EXTRA_DIRECT_ACCESS_ROOM_SETTINGS)
RoomDetailViewEvents.OpenRoomProfile -> handleOpenRoomSettings()
is RoomDetailViewEvents.ShowRoomAvatarFullScreen -> it.matrixItem?.let { item ->
navigator.openBigImageViewer(requireActivity(), it.view, item)
}
@ -585,11 +586,11 @@ class RoomDetailFragment @Inject constructor(
)
}
private fun handleOpenRoomSettings() {
private fun handleOpenRoomSettings(directAccess: Int? = null) {
navigator.openRoomProfile(
requireContext(),
roomDetailArgs.roomId,
RoomProfileActivity.EXTRA_DIRECT_ACCESS_ROOM_SETTINGS
directAccess
)
}
@ -949,6 +950,10 @@ class RoomDetailFragment @Inject constructor(
override fun onTombstoneEventClicked() {
roomDetailViewModel.handle(RoomDetailAction.JoinAndOpenReplacementRoom)
}
override fun onMisconfiguredEncryptionClicked() {
roomDetailViewModel.handle(RoomDetailAction.OnClickMisconfiguredEncryption)
}
}
}

View File

@ -48,6 +48,7 @@ sealed class RoomDetailViewEvents : VectorViewEvents {
object OpenInvitePeople : RoomDetailViewEvents()
object OpenSetRoomAvatarDialog : RoomDetailViewEvents()
object OpenRoomSettings : RoomDetailViewEvents()
object OpenRoomProfile : RoomDetailViewEvents()
data class ShowRoomAvatarFullScreen(val matrixItem: MatrixItem?, val view: View?) : RoomDetailViewEvents()
object ShowWaitingView : RoomDetailViewEvents()

View File

@ -211,11 +211,13 @@ class RoomDetailViewModel @AssistedInject constructor(
val canInvite = PowerLevelsHelper(it).isUserAbleToInvite(session.myUserId)
val isAllowedToManageWidgets = session.widgetService().hasPermissionsToHandleWidgets(room.roomId)
val isAllowedToStartWebRTCCall = PowerLevelsHelper(it).isUserAllowedToSend(session.myUserId, false, EventType.CALL_INVITE)
val isAllowedToSetupEncryption = PowerLevelsHelper(it).isUserAllowedToSend(session.myUserId, true, EventType.STATE_ROOM_ENCRYPTION)
setState {
copy(
canInvite = canInvite,
isAllowedToManageWidgets = isAllowedToManageWidgets,
isAllowedToStartWebRTCCall = isAllowedToStartWebRTCCall
isAllowedToStartWebRTCCall = isAllowedToStartWebRTCCall,
isAllowedToSetupEncryption = isAllowedToSetupEncryption
)
}
}.launchIn(viewModelScope)
@ -309,6 +311,7 @@ class RoomDetailViewModel @AssistedInject constructor(
is RoomDetailAction.DownloadOrOpen -> handleOpenOrDownloadFile(action)
is RoomDetailAction.NavigateToEvent -> handleNavigateToEvent(action)
is RoomDetailAction.JoinAndOpenReplacementRoom -> handleJoinAndOpenReplacementRoom()
is RoomDetailAction.OnClickMisconfiguredEncryption -> handleClickMisconfiguredE2E()
is RoomDetailAction.ResendMessage -> handleResendEvent(action)
is RoomDetailAction.RemoveFailedEcho -> handleRemove(action)
is RoomDetailAction.MarkAllAsRead -> handleMarkAllAsRead()
@ -614,6 +617,12 @@ class RoomDetailViewModel @AssistedInject constructor(
}
}
private fun handleClickMisconfiguredE2E() = withState { state ->
if (state.isAllowedToSetupEncryption) {
_viewEvents.post(RoomDetailViewEvents.OpenRoomProfile)
}
}
private fun isIntegrationEnabled() = session.integrationManagerService().isIntegrationEnabled()
fun isMenuItemVisible(@IdRes itemId: Int): Boolean = com.airbnb.mvrx.withState(this) { state ->

View File

@ -64,6 +64,7 @@ data class RoomDetailViewState(
val canInvite: Boolean = true,
val isAllowedToManageWidgets: Boolean = false,
val isAllowedToStartWebRTCCall: Boolean = true,
val isAllowedToSetupEncryption: Boolean = true,
val hasFailedSending: Boolean = false,
val jitsiState: JitsiState = JitsiState()
) : MavericksState {