Merge pull request #7710 from vector-im/feature/ons/fix_unknown_shield_icon_in_room
Fix usage of unknown shield in room summary (PSG-1019)
This commit is contained in:
commit
f76a6de10d
|
@ -0,0 +1 @@
|
|||
Fix usage of unknown shield in room summary
|
|
@ -38,6 +38,25 @@ class ShieldImageView @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders device shield with the support of unknown shields instead of black shields which is used for rooms.
|
||||
* @param roomEncryptionTrustLevel trust level that is usally calculated with [im.vector.app.features.settings.devices.TrustUtils.shieldForTrust]
|
||||
* @param borderLess if true then the shield icon with border around is used
|
||||
*/
|
||||
fun renderDeviceShield(roomEncryptionTrustLevel: RoomEncryptionTrustLevel?, borderLess: Boolean = false) {
|
||||
isVisible = roomEncryptionTrustLevel != null
|
||||
|
||||
if (roomEncryptionTrustLevel == RoomEncryptionTrustLevel.Default) {
|
||||
contentDescription = context.getString(R.string.a11y_trust_level_default)
|
||||
setImageResource(
|
||||
if (borderLess) R.drawable.ic_shield_unknown_no_border
|
||||
else R.drawable.ic_shield_unknown
|
||||
)
|
||||
} else {
|
||||
render(roomEncryptionTrustLevel, borderLess)
|
||||
}
|
||||
}
|
||||
|
||||
fun render(roomEncryptionTrustLevel: RoomEncryptionTrustLevel?, borderLess: Boolean = false) {
|
||||
isVisible = roomEncryptionTrustLevel != null
|
||||
|
||||
|
@ -45,8 +64,8 @@ class ShieldImageView @JvmOverloads constructor(
|
|||
RoomEncryptionTrustLevel.Default -> {
|
||||
contentDescription = context.getString(R.string.a11y_trust_level_default)
|
||||
setImageResource(
|
||||
if (borderLess) R.drawable.ic_shield_unknown_no_border
|
||||
else R.drawable.ic_shield_unknown
|
||||
if (borderLess) R.drawable.ic_shield_black_no_border
|
||||
else R.drawable.ic_shield_black
|
||||
)
|
||||
}
|
||||
RoomEncryptionTrustLevel.Warning -> {
|
||||
|
@ -137,7 +156,7 @@ class ShieldImageView @JvmOverloads constructor(
|
|||
@DrawableRes
|
||||
fun RoomEncryptionTrustLevel.toDrawableRes(): Int {
|
||||
return when (this) {
|
||||
RoomEncryptionTrustLevel.Default -> R.drawable.ic_shield_unknown
|
||||
RoomEncryptionTrustLevel.Default -> R.drawable.ic_shield_black
|
||||
RoomEncryptionTrustLevel.Warning -> R.drawable.ic_shield_warning
|
||||
RoomEncryptionTrustLevel.Trusted -> R.drawable.ic_shield_trusted
|
||||
RoomEncryptionTrustLevel.E2EWithUnsupportedAlgorithm -> R.drawable.ic_warning_badge
|
||||
|
|
|
@ -85,9 +85,9 @@ abstract class DeviceItem : VectorEpoxyModel<DeviceItem.Holder>(R.layout.item_de
|
|||
trusted
|
||||
)
|
||||
|
||||
holder.trustIcon.render(shield)
|
||||
holder.trustIcon.renderDeviceShield(shield)
|
||||
} else {
|
||||
holder.trustIcon.render(null)
|
||||
holder.trustIcon.renderDeviceShield(null)
|
||||
}
|
||||
|
||||
val detailedModeLabels = listOf(
|
||||
|
|
|
@ -97,7 +97,7 @@ abstract class OtherSessionItem : VectorEpoxyModel<OtherSessionItem.Holder>(R.la
|
|||
} else {
|
||||
setDeviceTypeIconUseCase.execute(deviceType, holder.otherSessionDeviceTypeImageView, stringProvider)
|
||||
}
|
||||
holder.otherSessionVerificationStatusImageView.render(roomEncryptionTrustLevel)
|
||||
holder.otherSessionVerificationStatusImageView.renderDeviceShield(roomEncryptionTrustLevel)
|
||||
holder.otherSessionNameTextView.text = sessionName
|
||||
holder.otherSessionDescriptionTextView.text = sessionDescription
|
||||
sessionDescriptionColor?.let {
|
||||
|
|
|
@ -90,7 +90,7 @@ class SessionInfoView @JvmOverloads constructor(
|
|||
hasLearnMoreLink: Boolean,
|
||||
isVerifyButtonVisible: Boolean,
|
||||
) {
|
||||
views.sessionInfoVerificationStatusImageView.render(encryptionTrustLevel)
|
||||
views.sessionInfoVerificationStatusImageView.renderDeviceShield(encryptionTrustLevel)
|
||||
when {
|
||||
encryptionTrustLevel == RoomEncryptionTrustLevel.Trusted -> renderCrossSigningVerified(isCurrentSession)
|
||||
encryptionTrustLevel == RoomEncryptionTrustLevel.Default && !isCurrentSession -> renderCrossSigningUnknown()
|
||||
|
|
Loading…
Reference in New Issue