Fix usage of unknown shield in room summary.

This commit is contained in:
Onuray Sahin 2022-12-05 18:10:22 +03:00
parent b4792c8a59
commit 516103e51b
3 changed files with 25 additions and 6 deletions

View File

@ -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

View File

@ -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(

View File

@ -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 {