You've already forked element-android
mirror of
https://github.com/vector-im/element-android.git
synced 2025-07-31 07:04:23 +03:00
Remove legacy manually verify specific other device
This commit is contained in:
@ -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_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_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>
|
<string name="initialize_cross_signing">Initialize CrossSigning</string>
|
||||||
|
@ -22,6 +22,4 @@ import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
|||||||
sealed class DeviceListAction : VectorViewModelAction {
|
sealed class DeviceListAction : VectorViewModelAction {
|
||||||
data class SelectDevice(val device: CryptoDeviceInfo) : DeviceListAction()
|
data class SelectDevice(val device: CryptoDeviceInfo) : DeviceListAction()
|
||||||
object DeselectDevice : DeviceListAction()
|
object DeselectDevice : DeviceListAction()
|
||||||
|
|
||||||
data class ManuallyVerify(val deviceId: String) : DeviceListAction()
|
|
||||||
}
|
}
|
||||||
|
@ -47,16 +47,7 @@ class DeviceListBottomSheet :
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
viewModel.observeViewEvents {
|
viewModel.observeViewEvents {
|
||||||
when (it) {
|
// nop
|
||||||
is DeviceListBottomSheetViewEvents.Verify -> {
|
|
||||||
// TODO selfverif
|
|
||||||
// VerificationBottomSheet.withArgs(
|
|
||||||
// // roomId = null,
|
|
||||||
// otherUserId = it.userId,
|
|
||||||
// transactionId = it.txID
|
|
||||||
// ).show(requireActivity().supportFragmentManager, "REQPOP")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,4 @@ import im.vector.app.core.platform.VectorViewEvents
|
|||||||
/**
|
/**
|
||||||
* Transient events for device list screen.
|
* Transient events for device list screen.
|
||||||
*/
|
*/
|
||||||
sealed class DeviceListBottomSheetViewEvents : VectorViewEvents {
|
sealed class DeviceListBottomSheetViewEvents : VectorViewEvents
|
||||||
data class Verify(val userId: String, val txID: String) : DeviceListBottomSheetViewEvents()
|
|
||||||
}
|
|
||||||
|
@ -34,7 +34,6 @@ import org.matrix.android.sdk.api.extensions.tryOrNull
|
|||||||
import org.matrix.android.sdk.api.session.Session
|
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.crosssigning.MXCrossSigningInfo
|
||||||
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
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.session.getUserOrDefault
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||||
@ -42,7 +41,7 @@ import org.matrix.android.sdk.flow.flow
|
|||||||
|
|
||||||
data class DeviceListViewState(
|
data class DeviceListViewState(
|
||||||
val userId: String,
|
val userId: String,
|
||||||
val allowDeviceAction: Boolean,
|
val myUserId: String,
|
||||||
val userItem: MatrixItem? = null,
|
val userItem: MatrixItem? = null,
|
||||||
val memberCrossSigningKey: MXCrossSigningInfo? = null,
|
val memberCrossSigningKey: MXCrossSigningInfo? = null,
|
||||||
val myDeviceId: String = "",
|
val myDeviceId: String = "",
|
||||||
@ -69,7 +68,7 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
|
|||||||
val session = EntryPoints.get(viewModelContext.app(), SingletonEntryPoint::class.java).activeSessionHolder().getActiveSession()
|
val session = EntryPoints.get(viewModelContext.app(), SingletonEntryPoint::class.java).activeSessionHolder().getActiveSession()
|
||||||
return DeviceListViewState(
|
return DeviceListViewState(
|
||||||
userId = userId,
|
userId = userId,
|
||||||
allowDeviceAction = args.allowDeviceAction,
|
myUserId = session.myUserId,
|
||||||
userItem = session.getUserOrDefault(userId).toMatrixItem(),
|
userItem = session.getUserOrDefault(userId).toMatrixItem(),
|
||||||
myDeviceId = session.sessionParams.deviceId,
|
myDeviceId = session.sessionParams.deviceId,
|
||||||
)
|
)
|
||||||
@ -104,7 +103,6 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
|
|||||||
when (action) {
|
when (action) {
|
||||||
is DeviceListAction.SelectDevice -> selectDevice(action)
|
is DeviceListAction.SelectDevice -> selectDevice(action)
|
||||||
is DeviceListAction.DeselectDevice -> deselectDevice()
|
is DeviceListAction.DeselectDevice -> deselectDevice()
|
||||||
is DeviceListAction.ManuallyVerify -> manuallyVerify(action)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +119,6 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun selectDevice(action: DeviceListAction.SelectDevice) {
|
private fun selectDevice(action: DeviceListAction.SelectDevice) {
|
||||||
if (!initialState.allowDeviceAction) return
|
|
||||||
setState {
|
setState {
|
||||||
copy(selectedDevice = action.device)
|
copy(selectedDevice = action.device)
|
||||||
}
|
}
|
||||||
@ -132,18 +129,4 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
|
|||||||
copy(selectedDevice = null)
|
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))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import im.vector.app.core.extensions.configureWith
|
|||||||
import im.vector.app.core.platform.VectorBaseFragment
|
import im.vector.app.core.platform.VectorBaseFragment
|
||||||
import im.vector.app.core.utils.DimensionConverter
|
import im.vector.app.core.utils.DimensionConverter
|
||||||
import im.vector.app.databinding.BottomSheetGenericListBinding
|
import im.vector.app.databinding.BottomSheetGenericListBinding
|
||||||
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@ -63,8 +62,4 @@ class DeviceTrustInfoActionFragment :
|
|||||||
override fun invalidate() = withState(viewModel) {
|
override fun invalidate() = withState(viewModel) {
|
||||||
epoxyController.setData(it)
|
epoxyController.setData(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onVerifyManually(device: CryptoDeviceInfo) {
|
|
||||||
viewModel.handle(DeviceListAction.ManuallyVerify(device.deviceId))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,10 @@ import im.vector.app.core.ui.list.genericFooterItem
|
|||||||
import im.vector.app.core.ui.list.genericItem
|
import im.vector.app.core.ui.list.genericItem
|
||||||
import im.vector.app.core.ui.list.genericWithValueItem
|
import im.vector.app.core.ui.list.genericWithValueItem
|
||||||
import im.vector.app.core.utils.DimensionConverter
|
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.app.features.settings.devices.TrustUtils
|
||||||
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
|
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
|
||||||
import me.gujun.android.span.span
|
import me.gujun.android.span.span
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
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 org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -39,13 +36,10 @@ class DeviceTrustInfoEpoxyController @Inject constructor(
|
|||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
private val colorProvider: ColorProvider,
|
private val colorProvider: ColorProvider,
|
||||||
private val dimensionConverter: DimensionConverter,
|
private val dimensionConverter: DimensionConverter,
|
||||||
private val vectorPreferences: VectorPreferences
|
|
||||||
) :
|
) :
|
||||||
TypedEpoxyController<DeviceListViewState>() {
|
TypedEpoxyController<DeviceListViewState>() {
|
||||||
|
|
||||||
interface InteractionListener {
|
interface InteractionListener
|
||||||
fun onVerifyManually(device: CryptoDeviceInfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
var interactionListener: InteractionListener? = null
|
var interactionListener: InteractionListener? = null
|
||||||
|
|
||||||
@ -54,7 +48,7 @@ class DeviceTrustInfoEpoxyController @Inject constructor(
|
|||||||
data?.selectedDevice?.let { cryptoDeviceInfo ->
|
data?.selectedDevice?.let { cryptoDeviceInfo ->
|
||||||
val trustMSK = data.memberCrossSigningKey?.isTrusted().orFalse()
|
val trustMSK = data.memberCrossSigningKey?.isTrusted().orFalse()
|
||||||
val legacyMode = data.memberCrossSigningKey == null
|
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(
|
val trustLevel = TrustUtils.shieldForTrust(
|
||||||
isMyDevice,
|
isMyDevice,
|
||||||
trustMSK,
|
trustMSK,
|
||||||
@ -126,18 +120,7 @@ class DeviceTrustInfoEpoxyController @Inject constructor(
|
|||||||
id("warn")
|
id("warn")
|
||||||
centered(false)
|
centered(false)
|
||||||
textColor(host.colorProvider.getColorFromAttribute(R.attr.vctr_content_primary))
|
textColor(host.colorProvider.getColorFromAttribute(R.attr.vctr_content_primary))
|
||||||
text(host.stringProvider.getString(R.string.verification_profile_device_untrust_info).toEpoxyCharSequence())
|
text(host.stringProvider.getString(R.string.verification_profile_other_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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
|
|||||||
// TODO Replace usage by the use case GetEncryptionTrustLevelForDeviceUseCase
|
// TODO Replace usage by the use case GetEncryptionTrustLevelForDeviceUseCase
|
||||||
object TrustUtils {
|
object TrustUtils {
|
||||||
|
|
||||||
|
// XXX why is this using the RoomEncryptionTrustLevel?
|
||||||
|
// should be using a new DeviceTrustShield enum
|
||||||
fun shieldForTrust(
|
fun shieldForTrust(
|
||||||
currentDevice: Boolean,
|
currentDevice: Boolean,
|
||||||
trustMSK: Boolean,
|
trustMSK: Boolean,
|
||||||
|
Reference in New Issue
Block a user