From ea0c99011f5603f26e866b112a0ed5116efa5443 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 13 Oct 2022 10:41:38 +0200 Subject: [PATCH] Updating descriptions when unknown verification status --- .../ui-strings/src/main/res/values/strings.xml | 2 ++ .../devices/v2/list/OtherSessionsController.kt | 7 +++++-- .../settings/devices/v2/list/SessionInfoView.kt | 15 +++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index c997fb5639..97db6ea627 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3250,10 +3250,12 @@ Unknown device type Verified session Unverified session + Unknown verification status Your current session is ready for secure messaging. This session is ready for secure messaging. Verify your current session for enhanced secure messaging. Verify or sign out from this session for best security and reliability. + Verify your current session to reveal this session\'s verification status. Verify Session View Details View All (%1$d) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt index b0ba8baa1a..59e7e1888e 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt @@ -53,7 +53,7 @@ class OtherSessionsController @Inject constructor( data.forEach { device -> val dateFormatKind = if (device.isInactive) DateFormatKind.TIMELINE_DAY_DIVIDER else DateFormatKind.DEFAULT_DATE_AND_TIME val formattedLastActivityDate = host.dateFormatter.format(device.deviceInfo.lastSeenTs, dateFormatKind) - val description = calculateDescription(device, formattedLastActivityDate) + val description = buildDescription(device, formattedLastActivityDate) val descriptionColor = if (device.isCurrentDevice) { host.colorProvider.getColorFromAttribute(R.attr.colorError) } else { @@ -77,7 +77,7 @@ class OtherSessionsController @Inject constructor( } } - private fun calculateDescription(device: DeviceFullInfo, formattedLastActivityDate: String): String { + private fun buildDescription(device: DeviceFullInfo, formattedLastActivityDate: String): String { return when { device.isInactive -> { stringProvider.getQuantityString( @@ -93,6 +93,9 @@ class OtherSessionsController @Inject constructor( device.isCurrentDevice -> { stringProvider.getString(R.string.device_manager_other_sessions_description_unverified_current_session) } + device.roomEncryptionTrustLevel == RoomEncryptionTrustLevel.Default -> { + stringProvider.getString(R.string.device_manager_session_last_activity, formattedLastActivityDate) + } else -> { stringProvider.getString(R.string.device_manager_other_sessions_description_unverified, formattedLastActivityDate) } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt index 6f6c5b24e2..bef3f5c9e4 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt @@ -90,10 +90,11 @@ class SessionInfoView @JvmOverloads constructor( isVerifyButtonVisible: Boolean, ) { views.sessionInfoVerificationStatusImageView.render(encryptionTrustLevel) - if (encryptionTrustLevel == RoomEncryptionTrustLevel.Trusted) { - renderCrossSigningVerified(isCurrentSession) - } else { - renderCrossSigningUnverified(isCurrentSession, isVerifyButtonVisible) + when { + encryptionTrustLevel == RoomEncryptionTrustLevel.Trusted -> renderCrossSigningVerified(isCurrentSession) + encryptionTrustLevel == RoomEncryptionTrustLevel.Default && !isCurrentSession -> renderCrossSigningUnknown() + else -> renderCrossSigningUnverified(isCurrentSession, isVerifyButtonVisible) + } if (hasLearnMoreLink) { appendLearnMoreToVerificationStatus() @@ -142,6 +143,12 @@ class SessionInfoView @JvmOverloads constructor( views.sessionInfoVerifySessionButton.isVisible = isVerifyButtonVisible } + private fun renderCrossSigningUnknown() { + views.sessionInfoVerificationStatusTextView.text = context.getString(R.string.device_manager_verification_status_unknown) + views.sessionInfoVerificationStatusDetailTextView.text = context.getString(R.string.device_manager_verification_status_detail_other_session_unknown) + views.sessionInfoVerifySessionButton.isVisible = false + } + private fun renderDeviceInfo(sessionName: String, deviceType: DeviceType, stringProvider: StringProvider) { setDeviceTypeIconUseCase.execute(deviceType, views.sessionInfoDeviceTypeImageView, stringProvider) views.sessionInfoNameTextView.text = sessionName