diff --git a/CHANGES.md b/CHANGES.md index 86b796869e..1ec6d091a9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Features ✨: Improvements 🙌: - You can now join room through permalink and within room directory search - Add long click gesture to copy userId, user display name, room name, room topic and room alias (#1774) + - Do not propose to verify session if there is only one session (#1901) Bugfix 🐛: - Display name not shown under Settings/General (#1926) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetController.kt b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetController.kt index 5fb6e20a2f..9c7615c94b 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetController.kt @@ -66,16 +66,18 @@ class DeviceVerificationInfoBottomSheetController @Inject constructor( if (data.hasAccountCrossSigning) { // Cross Signing is enabled - handleE2EWithCrossSigning(data.isMine, data.accountCrossSigningIsTrusted, cryptoDeviceInfo, shield) + handleE2EWithCrossSigning(data, cryptoDeviceInfo, shield) } else { - handleE2EInLegacy(data.isMine, cryptoDeviceInfo, shield) + handleE2EInLegacy(data, cryptoDeviceInfo, shield) } // COMMON ACTIONS (Rename / signout) addGenericDeviceManageActions(data, cryptoDeviceInfo.deviceId) } - private fun handleE2EWithCrossSigning(isMine: Boolean, currentSessionIsTrusted: Boolean, cryptoDeviceInfo: CryptoDeviceInfo, shield: Int) { + private fun handleE2EWithCrossSigning(data: DeviceVerificationInfoBottomSheetViewState, cryptoDeviceInfo: CryptoDeviceInfo, shield: Int) { + val isMine = data.isMine + val currentSessionIsTrusted = data.accountCrossSigningIsTrusted Timber.v("handleE2EWithCrossSigning $isMine, $cryptoDeviceInfo, $shield") if (isMine) { @@ -87,8 +89,8 @@ class DeviceVerificationInfoBottomSheetController @Inject constructor( title(stringProvider.getString(R.string.encryption_information_verified)) description(stringProvider.getString(R.string.settings_active_sessions_verified_device_desc)) } - } else { - // You need to complete security + } else if (data.hasOtherSessions) { + // You need to complete security, only if there are other session(s) available genericItem { id("trust${cryptoDeviceInfo.deviceId}") style(GenericItem.STYLE.BIG_TEXT) @@ -131,7 +133,7 @@ class DeviceVerificationInfoBottomSheetController @Inject constructor( description("(${cryptoDeviceInfo.deviceId})") } - if (isMine && !currentSessionIsTrusted) { + if (isMine && !currentSessionIsTrusted && data.hasOtherSessions) { // Add complete security dividerItem { id("completeSecurityDiv") @@ -157,8 +159,9 @@ class DeviceVerificationInfoBottomSheetController @Inject constructor( } } - private fun handleE2EInLegacy(isMine: Boolean, cryptoDeviceInfo: CryptoDeviceInfo, shield: Int) { + private fun handleE2EInLegacy(data: DeviceVerificationInfoBottomSheetViewState, cryptoDeviceInfo: CryptoDeviceInfo, shield: Int) { // ==== Legacy + val isMine = data.isMine // TRUST INFO SECTION if (cryptoDeviceInfo.trustLevel?.isLocallyVerified() == true) { diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt index 5746891576..34e3c566fb 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt @@ -65,6 +65,14 @@ class DeviceVerificationInfoBottomSheetViewModel @AssistedInject constructor(@As ) } + session.rx().liveUserCryptoDevices(session.myUserId) + .map { it.size } + .execute { + copy( + hasOtherSessions = it.invoke() ?: 0 > 1 + ) + } + setState { copy(deviceInfo = Loading()) } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetViewState.kt b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetViewState.kt index ff7532fdaf..61e4aa6f4d 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetViewState.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/DeviceVerificationInfoBottomSheetViewState.kt @@ -27,5 +27,6 @@ data class DeviceVerificationInfoBottomSheetViewState( val deviceInfo: Async = Uninitialized, val hasAccountCrossSigning: Boolean = false, val accountCrossSigningIsTrusted: Boolean = false, - val isMine: Boolean = false + val isMine: Boolean = false, + val hasOtherSessions: Boolean = false ) : MvRxState