From 8c1b2548d1c0cc8444486cc55009c0a74cb5dd90 Mon Sep 17 00:00:00 2001 From: Mojtaba Chenani Date: Fri, 26 Apr 2024 08:56:08 +0200 Subject: [PATCH] fix(e2ei): set user display name correctly for the certificate downloaded file --- app/src/main/kotlin/com/wire/android/ui/WireActivity.kt | 2 +- .../wire/android/ui/e2eiEnrollment/E2EIEnrollmentScreen.kt | 2 +- .../android/ui/settings/devices/DeviceDetailsScreen.kt | 6 ++++-- .../devices/e2ei/E2eiCertificateDetailsScreenNavArgs.kt | 4 +++- .../devices/e2ei/E2eiCertificateDetailsViewModel.kt | 7 ++++--- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/WireActivity.kt b/app/src/main/kotlin/com/wire/android/ui/WireActivity.kt index 3d4a4bc556a..c90046edd39 100644 --- a/app/src/main/kotlin/com/wire/android/ui/WireActivity.kt +++ b/app/src/main/kotlin/com/wire/android/ui/WireActivity.kt @@ -388,7 +388,7 @@ class WireActivity : AppCompatActivity() { result = e2EIResult, updateCertificate = featureFlagNotificationViewModel::enrollE2EICertificate, snoozeDialog = featureFlagNotificationViewModel::snoozeE2EIdRequiredDialog, - openCertificateDetails = { navigate(NavigationCommand(E2eiCertificateDetailsScreenDestination(it))) }, + openCertificateDetails = { navigate(NavigationCommand(E2eiCertificateDetailsScreenDestination(it, true))) }, dismissSuccessDialog = featureFlagNotificationViewModel::dismissSuccessE2EIdDialog, isE2EILoading = isE2EILoading ) diff --git a/app/src/main/kotlin/com/wire/android/ui/e2eiEnrollment/E2EIEnrollmentScreen.kt b/app/src/main/kotlin/com/wire/android/ui/e2eiEnrollment/E2EIEnrollmentScreen.kt index cc11e227b11..b2557824f93 100644 --- a/app/src/main/kotlin/com/wire/android/ui/e2eiEnrollment/E2EIEnrollmentScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/e2eiEnrollment/E2EIEnrollmentScreen.kt @@ -89,7 +89,7 @@ fun E2EIEnrollmentScreen( enrollE2EICertificate = viewModel::enrollE2EICertificate, handleE2EIEnrollmentResult = viewModel::handleE2EIEnrollmentResult, openCertificateDetails = { - navigator.navigate(NavigationCommand(E2eiCertificateDetailsScreenDestination(state.certificate))) + navigator.navigate(NavigationCommand(E2eiCertificateDetailsScreenDestination(state.certificate, true))) }, onBackButtonClicked = viewModel::onBackButtonClicked, onCancelEnrollmentClicked = { viewModel.onCancelEnrollmentClicked(NavigationSwitchAccountActions(navigator::navigate)) }, diff --git a/app/src/main/kotlin/com/wire/android/ui/settings/devices/DeviceDetailsScreen.kt b/app/src/main/kotlin/com/wire/android/ui/settings/devices/DeviceDetailsScreen.kt index 029a283e75a..081bccdce72 100644 --- a/app/src/main/kotlin/com/wire/android/ui/settings/devices/DeviceDetailsScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/settings/devices/DeviceDetailsScreen.kt @@ -83,10 +83,10 @@ import com.wire.android.ui.theme.wireColorScheme import com.wire.android.ui.theme.wireDimensions import com.wire.android.ui.theme.wireTypography import com.wire.android.util.CustomTabsHelper +import com.wire.android.util.deviceDateTimeFormat import com.wire.android.util.dialogErrorStrings import com.wire.android.util.extension.formatAsFingerPrint import com.wire.android.util.extension.formatAsString -import com.wire.android.util.deviceDateTimeFormat import com.wire.android.util.ui.UIText import com.wire.kalium.logic.CoreFailure import com.wire.kalium.logic.data.conversation.ClientId @@ -117,7 +117,9 @@ fun DeviceDetailsScreen( handleE2EIEnrollmentResult = viewModel::handleE2EIEnrollmentResult, onNavigateToE2eiCertificateDetailsScreen = { navigator.navigate( - NavigationCommand(E2eiCertificateDetailsScreenDestination(it)) + NavigationCommand( + E2eiCertificateDetailsScreenDestination(it, viewModel.state.isSelfClient, viewModel.state.userName) + ) ) }, onEnrollE2EIErrorDismiss = viewModel::hideEnrollE2EICertificateError, diff --git a/app/src/main/kotlin/com/wire/android/ui/settings/devices/e2ei/E2eiCertificateDetailsScreenNavArgs.kt b/app/src/main/kotlin/com/wire/android/ui/settings/devices/e2ei/E2eiCertificateDetailsScreenNavArgs.kt index 340caeb21de..bc764d5e581 100644 --- a/app/src/main/kotlin/com/wire/android/ui/settings/devices/e2ei/E2eiCertificateDetailsScreenNavArgs.kt +++ b/app/src/main/kotlin/com/wire/android/ui/settings/devices/e2ei/E2eiCertificateDetailsScreenNavArgs.kt @@ -18,5 +18,7 @@ package com.wire.android.ui.settings.devices.e2ei data class E2eiCertificateDetailsScreenNavArgs( - val certificateString: String + val certificateString: String, + val isSelfUser: Boolean, + val otherUserName: String? = null ) diff --git a/app/src/main/kotlin/com/wire/android/ui/settings/devices/e2ei/E2eiCertificateDetailsViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/settings/devices/e2ei/E2eiCertificateDetailsViewModel.kt index 3d195b8b38b..61522adeb05 100644 --- a/app/src/main/kotlin/com/wire/android/ui/settings/devices/e2ei/E2eiCertificateDetailsViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/settings/devices/e2ei/E2eiCertificateDetailsViewModel.kt @@ -45,7 +45,7 @@ class E2eiCertificateDetailsViewModel @Inject constructor( private val e2eiCertificateDetailsScreenNavArgs: E2eiCertificateDetailsScreenNavArgs = savedStateHandle.navArgs() - private var selfUserHandle: String? = null + private var selfUserName: String? = null init { getSelfUserId() @@ -53,7 +53,7 @@ class E2eiCertificateDetailsViewModel @Inject constructor( private fun getSelfUserId() { viewModelScope.launch { - selfUserHandle = observerSelfUser().first().handle + selfUserName = observerSelfUser().first().name } } @@ -61,7 +61,8 @@ class E2eiCertificateDetailsViewModel @Inject constructor( fun getCertificateName(): String { val date = DateTimeUtil.currentInstant().fileDateTime() - return "wire-certificate-$selfUserHandle-$date.txt" + val userName = if(e2eiCertificateDetailsScreenNavArgs.isSelfUser) selfUserName else e2eiCertificateDetailsScreenNavArgs.otherUserName + return "wire-certificate-$userName-$date.txt" } }