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 5e9c0e7362..8b127307ce 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 @@ -18,6 +18,7 @@ package im.vector.app.core.ui.views import android.content.Context import android.util.AttributeSet +import androidx.annotation.DrawableRes import androidx.appcompat.widget.AppCompatImageView import androidx.core.view.isVisible import im.vector.app.R @@ -54,3 +55,12 @@ class ShieldImageView @JvmOverloads constructor( } } } + +@DrawableRes +fun RoomEncryptionTrustLevel.toDrawableRes(): Int { + return when (this) { + RoomEncryptionTrustLevel.Default -> R.drawable.ic_shield_black + RoomEncryptionTrustLevel.Warning -> R.drawable.ic_shield_warning + RoomEncryptionTrustLevel.Trusted -> R.drawable.ic_shield_trusted + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceItem.kt index 49840cdd64..62c0b6149f 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceItem.kt @@ -18,7 +18,6 @@ package im.vector.app.features.settings.devices import android.graphics.Typeface import android.view.ViewGroup -import android.widget.ImageView import android.widget.TextView import androidx.core.view.isVisible import com.airbnb.epoxy.EpoxyAttribute @@ -27,6 +26,7 @@ import im.vector.app.R import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel import im.vector.app.core.resources.ColorProvider +import im.vector.app.core.ui.views.ShieldImageView import im.vector.app.core.utils.DimensionConverter import me.gujun.android.span.span import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel @@ -75,17 +75,17 @@ abstract class DeviceItem : VectorEpoxyModel() { super.bind(holder) holder.root.setOnClickListener { itemClickAction?.invoke() } - val shield = TrustUtils.shieldForTrust( - currentDevice, - trustedSession, - legacyMode, - trusted - ) - if (e2eCapable) { - holder.trustIcon.setImageResource(shield) + val shield = TrustUtils.shieldForTrust( + currentDevice, + trustedSession, + legacyMode, + trusted + ) + + holder.trustIcon.render(shield) } else { - holder.trustIcon.setImageDrawable(null) + holder.trustIcon.render(null) } val detailedModeLabels = listOf( @@ -152,6 +152,6 @@ abstract class DeviceItem : VectorEpoxyModel() { val deviceLastSeenLabelText by bind(R.id.itemDeviceLastSeenLabel) val deviceLastSeenText by bind(R.id.itemDeviceLastSeen) - val trustIcon by bind(R.id.itemDeviceTrustLevelIcon) + val trustIcon by bind(R.id.itemDeviceTrustLevelIcon) } } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetController.kt b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetController.kt index 25a98bb4b5..100d4c97c5 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetController.kt @@ -24,6 +24,7 @@ import im.vector.app.core.resources.StringProvider import im.vector.app.core.ui.list.GenericItem import im.vector.app.core.ui.list.genericFooterItem import im.vector.app.core.ui.list.genericItem +import im.vector.app.core.ui.views.toDrawableRes import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo @@ -62,7 +63,7 @@ class DeviceVerificationInfoBottomSheetController @Inject constructor( trustMSK = data.accountCrossSigningIsTrusted, legacyMode = !data.hasAccountCrossSigning, deviceTrustLevel = cryptoDeviceInfo.trustLevel - ) + ).toDrawableRes() if (data.hasAccountCrossSigning) { // Cross Signing is enabled diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/TrustUtils.kt b/vector/src/main/java/im/vector/app/features/settings/devices/TrustUtils.kt index 80cd91664d..06ef96daf7 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/TrustUtils.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/TrustUtils.kt @@ -16,38 +16,50 @@ package im.vector.app.features.settings.devices -import androidx.annotation.DrawableRes -import im.vector.app.R +import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel object TrustUtils { - @DrawableRes - fun shieldForTrust(currentDevice: Boolean, trustMSK: Boolean, legacyMode: Boolean, deviceTrustLevel: DeviceTrustLevel?): Int { + fun shieldForTrust(currentDevice: Boolean, + trustMSK: Boolean, + legacyMode: Boolean, + deviceTrustLevel: DeviceTrustLevel?): RoomEncryptionTrustLevel { return when { currentDevice -> { if (legacyMode) { // In legacy, current session is always trusted - R.drawable.ic_shield_trusted + RoomEncryptionTrustLevel.Trusted } else { // If current session doesn't trust MSK, show red shield for current device - R.drawable.ic_shield_trusted.takeIf { trustMSK } ?: R.drawable.ic_shield_warning + if (trustMSK) { + RoomEncryptionTrustLevel.Trusted + } else { + RoomEncryptionTrustLevel.Warning + } } } else -> { if (legacyMode) { // use local trust - R.drawable.ic_shield_trusted.takeIf { deviceTrustLevel?.locallyVerified == true } ?: R.drawable.ic_shield_warning + if (deviceTrustLevel?.locallyVerified == true) { + RoomEncryptionTrustLevel.Trusted + } else { + RoomEncryptionTrustLevel.Warning + } } else { if (trustMSK) { // use cross sign trust, put locally trusted in black - R.drawable.ic_shield_trusted.takeIf { deviceTrustLevel?.crossSigningVerified == true } - ?: R.drawable.ic_shield_black.takeIf { deviceTrustLevel?.locallyVerified == true } - ?: R.drawable.ic_shield_warning + when { + deviceTrustLevel?.crossSigningVerified == true -> RoomEncryptionTrustLevel.Trusted + + deviceTrustLevel?.locallyVerified == true -> RoomEncryptionTrustLevel.Default + else -> RoomEncryptionTrustLevel.Warning + } } else { // The current session is untrusted, so displays others in black // as we can't know the cross-signing state - R.drawable.ic_shield_black + RoomEncryptionTrustLevel.Default } } } diff --git a/vector/src/main/res/layout/composer_layout_constraint_set_compact.xml b/vector/src/main/res/layout/composer_layout_constraint_set_compact.xml index 892bf8b8b9..7739fd3e11 100644 --- a/vector/src/main/res/layout/composer_layout_constraint_set_compact.xml +++ b/vector/src/main/res/layout/composer_layout_constraint_set_compact.xml @@ -89,6 +89,7 @@ android:layout_width="22dp" android:layout_height="22dp" android:background="?android:attr/selectableItemBackground" + android:contentDescription="@string/cancel" android:src="@drawable/ic_close_round" android:visibility="invisible" app:layout_constraintBottom_toTopOf="parent" diff --git a/vector/src/main/res/layout/composer_layout_constraint_set_expanded.xml b/vector/src/main/res/layout/composer_layout_constraint_set_expanded.xml index c453afe355..016ec15c89 100644 --- a/vector/src/main/res/layout/composer_layout_constraint_set_expanded.xml +++ b/vector/src/main/res/layout/composer_layout_constraint_set_expanded.xml @@ -95,7 +95,7 @@ android:layout_width="48dp" android:layout_height="48dp" android:background="?android:attr/selectableItemBackground" - android:contentDescription="@string/action_close" + android:contentDescription="@string/cancel" android:src="@drawable/ic_close_round" app:layout_constraintBottom_toBottomOf="@id/composerRelatedMessageContent" app:layout_constraintEnd_toEndOf="parent" diff --git a/vector/src/main/res/layout/item_bottom_sheet_room_preview.xml b/vector/src/main/res/layout/item_bottom_sheet_room_preview.xml index ce3e9bd879..de3b27d368 100644 --- a/vector/src/main/res/layout/item_bottom_sheet_room_preview.xml +++ b/vector/src/main/res/layout/item_bottom_sheet_room_preview.xml @@ -48,6 +48,7 @@ android:layout_width="48dp" android:layout_height="48dp" android:background="?attr/selectableItemBackground" + android:contentDescription="@string/room_list_quick_actions_low_priority_add" android:scaleType="centerInside" android:src="@drawable/ic_low_priority_24" app:layout_constraintBottom_toBottomOf="@+id/bottomSheetRoomPreviewAvatar" diff --git a/vector/src/main/res/layout/item_create_direct_room_user.xml b/vector/src/main/res/layout/item_create_direct_room_user.xml index 59ae13602a..041d0c59b5 100644 --- a/vector/src/main/res/layout/item_create_direct_room_user.xml +++ b/vector/src/main/res/layout/item_create_direct_room_user.xml @@ -31,6 +31,7 @@ android:id="@+id/createDirectRoomUserAvatarChecked" android:layout_width="40dp" android:layout_height="40dp" + android:contentDescription="@string/a11y_checked" android:scaleType="centerInside" android:src="@drawable/ic_material_done" android:visibility="visible" diff --git a/vector/src/main/res/layout/item_device.xml b/vector/src/main/res/layout/item_device.xml index 6d63b1c3a7..f9fd6f6088 100644 --- a/vector/src/main/res/layout/item_device.xml +++ b/vector/src/main/res/layout/item_device.xml @@ -84,7 +84,7 @@ - diff --git a/vector/src/main/res/layout/item_profile_matrix_item_progress.xml b/vector/src/main/res/layout/item_profile_matrix_item_progress.xml index 23e3edda87..1f755cf2be 100644 --- a/vector/src/main/res/layout/item_profile_matrix_item_progress.xml +++ b/vector/src/main/res/layout/item_profile_matrix_item_progress.xml @@ -26,7 +26,7 @@ app:layout_constraintTop_toTopOf="parent" tools:src="@tools:sample/avatars" /> - diff --git a/vector/src/main/res/layout/item_timeline_event_base_state.xml b/vector/src/main/res/layout/item_timeline_event_base_state.xml index 424dfef6b4..8f5985ef8e 100644 --- a/vector/src/main/res/layout/item_timeline_event_base_state.xml +++ b/vector/src/main/res/layout/item_timeline_event_base_state.xml @@ -50,14 +50,14 @@ android:id="@+id/messageVerificationRequestStub" style="@style/TimelineContentStubBaseParams" android:layout="@layout/item_timeline_event_verification_stub" - tools:layout_marginTop= "250dp" + tools:layout_marginTop="250dp" tools:visibility="visible" /> diff --git a/vector/src/main/res/layout/item_timeline_event_media_message_stub.xml b/vector/src/main/res/layout/item_timeline_event_media_message_stub.xml index 42bae56238..715b115c82 100644 --- a/vector/src/main/res/layout/item_timeline_event_media_message_stub.xml +++ b/vector/src/main/res/layout/item_timeline_event_media_message_stub.xml @@ -23,6 +23,7 @@ android:layout_width="14dp" android:layout_height="14dp" android:layout_marginStart="2dp" + android:contentDescription="@string/a11y_error_message_not_sent" android:src="@drawable/ic_warning_badge" android:visibility="gone" app:layout_constraintStart_toEndOf="@id/messageThumbnailView" diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index fee926882c..82d2efdaf8 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -2845,4 +2845,6 @@ Trusted trust level Open Emoji picker Close Emoji picker + Checked + Message not sent due to error