From 149cb1491683331ac174b963943896bd642d8baf Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 2 Dec 2024 14:50:10 +0100 Subject: [PATCH 1/5] feat(crypto): Support new expected UTD causes UX + Analytics --- .../event/TimelineItemEncryptedView.kt | 9 +++++++++ .../TimelineItemEncryptedContentProvider.kt | 18 ++++++++++++++++++ .../api/timeline/item/event/UtdCause.kt | 19 ++++++++++++++++++- .../matrix/impl/analytics/UtdTracker.kt | 3 +++ .../item/event/TimelineEventContentMapper.kt | 3 +++ .../src/main/res/values/localazy.xml | 3 +++ 6 files changed, 54 insertions(+), 1 deletion(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEncryptedView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEncryptedView.kt index e84f7ccbc2..b91b4ccc17 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEncryptedView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEncryptedView.kt @@ -40,6 +40,15 @@ fun TimelineItemEncryptedView( UtdCause.UnknownDevice -> { CommonStrings.common_unable_to_decrypt_insecure_device to CompoundDrawables.ic_compound_block } + UtdCause.HistoricalMessage -> { + CommonStrings.timeline_decryption_failure_historical_event_no_key_backup to CompoundDrawables.ic_compound_block + } + UtdCause.WithheldUnverifiedOrInsecureDevice -> { + CommonStrings.timeline_decryption_failure_withheld_unverified to CompoundDrawables.ic_compound_block + } + UtdCause.WithheldBySender -> { + CommonStrings.timeline_decryption_failure_unable_to_decrypt to CompoundDrawables.ic_compound_error + } else -> { CommonStrings.common_waiting_for_decryption_key to CompoundDrawables.ic_compound_time } diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemEncryptedContentProvider.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemEncryptedContentProvider.kt index 7aa44e03f0..b312024ebb 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemEncryptedContentProvider.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemEncryptedContentProvider.kt @@ -33,6 +33,24 @@ open class TimelineItemEncryptedContentProvider : PreviewParameterProvider { Error.Name.ExpectedSentByInsecureDevice } + UtdCause.HISTORICAL_MESSAGE -> Error.Name.HistoricalMessage + UtdCause.WITHHELD_FOR_UNVERIFIED_OR_INSECURE_DEVICE -> Error.Name.RoomKeysWithheldForUnverifiedDevice + UtdCause.WITHHELD_BY_SENDER -> Error.Name.OlmKeysNotSentError } val event = Error( context = null, diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/TimelineEventContentMapper.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/TimelineEventContentMapper.kt index f85dc5acc1..6e079ffe3f 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/TimelineEventContentMapper.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/TimelineEventContentMapper.kt @@ -145,6 +145,9 @@ private fun RustUtdCause.map(): UtdCause { RustUtdCause.VERIFICATION_VIOLATION -> UtdCause.VerificationViolation RustUtdCause.UNSIGNED_DEVICE -> UtdCause.UnsignedDevice RustUtdCause.UNKNOWN_DEVICE -> UtdCause.UnknownDevice + RustUtdCause.HISTORICAL_MESSAGE -> UtdCause.HistoricalMessage + RustUtdCause.WITHHELD_FOR_UNVERIFIED_OR_INSECURE_DEVICE -> UtdCause.WithheldUnverifiedOrInsecureDevice + RustUtdCause.WITHHELD_BY_SENDER -> UtdCause.WithheldBySender } } diff --git a/libraries/ui-strings/src/main/res/values/localazy.xml b/libraries/ui-strings/src/main/res/values/localazy.xml index 9d6e87db99..02c85887ae 100644 --- a/libraries/ui-strings/src/main/res/values/localazy.xml +++ b/libraries/ui-strings/src/main/res/values/localazy.xml @@ -365,4 +365,7 @@ Reason: %1$s." "Version: %1$s (%2$s)" "en" "en" + "Historical messages are not available on this device" + "Unable to decrypt message" + "This message was blocked either because your device is unverified or because the sender needs to verify your identity." From 3eec5eba941fa13bd2d470fd8ff5fc0c260eb6c7 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 3 Dec 2024 11:20:55 +0100 Subject: [PATCH 2/5] Update withheld unverified string --- libraries/ui-strings/src/main/res/values/localazy.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ui-strings/src/main/res/values/localazy.xml b/libraries/ui-strings/src/main/res/values/localazy.xml index 02c85887ae..8f4aa8b20c 100644 --- a/libraries/ui-strings/src/main/res/values/localazy.xml +++ b/libraries/ui-strings/src/main/res/values/localazy.xml @@ -367,5 +367,5 @@ Reason: %1$s." "en" "Historical messages are not available on this device" "Unable to decrypt message" - "This message was blocked either because your device is unverified or because the sender needs to verify your identity." + "This message was blocked either because you did not verify your device or because the sender needs to verify your identity." From 5486a08b1866bc96d5e2e466548d6616c52283ab Mon Sep 17 00:00:00 2001 From: ElementBot Date: Tue, 3 Dec 2024 13:41:36 +0000 Subject: [PATCH 3/5] Update screenshots --- ...ne.components.event_TimelineItemEncryptedView_Day_4_en.png | 4 ++-- ...ne.components.event_TimelineItemEncryptedView_Day_5_en.png | 3 +++ ...ne.components.event_TimelineItemEncryptedView_Day_6_en.png | 3 +++ ...ne.components.event_TimelineItemEncryptedView_Day_7_en.png | 3 +++ ....components.event_TimelineItemEncryptedView_Night_4_en.png | 4 ++-- ....components.event_TimelineItemEncryptedView_Night_5_en.png | 3 +++ ....components.event_TimelineItemEncryptedView_Night_6_en.png | 3 +++ ....components.event_TimelineItemEncryptedView_Night_7_en.png | 3 +++ 8 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png create mode 100644 tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_6_en.png create mode 100644 tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_7_en.png create mode 100644 tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png create mode 100644 tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_6_en.png create mode 100644 tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_7_en.png diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_4_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_4_en.png index afa1dd9b61..ffb879e770 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_4_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_4_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fee2af8462597d58274b7168c5cfe1f6d6b0909b048adc0f4fc5b3c12a90b859 -size 8861 +oid sha256:397d76d3fe47c61d112b09355097f103ef3ab38caaa99d838d44498a85969289 +size 12419 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png new file mode 100644 index 0000000000..ee6bed15eb --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21dcb76e1f9712325c1d47603e121849298aba995d493380ccc3a174296f0dd5 +size 23794 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_6_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_6_en.png new file mode 100644 index 0000000000..cff8f7e35f --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_6_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5c8494ebb4ceaf3a31b661aec47f8a33afeb7aab1457483b7009099a6b56f86 +size 8960 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_7_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_7_en.png new file mode 100644 index 0000000000..afa1dd9b61 --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_7_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fee2af8462597d58274b7168c5cfe1f6d6b0909b048adc0f4fc5b3c12a90b859 +size 8861 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_4_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_4_en.png index 212726df37..3809d0c0d5 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_4_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_4_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d4f48cd7dc7e2bbf7363d1127e46721c25bb8dd887927dbcffe525f5bb5bae01 -size 8781 +oid sha256:252efa710f80f4ea57c909cfd5cfee2beef982a209367138f10972dd5aa49db2 +size 12264 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png new file mode 100644 index 0000000000..78b8059fe5 --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12ba26807e062ad5146847438ad82b9c24805c3edbc3c949f5ba3ac20c768af0 +size 23430 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_6_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_6_en.png new file mode 100644 index 0000000000..a851ce84e5 --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_6_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dda55a19381d9f51a270afa644894f909d8c479be0a5e57b977393c9f1253683 +size 8960 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_7_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_7_en.png new file mode 100644 index 0000000000..212726df37 --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_7_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4f48cd7dc7e2bbf7363d1127e46721c25bb8dd887927dbcffe525f5bb5bae01 +size 8781 From 255c880b34cbc29bcdce55bb8a3dfbfac38659f7 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 3 Dec 2024 15:55:31 +0100 Subject: [PATCH 4/5] fix(ui) : update timeline informative view --- .../event/TimelineItemInformativeView.kt | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemInformativeView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemInformativeView.kt index 58f2f25712..304527e806 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemInformativeView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemInformativeView.kt @@ -8,8 +8,10 @@ package io.element.android.features.messages.impl.timeline.components.event import androidx.annotation.DrawableRes +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.material3.MaterialTheme @@ -44,14 +46,18 @@ fun TimelineItemInformativeView( ) ) }, - verticalAlignment = Alignment.CenterVertically, ) { - Icon( - resourceId = iconResourceId, - tint = MaterialTheme.colorScheme.secondary, - contentDescription = iconDescription, - modifier = Modifier.size(16.dp) - ) + Box( + contentAlignment = Alignment.Center, + modifier = Modifier.height(20.dp) + ) { + Icon( + resourceId = iconResourceId, + tint = MaterialTheme.colorScheme.secondary, + contentDescription = iconDescription, + modifier = Modifier.size(16.dp) + ) + } Spacer(modifier = Modifier.width(4.dp)) Text( fontStyle = FontStyle.Italic, From ae0b4e2bf12687a18b8d7112df0d87fca83e28f3 Mon Sep 17 00:00:00 2001 From: ElementBot Date: Tue, 3 Dec 2024 15:07:54 +0000 Subject: [PATCH 5/5] Update screenshots --- ...ne.components.event_TimelineItemEncryptedView_Day_5_en.png | 4 ++-- ....components.event_TimelineItemEncryptedView_Night_5_en.png | 4 ++-- ...l.timeline.components_TimelineItemEventRowUtd_Day_0_en.png | 4 ++-- ...timeline.components_TimelineItemEventRowUtd_Night_0_en.png | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png index ee6bed15eb..8f51f4d170 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Day_5_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:21dcb76e1f9712325c1d47603e121849298aba995d493380ccc3a174296f0dd5 -size 23794 +oid sha256:aba63b0f223f8480d40e6c9c48ce44a1ae1a8bdcc3d101030b9a0bd5f1e9ebee +size 23773 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png index 78b8059fe5..8561e18151 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components.event_TimelineItemEncryptedView_Night_5_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:12ba26807e062ad5146847438ad82b9c24805c3edbc3c949f5ba3ac20c768af0 -size 23430 +oid sha256:5d0a687a259fafe830560b762a915e478d680dd7c34a295d72e82fc7c427a815 +size 23403 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components_TimelineItemEventRowUtd_Day_0_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components_TimelineItemEventRowUtd_Day_0_en.png index 7877602031..e847cd3292 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components_TimelineItemEventRowUtd_Day_0_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components_TimelineItemEventRowUtd_Day_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b1f04171ef894f299b58cc15158daf9655cc04f9ab2418973e7e6e78e22884e8 -size 31693 +oid sha256:f1c226a36c42d4aa725a941ed58036dc5e75c9547720e00b75c64c7fe33491af +size 31647 diff --git a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components_TimelineItemEventRowUtd_Night_0_en.png b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components_TimelineItemEventRowUtd_Night_0_en.png index 57f18ac15c..562bcf09f2 100644 --- a/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components_TimelineItemEventRowUtd_Night_0_en.png +++ b/tests/uitests/src/test/snapshots/images/features.messages.impl.timeline.components_TimelineItemEventRowUtd_Night_0_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ce15bbbb3bc562f92a7d07a0f2f907d4e351e0b7133a61b7ef49540ef622c15 -size 30613 +oid sha256:47afdecd896bef06623b81ca53e0b60a0deeb01014903906fbd3fbf15ea4a5f6 +size 30592