From f8c1ec985f962d41840c35b2ed65b5e208529c51 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 26 Mar 2020 09:48:02 +0100 Subject: [PATCH 1/6] re-prompt to verify on restart --- .../request/VerificationRequestController.kt | 9 --------- .../vector/riotx/features/home/HomeActivity.kt | 18 +++++++++++++----- vector/src/main/res/values/strings.xml | 6 +++--- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/request/VerificationRequestController.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/request/VerificationRequestController.kt index 60d0d86aeb..56c76bc2b0 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/request/VerificationRequestController.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/request/VerificationRequestController.kt @@ -74,15 +74,6 @@ class VerificationRequestController @Inject constructor( iconColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary)) listener { listener?.onClickRecoverFromPassphrase() } } - bottomSheetVerificationActionItem { - id("skip") - title(stringProvider.getString(R.string.skip)) - titleColor(colorProvider.getColor(R.color.riotx_destructive_accent)) -// subTitle(stringProvider.getString(R.string.verification_use_passphrase)) - iconRes(R.drawable.ic_arrow_right) - iconColor(colorProvider.getColor(R.color.riotx_destructive_accent)) - listener { listener?.onClickDismiss() } - } } else { val styledText = if (state.isMe) { diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt index 0fa3e5416d..b814fd9410 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt @@ -29,6 +29,7 @@ import androidx.drawerlayout.widget.DrawerLayout import androidx.lifecycle.Observer import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.session.Session +import im.vector.matrix.android.api.util.toMatrixItem import im.vector.matrix.android.internal.crypto.model.CryptoDeviceInfo import im.vector.matrix.android.internal.crypto.model.MXUsersDevicesMap import im.vector.riotx.R @@ -41,8 +42,8 @@ import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.pushers.PushersManager import im.vector.riotx.features.disclaimer.showDisclaimerDialog import im.vector.riotx.features.notifications.NotificationDrawerManager -import im.vector.riotx.features.popup.DefaultVectorAlert import im.vector.riotx.features.popup.PopupAlertManager +import im.vector.riotx.features.popup.VerificationVectorAlert import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler import im.vector.riotx.features.settings.VectorPreferences import im.vector.riotx.features.workers.signout.SignOutViewModel @@ -126,6 +127,12 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable { waiting_view.isVisible = true } }) + + // Ask again if the app is relaunched + if (!sharedActionViewModel.hasDisplayedCompleteSecurityPrompt + && activeSessionHolder.getSafeActiveSession()?.hasAlreadySynced() == true) { + promptCompleteSecurityIfNeeded() + } } private fun promptCompleteSecurityIfNeeded() { @@ -152,13 +159,14 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable { // We need to ask sharedActionViewModel.hasDisplayedCompleteSecurityPrompt = true popupAlertManager.postVectorAlert( - DefaultVectorAlert( + VerificationVectorAlert( uid = "completeSecurity", - title = getString(R.string.new_signin), - description = getString(R.string.complete_security), + title = getString(R.string.complete_security), + description = getString(R.string.crosssigning_verify_this_session), iconId = R.drawable.ic_shield_warning ).apply { - colorInt = ContextCompat.getColor(this@HomeActivity, R.color.riotx_destructive_accent) + matrixItem = session.getUser(session.myUserId)?.toMatrixItem() + colorInt = ContextCompat.getColor(this@HomeActivity, R.color.riotx_positive_accent) contentAction = Runnable { (weakCurrentActivity?.get() as? VectorBaseActivity)?.let { it.navigator.waitSessionVerification(it) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 9e07f43cb8..928aafbd55 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -2126,7 +2126,7 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming Other users may not trust it Complete Security - Open an existing session & use it to verify this one, granting it access to encrypted messages. + Use an existing session to verify this one, granting it access to encrypted messages. Verify @@ -2166,8 +2166,8 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming Selected Option Creates a simple poll - Can‘t access an existing session? - Use your recovery key or passphrase + Use a recovery method + If you can’t access an existing session New Sign In From 5bef9aef6a01cd40a287acac0a8baa4c0f071615 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 26 Mar 2020 11:44:21 +0100 Subject: [PATCH 2/6] Fix / add specific copy for other verif cancel confirm --- .../crypto/verification/cancel/VerificationCancelController.kt | 2 +- vector/src/main/res/values/strings_riotX.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationCancelController.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationCancelController.kt index 1beea4ae9f..65ed1de555 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationCancelController.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationCancelController.kt @@ -58,7 +58,7 @@ class VerificationCancelController @Inject constructor( } else { bottomSheetVerificationNoticeItem { id("notice") - notice(stringProvider.getString(R.string.verify_cancel_self_verification_from_untrusted)) + notice(stringProvider.getString(R.string.verify_cancel_other)) } } diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index de28f316fa..568513bf62 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -23,6 +23,7 @@ If you cancel, you won’t be able to read encrypted messages on this device, and other users won’t trust it If you cancel, you won’t be able to read encrypted messages on your new device, and other users won’t trust it + You can verify them later from their user profile. One of the following may be compromised:\n\n- Your password\n- Your homeserver\n- This device, or the other device\n- The internet connection either device is using\n\nWe recommend you change your password & recovery key in Settings immediately. From 42a8c561db553cc6c398a74b13710b592b0a1f9f Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 26 Mar 2020 11:44:47 +0100 Subject: [PATCH 3/6] Fix / Verification was not cancelled on back in ready state --- .../verification/VerificationBottomSheetViewModel.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt index 731f12cca4..e1edde7905 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt @@ -69,7 +69,7 @@ data class VerificationBottomSheetViewState( class VerificationBottomSheetViewModel @AssistedInject constructor( @Assisted initialState: VerificationBottomSheetViewState, - @Assisted args: VerificationBottomSheet.VerificationArgs, + @Assisted val args: VerificationBottomSheet.VerificationArgs, private val session: Session, private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider) : VectorViewModel(initialState), @@ -447,7 +447,10 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( || pr.localId == state.pendingRequest.invoke()?.localId || state.pendingRequest.invoke()?.transactionId == pr.transactionId) { setState { - copy(pendingRequest = Success(pr)) + copy( + transactionId = args.verificationId ?: pr.transactionId, + pendingRequest = Success(pr) + ) } } } From 1de57bbf3b54ef0ab25ab5e9b5673c96796cd476 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 26 Mar 2020 13:49:09 +0100 Subject: [PATCH 4/6] Fix / cancel copy when verifying other --- .../cancel/VerificationCancelController.kt | 10 +++++++++- vector/src/main/res/values/strings_riotX.xml | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationCancelController.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationCancelController.kt index 65ed1de555..49b2f7dce1 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationCancelController.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationCancelController.kt @@ -16,11 +16,13 @@ package im.vector.riotx.features.crypto.verification.cancel +import androidx.core.text.toSpannable import com.airbnb.epoxy.EpoxyController import im.vector.riotx.R import im.vector.riotx.core.epoxy.dividerItem import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.StringProvider +import im.vector.riotx.core.utils.colorizeMatchingText import im.vector.riotx.features.crypto.verification.VerificationBottomSheetViewState import im.vector.riotx.features.crypto.verification.epoxy.bottomSheetVerificationActionItem import im.vector.riotx.features.crypto.verification.epoxy.bottomSheetVerificationNoticeItem @@ -56,9 +58,15 @@ class VerificationCancelController @Inject constructor( } } } else { + val otherUserID = state.otherUserMxItem?.id ?: "" + val otherDisplayName = state.otherUserMxItem?.displayName ?: "" bottomSheetVerificationNoticeItem { id("notice") - notice(stringProvider.getString(R.string.verify_cancel_other)) + notice( + stringProvider.getString(R.string.verify_cancel_other, otherDisplayName, otherUserID) + .toSpannable() + .colorizeMatchingText(otherUserID, colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color)) + ) } } diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index 568513bf62..ccb4bfa9be 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -23,7 +23,7 @@ If you cancel, you won’t be able to read encrypted messages on this device, and other users won’t trust it If you cancel, you won’t be able to read encrypted messages on your new device, and other users won’t trust it - You can verify them later from their user profile. + You won’t verify %1$s (%2$s) if you cancel now. Start again in their user profile. One of the following may be compromised:\n\n- Your password\n- Your homeserver\n- This device, or the other device\n- The internet connection either device is using\n\nWe recommend you change your password & recovery key in Settings immediately. From acd90657c764740025ad31d137c7476482fdf1b4 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 26 Mar 2020 14:09:41 +0100 Subject: [PATCH 5/6] Fix / prevent cancel when in conclusion fragment --- .../VerificationBottomSheetViewModel.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt index e1edde7905..c37bba1469 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt @@ -142,14 +142,19 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( args: VerificationBottomSheet.VerificationArgs): VerificationBottomSheetViewModel } - fun queryCancel() = withState { - if (it.userThinkItsNotHim) { + fun queryCancel() = withState { state -> + if (state.userThinkItsNotHim) { setState { copy(userThinkItsNotHim = false) } } else { - setState { - copy(userWantsToCancel = true) + // if the verification is already done you can't cancel anymore + if (state.pendingRequest.invoke()?.cancelConclusion != null || state.sasTransactionState is VerificationTxState.TerminalTxState) { + // you cannot cancel anymore + } else { + setState { + copy(userWantsToCancel = true) + } } } } From e51439ade0226c7ecf3b4ffa1ce480bb24d64a1f Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 26 Mar 2020 14:10:19 +0100 Subject: [PATCH 6/6] updage change log --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 0cea91ed5b..da6be103b7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Features ✨: Improvements 🙌: - Verification DM / Handle concurrent .start after .ready (#794) + - Xsigning | Complete security new session design update (#1135) Bugfix 🐛: - Missing avatar/displayname after verification request message (#841)