From cc3a165084967e1a37aa37d21c425990ca706799 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 2 Dec 2024 14:50:10 +0100 Subject: [PATCH] feat(crypto): Support new expected UTD causes UX + Ana;ytics --- .../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."