Code review

This commit is contained in:
Valere 2021-12-16 11:55:34 +01:00
parent 1fdb851845
commit fca32da204
2 changed files with 8 additions and 5 deletions

View file

@ -74,7 +74,7 @@ class NotificationAreaView @JvmOverloads constructor(
is State.Default -> renderDefault() is State.Default -> renderDefault()
is State.Hidden -> renderHidden() is State.Hidden -> renderHidden()
is State.NoPermissionToPost -> renderNoPermissionToPost() is State.NoPermissionToPost -> renderNoPermissionToPost()
is State.UnsupportedAlgorithm -> renderUnsupportedAlgorithm() is State.UnsupportedAlgorithm -> renderUnsupportedAlgorithm(newState)
is State.Tombstone -> renderTombstone() is State.Tombstone -> renderTombstone()
is State.ResourceLimitExceededError -> renderResourceLimitExceededError(newState) is State.ResourceLimitExceededError -> renderResourceLimitExceededError(newState)
}.exhaustive }.exhaustive
@ -108,12 +108,15 @@ class NotificationAreaView @JvmOverloads constructor(
views.roomNotificationMessage.setTextColor(ThemeUtils.getColor(context, R.attr.vctr_content_secondary)) views.roomNotificationMessage.setTextColor(ThemeUtils.getColor(context, R.attr.vctr_content_secondary))
} }
private fun renderUnsupportedAlgorithm() { private fun renderUnsupportedAlgorithm(e2eState: State.UnsupportedAlgorithm) {
visibility = View.VISIBLE visibility = View.VISIBLE
views.roomNotificationIcon.setImageResource(R.drawable.ic_shield_warning_small) views.roomNotificationIcon.setImageResource(R.drawable.ic_shield_warning_small)
val text = if (e2eState.canRestore) {
R.string.room_unsupported_e2e_algorithm_as_admin
} else R.string.room_unsupported_e2e_algorithm
val message = span { val message = span {
italic { italic {
+resources.getString(R.string.room_unsupported_e2e_algorithm) +resources.getString(text)
} }
} }
views.roomNotificationMessage.onClick { views.roomNotificationMessage.onClick {
@ -180,7 +183,7 @@ class NotificationAreaView @JvmOverloads constructor(
// User can't post messages to room because his power level doesn't allow it. // User can't post messages to room because his power level doesn't allow it.
object NoPermissionToPost : State() object NoPermissionToPost : State()
object UnsupportedAlgorithm : State() data class UnsupportedAlgorithm(val canRestore: Boolean) : State()
// View will be Gone // View will be Gone
object Hidden : State() object Hidden : State()

View file

@ -1461,7 +1461,7 @@ class RoomDetailFragment @Inject constructor(
NotificationAreaView.State.NoPermissionToPost NotificationAreaView.State.NoPermissionToPost
} }
is CanSendStatus.UnSupportedE2eAlgorithm -> { is CanSendStatus.UnSupportedE2eAlgorithm -> {
NotificationAreaView.State.UnsupportedAlgorithm NotificationAreaView.State.UnsupportedAlgorithm(mainState.isAllowedToSetupEncryption)
} }
}.let { }.let {
views.notificationAreaView.render(it) views.notificationAreaView.render(it)