mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 02:15:46 +03:00
Merge pull request #8458 from vector-im/feature/bca/remove_legacy_per_device_verif
Remove legacy manually verify specific other device
This commit is contained in:
commit
9f3255dd78
10 changed files with 16 additions and 64 deletions
1
changelog.d/8458.misc
Normal file
1
changelog.d/8458.misc
Normal file
|
@ -0,0 +1 @@
|
|||
Remove UI option to manually verify a specific device of another user (deprecated behaviour)
|
|
@ -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>
|
||||
|
|
|
@ -52,7 +52,7 @@ class SharedSecuredStorageResetAllFragment :
|
|||
|
||||
views.ssssResetOtherDevices.debouncedClicks {
|
||||
withState(sharedViewModel) {
|
||||
DeviceListBottomSheet.newInstance(it.userId, false).show(childFragmentManager, "DEV_LIST")
|
||||
DeviceListBottomSheet.newInstance(it.userId).show(childFragmentManager, "DEV_LIST")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,13 +100,12 @@ class DeviceListBottomSheet :
|
|||
@Parcelize
|
||||
data class Args(
|
||||
val userId: String,
|
||||
val allowDeviceAction: Boolean
|
||||
) : Parcelable
|
||||
|
||||
companion object {
|
||||
fun newInstance(userId: String, allowDeviceAction: Boolean = true): DeviceListBottomSheet {
|
||||
fun newInstance(userId: String): DeviceListBottomSheet {
|
||||
return DeviceListBottomSheet().apply {
|
||||
setArguments(Args(userId, allowDeviceAction))
|
||||
setArguments(Args(userId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.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
|
||||
|
@ -42,7 +41,7 @@ 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 = "",
|
||||
|
@ -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,
|
||||
userItem = session.getUserOrDefault(userId).toMatrixItem(),
|
||||
myDeviceId = session.sessionParams.deviceId,
|
||||
)
|
||||
|
@ -104,7 +103,6 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
|
|||
when (action) {
|
||||
is DeviceListAction.SelectDevice -> selectDevice(action)
|
||||
is DeviceListAction.DeselectDevice -> deselectDevice()
|
||||
is DeviceListAction.ManuallyVerify -> manuallyVerify(action)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +119,6 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private fun selectDevice(action: DeviceListAction.SelectDevice) {
|
||||
if (!initialState.allowDeviceAction) return
|
||||
setState {
|
||||
copy(selectedDevice = action.device)
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.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
|
||||
|
||||
|
@ -39,13 +36,10 @@ 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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ class GetEncryptionTrustLevelForDeviceUseCase @Inject constructor(
|
|||
private val getEncryptionTrustLevelForOtherDeviceUseCase: GetEncryptionTrustLevelForOtherDeviceUseCase,
|
||||
) {
|
||||
|
||||
// XXX why is this using the RoomEncryptionTrustLevel?
|
||||
// should be using a new DeviceTrustShield enum
|
||||
fun execute(currentSessionCrossSigningInfo: CurrentSessionCrossSigningInfo, cryptoDeviceInfo: CryptoDeviceInfo?): RoomEncryptionTrustLevel? {
|
||||
if (cryptoDeviceInfo == null) {
|
||||
return null
|
||||
|
|
Loading…
Reference in a new issue