Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8458.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove UI option to manually verify a specific device of another user (deprecated behaviour)
4 changes: 3 additions & 1 deletion library/ui-strings/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2465,7 +2465,9 @@

<string name="verification_profile_device_verified_because">This session is trusted for secure messaging because %1$s (%2$s) verified it:</string>
<string name="verification_profile_device_new_signing">%1$s (%2$s) signed in using a new session:</string>
<string name="verification_profile_device_untrust_info">Until this user trusts this session, messages sent to and from it are labeled with warnings. Alternatively, you can manually verify it.</string>
<!-- TODO TO BE REMOVED -->
<string tools:ignore="UnusedResources" name="verification_profile_device_untrust_info">Until this user trusts this session, messages sent to and from it are labeled with warnings. Alternatively, you can manually verify it.</string>
<string name="verification_profile_other_device_untrust_info">Until this user trusts this session, messages sent to and from it are labeled with warnings.</string>


<string name="initialize_cross_signing">Initialize CrossSigning</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
sealed class DeviceListAction : VectorViewModelAction {
data class SelectDevice(val device: CryptoDeviceInfo) : DeviceListAction()
object DeselectDevice : DeviceListAction()

data class ManuallyVerify(val deviceId: String) : DeviceListAction()
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,7 @@ class DeviceListBottomSheet :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel.observeViewEvents {
when (it) {
is DeviceListBottomSheetViewEvents.Verify -> {
// TODO selfverif
// VerificationBottomSheet.withArgs(
// // roomId = null,
// otherUserId = it.userId,
// transactionId = it.txID
// ).show(requireActivity().supportFragmentManager, "REQPOP")
}
}
// nop
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@ import im.vector.app.core.platform.VectorViewEvents
/**
* Transient events for device list screen.
*/
sealed class DeviceListBottomSheetViewEvents : VectorViewEvents {
data class Verify(val userId: String, val txID: String) : DeviceListBottomSheetViewEvents()
}
sealed class DeviceListBottomSheetViewEvents : VectorViewEvents
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
import org.matrix.android.sdk.api.session.getUserOrDefault
import org.matrix.android.sdk.api.util.MatrixItem
import org.matrix.android.sdk.api.util.toMatrixItem
import org.matrix.android.sdk.flow.flow

data class DeviceListViewState(
val userId: String,
val allowDeviceAction: Boolean,
val myUserId: String,
val userItem: MatrixItem? = null,
val memberCrossSigningKey: MXCrossSigningInfo? = null,
val myDeviceId: String = "",
Expand All @@ -69,7 +68,7 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
val session = EntryPoints.get(viewModelContext.app(), SingletonEntryPoint::class.java).activeSessionHolder().getActiveSession()
return DeviceListViewState(
userId = userId,
allowDeviceAction = args.allowDeviceAction,
myUserId = session.myUserId,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but maybe also remove DeviceListBottomSheet.Args::allowDeviceAction

userItem = session.getUserOrDefault(userId).toMatrixItem(),
myDeviceId = session.sessionParams.deviceId,
)
Expand Down Expand Up @@ -104,7 +103,6 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
when (action) {
is DeviceListAction.SelectDevice -> selectDevice(action)
is DeviceListAction.DeselectDevice -> deselectDevice()
is DeviceListAction.ManuallyVerify -> manuallyVerify(action)
}
}

Expand All @@ -121,7 +119,6 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
}

private fun selectDevice(action: DeviceListAction.SelectDevice) {
if (!initialState.allowDeviceAction) return
setState {
copy(selectedDevice = action.device)
}
Expand All @@ -132,18 +129,4 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
copy(selectedDevice = null)
}
}

private fun manuallyVerify(action: DeviceListAction.ManuallyVerify) {
if (!initialState.allowDeviceAction) return
viewModelScope.launch {
session.cryptoService().verificationService().requestDeviceVerification(
methods = listOf(VerificationMethod.SAS),
otherUserId = initialState.userId,
otherDeviceId = action.deviceId,
).transactionId
.let { txID ->
_viewEvents.post(DeviceListBottomSheetViewEvents.Verify(initialState.userId, txID))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.databinding.BottomSheetGenericListBinding
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
import javax.inject.Inject

@AndroidEntryPoint
Expand Down Expand Up @@ -63,8 +62,4 @@ class DeviceTrustInfoActionFragment :
override fun invalidate() = withState(viewModel) {
epoxyController.setData(it)
}

override fun onVerifyManually(device: CryptoDeviceInfo) {
viewModel.handle(DeviceListAction.ManuallyVerify(device.deviceId))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,21 @@ import im.vector.app.core.ui.list.genericFooterItem
import im.vector.app.core.ui.list.genericItem
import im.vector.app.core.ui.list.genericWithValueItem
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.settings.devices.TrustUtils
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
import me.gujun.android.span.span
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
import javax.inject.Inject

class DeviceTrustInfoEpoxyController @Inject constructor(
private val stringProvider: StringProvider,
private val colorProvider: ColorProvider,
private val dimensionConverter: DimensionConverter,
private val vectorPreferences: VectorPreferences
) :
TypedEpoxyController<DeviceListViewState>() {

interface InteractionListener {
fun onVerifyManually(device: CryptoDeviceInfo)
}
interface InteractionListener

var interactionListener: InteractionListener? = null

Expand All @@ -54,7 +48,7 @@ class DeviceTrustInfoEpoxyController @Inject constructor(
data?.selectedDevice?.let { cryptoDeviceInfo ->
val trustMSK = data.memberCrossSigningKey?.isTrusted().orFalse()
val legacyMode = data.memberCrossSigningKey == null
val isMyDevice = data.myDeviceId == cryptoDeviceInfo.deviceId
val isMyDevice = data.userId == data.myUserId && data.myDeviceId == cryptoDeviceInfo.deviceId
val trustLevel = TrustUtils.shieldForTrust(
isMyDevice,
trustMSK,
Expand Down Expand Up @@ -126,18 +120,7 @@ class DeviceTrustInfoEpoxyController @Inject constructor(
id("warn")
centered(false)
textColor(host.colorProvider.getColorFromAttribute(R.attr.vctr_content_primary))
text(host.stringProvider.getString(R.string.verification_profile_device_untrust_info).toEpoxyCharSequence())
}

bottomSheetVerificationActionItem {
id("verify")
title(host.stringProvider.getString(R.string.cross_signing_verify_by_emoji))
titleColor(host.colorProvider.getColorFromAttribute(R.attr.colorPrimary))
iconRes(R.drawable.ic_arrow_right)
iconColor(host.colorProvider.getColorFromAttribute(R.attr.colorPrimary))
listener {
host.interactionListener?.onVerifyManually(cryptoDeviceInfo)
}
text(host.stringProvider.getString(R.string.verification_profile_other_device_untrust_info).toEpoxyCharSequence())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
// TODO Replace usage by the use case GetEncryptionTrustLevelForDeviceUseCase
object TrustUtils {

// XXX why is this using the RoomEncryptionTrustLevel?
// should be using a new DeviceTrustShield enum

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the TODO just above?

fun shieldForTrust(
currentDevice: Boolean,
trustMSK: Boolean,
Expand Down