From 78bdef4e2d3f2eec67b67f93637052ee25881b3e Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 17 Nov 2021 16:37:16 +0100 Subject: [PATCH] Code review --- .../app/core/ui/views/ShieldImageView.kt | 17 +++++++++++++---- .../BottomSheetVerificationBigImageItem.kt | 19 +++---------------- .../drawable/ic_shield_black_no_border.xml | 9 +++++++++ .../drawable/ic_shield_warning_no_border.xml | 14 ++++++++++---- .../layout/item_verification_big_image.xml | 5 +---- 5 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 vector/src/main/res/drawable/ic_shield_black_no_border.xml diff --git a/vector/src/main/java/im/vector/app/core/ui/views/ShieldImageView.kt b/vector/src/main/java/im/vector/app/core/ui/views/ShieldImageView.kt index 8b127307ce..44724f7954 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/ShieldImageView.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/ShieldImageView.kt @@ -36,21 +36,30 @@ class ShieldImageView @JvmOverloads constructor( } } - fun render(roomEncryptionTrustLevel: RoomEncryptionTrustLevel?) { + fun render(roomEncryptionTrustLevel: RoomEncryptionTrustLevel?, borderLess: Boolean = false) { isVisible = roomEncryptionTrustLevel != null when (roomEncryptionTrustLevel) { RoomEncryptionTrustLevel.Default -> { contentDescription = context.getString(R.string.a11y_trust_level_default) - setImageResource(R.drawable.ic_shield_black) + setImageResource( + if (borderLess) R.drawable.ic_shield_black_no_border + else R.drawable.ic_shield_black + ) } RoomEncryptionTrustLevel.Warning -> { contentDescription = context.getString(R.string.a11y_trust_level_warning) - setImageResource(R.drawable.ic_shield_warning) + setImageResource( + if (borderLess) R.drawable.ic_shield_warning_no_border + else R.drawable.ic_shield_warning + ) } RoomEncryptionTrustLevel.Trusted -> { contentDescription = context.getString(R.string.a11y_trust_level_trusted) - setImageResource(R.drawable.ic_shield_trusted) + setImageResource( + if (borderLess) R.drawable.ic_shield_trusted_no_border + else R.drawable.ic_shield_trusted + ) } } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/epoxy/BottomSheetVerificationBigImageItem.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/epoxy/BottomSheetVerificationBigImageItem.kt index d1d323f95c..b15f857c3a 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/epoxy/BottomSheetVerificationBigImageItem.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/epoxy/BottomSheetVerificationBigImageItem.kt @@ -16,12 +16,12 @@ */ package im.vector.app.features.crypto.verification.epoxy -import android.widget.ImageView import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass import im.vector.app.R import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel +import im.vector.app.core.ui.views.ShieldImageView import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel /** @@ -35,23 +35,10 @@ abstract class BottomSheetVerificationBigImageItem : VectorEpoxyModel { - holder.image.contentDescription = holder.view.context.getString(R.string.a11y_trust_level_default) - holder.image.setImageResource(R.drawable.ic_shield_black) - } - RoomEncryptionTrustLevel.Warning -> { - holder.image.contentDescription = holder.view.context.getString(R.string.a11y_trust_level_warning) - holder.image.setImageResource(R.drawable.ic_shield_warning_no_border) - } - RoomEncryptionTrustLevel.Trusted -> { - holder.image.contentDescription = holder.view.context.getString(R.string.a11y_trust_level_trusted) - holder.image.setImageResource(R.drawable.ic_shield_trusted_no_border) - } - } + holder.image.render(roomEncryptionTrustLevel, borderLess = true) } class Holder : VectorEpoxyHolder() { - val image by bind(R.id.itemVerificationBigImage) + val image by bind(R.id.itemVerificationBigImage) } } diff --git a/vector/src/main/res/drawable/ic_shield_black_no_border.xml b/vector/src/main/res/drawable/ic_shield_black_no_border.xml new file mode 100644 index 0000000000..1e322c77c3 --- /dev/null +++ b/vector/src/main/res/drawable/ic_shield_black_no_border.xml @@ -0,0 +1,9 @@ + + + diff --git a/vector/src/main/res/drawable/ic_shield_warning_no_border.xml b/vector/src/main/res/drawable/ic_shield_warning_no_border.xml index 2266c23548..49698f273f 100644 --- a/vector/src/main/res/drawable/ic_shield_warning_no_border.xml +++ b/vector/src/main/res/drawable/ic_shield_warning_no_border.xml @@ -4,9 +4,15 @@ android:viewportWidth="24" android:viewportHeight="24"> + android:strokeWidth="1" + android:pathData="M12.0077,23.4869C12.0051,23.4875 12.0025,23.4881 12,23.4886C11.9975,23.4881 11.9949,23.4875 11.9923,23.4869C11.9204,23.4706 11.8129,23.4452 11.6749,23.4092C11.3989,23.3373 11.0015,23.2235 10.5233,23.0575C9.5654,22.725 8.2921,22.186 7.0225,21.3608C4.4897,19.7145 2,16.954 2,12.405V3.4496L12,0.521L22,3.4496V12.405C22,16.954 19.5103,19.7145 16.9775,21.3608C15.7079,22.186 14.4346,22.725 13.4767,23.0575C12.9985,23.2235 12.6011,23.3373 12.3251,23.4092C12.1871,23.4452 12.0796,23.4706 12.0077,23.4869Z" + android:fillColor="#FF4B55" + android:strokeColor="#ffffff"/> + android:pathData="M1.5,12.405V3.075L12,0L22.5,3.075V12.405C22.5,21.945 12,24 12,24C12,24 1.5,21.945 1.5,12.405Z" + android:fillColor="#FF4B55"/> + diff --git a/vector/src/main/res/layout/item_verification_big_image.xml b/vector/src/main/res/layout/item_verification_big_image.xml index 7c036d298f..8d23f342cd 100644 --- a/vector/src/main/res/layout/item_verification_big_image.xml +++ b/vector/src/main/res/layout/item_verification_big_image.xml @@ -1,8 +1,5 @@ -