From 8f7b18239d7dcd830ffc8b9bf21ce2251e72efdc Mon Sep 17 00:00:00 2001 From: Valere Date: Sat, 1 Feb 2020 14:35:18 +0100 Subject: [PATCH] Warn on verify when private keys not known --- .../RoomMemberProfileAction.kt | 2 +- .../RoomMemberProfileFragment.kt | 20 ++++++++++++++++--- .../RoomMemberProfileViewModel.kt | 7 ++++++- vector/src/main/res/values/strings_riotX.xml | 2 ++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileAction.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileAction.kt index 9122b180e8..5b890d1ef6 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileAction.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileAction.kt @@ -23,5 +23,5 @@ sealed class RoomMemberProfileAction : VectorViewModelAction { object RetryFetchingInfo: RoomMemberProfileAction() object IgnoreUser: RoomMemberProfileAction() - data class VerifyUser(val userId: String? = null, val roomId: String? = null): RoomMemberProfileAction() + data class VerifyUser(val userId: String? = null, val roomId: String? = null, val canCrossSign: Boolean? = true): RoomMemberProfileAction() } diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt index cce105619a..e9ecbf78e3 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt @@ -20,6 +20,7 @@ package im.vector.riotx.features.roommemberprofile import android.os.Bundle import android.os.Parcelable import android.view.View +import androidx.appcompat.app.AlertDialog import androidx.core.view.isVisible import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Incomplete @@ -100,9 +101,22 @@ class RoomMemberProfileFragment @Inject constructor( is Success -> { when (val action = async.invoke()) { is RoomMemberProfileAction.VerifyUser -> { - VerificationBottomSheet - .withArgs(roomId = null, otherUserId = action.userId!!) - .show(parentFragmentManager, "VERIF") + if (action.canCrossSign == true) { + VerificationBottomSheet + .withArgs(roomId = null, otherUserId = action.userId!!) + .show(parentFragmentManager, "VERIF") + } else { + AlertDialog.Builder(requireContext()) + .setTitle(R.string.dialog_title_warning) + .setMessage(R.string.verify_cannot_cross_sign) + .setPositiveButton(R.string.verification_profile_verify) { _, _ -> + VerificationBottomSheet + .withArgs(roomId = null, otherUserId = action.userId!!) + .show(parentFragmentManager, "VERIF") + } + .setNegativeButton(R.string.cancel, null) + .show() + } } } } diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt index 1820262b49..bbccab3913 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt @@ -149,7 +149,12 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v if (!state.isMine && state.userMXCrossSigningInfo?.isTrusted() == false) { // ok, let's find or create the DM room _actionResultLiveData.postValue( - LiveEvent(Success(action.copy(userId = state.userId))) + LiveEvent(Success( + action.copy( + userId = state.userId, + canCrossSign = session.getCrossSigningService().canCrossSign() + ) + )) ) } } diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index bf6bcf40d3..d093f2b4d5 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -91,6 +91,8 @@ Unignore + This session is unable to share this verification with your other sessions.\nThe verification will be saved locally and shared in a future version of the app. + Recent rooms Other rooms