From 712d39b9dd260ddb2f700e3779b69dba546b46d2 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 5 Sep 2022 11:59:32 +0200 Subject: [PATCH] Inject new ViewModel in the fragment V2 + add use cases --- ...etCurrentSessionCrossSigningInfoUseCase.kt | 3 +- ...GetEncryptionTrustLevelForDeviceUseCase.kt | 1 + .../CurrentSessionCrossSigningInfo.kt | 8 +-- .../settings/devices/v2/DevicesViewModel.kt | 58 +++++++++++----- .../settings/devices/v2/DevicesViewState.kt | 5 +- ...etCurrentSessionCrossSigningInfoUseCase.kt | 49 ++++++++++++++ .../v2/GetDeviceFullInfoListUseCase.kt | 67 +++++++++++++++++++ .../v2/VectorSettingsDevicesFragment.kt | 36 ++++------ .../v2/list/OtherSessionsController.kt | 6 +- .../devices/v2/list/OtherSessionsView.kt | 2 +- .../devices/v2/list/SessionInfoView.kt | 2 +- .../devices/v2/list/SessionInfoViewState.kt | 2 +- .../v2/overview/GetDeviceFullInfoUseCase.kt | 4 +- .../v2/overview/SessionOverviewFragment.kt | 2 +- .../v2/overview/SessionOverviewViewState.kt | 2 +- ...rrentSessionCrossSigningInfoUseCaseTest.kt | 1 + ...ncryptionTrustLevelForDeviceUseCaseTest.kt | 1 + .../overview/GetDeviceFullInfoUseCaseTest.kt | 2 +- 18 files changed, 195 insertions(+), 56 deletions(-) rename vector/src/main/java/im/vector/app/features/settings/devices/{ => v2}/CurrentSessionCrossSigningInfo.kt (78%) create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/GetCurrentSessionCrossSigningInfoUseCase.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/GetCurrentSessionCrossSigningInfoUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/GetCurrentSessionCrossSigningInfoUseCase.kt index d07bd5daae..8b58bd0536 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/GetCurrentSessionCrossSigningInfoUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/GetCurrentSessionCrossSigningInfoUseCase.kt @@ -17,6 +17,7 @@ package im.vector.app.features.settings.devices import im.vector.app.core.di.ActiveSessionHolder +import im.vector.app.features.settings.devices.v2.CurrentSessionCrossSigningInfo import javax.inject.Inject class GetCurrentSessionCrossSigningInfoUseCase @Inject constructor( @@ -28,7 +29,7 @@ class GetCurrentSessionCrossSigningInfoUseCase @Inject constructor( val isCrossSigningInitialized = session.cryptoService().crossSigningService().isCrossSigningInitialized() val isCrossSigningVerified = session.cryptoService().crossSigningService().isCrossSigningVerified() return CurrentSessionCrossSigningInfo( - deviceId = session.sessionParams.deviceId, + deviceId = session.sessionParams.deviceId.orEmpty(), isCrossSigningInitialized = isCrossSigningInitialized, isCrossSigningVerified = isCrossSigningVerified ) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCase.kt index e5ef4b446b..433c4da233 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCase.kt @@ -16,6 +16,7 @@ package im.vector.app.features.settings.devices +import im.vector.app.features.settings.devices.v2.CurrentSessionCrossSigningInfo import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel import javax.inject.Inject diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/CurrentSessionCrossSigningInfo.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/CurrentSessionCrossSigningInfo.kt similarity index 78% rename from vector/src/main/java/im/vector/app/features/settings/devices/CurrentSessionCrossSigningInfo.kt rename to vector/src/main/java/im/vector/app/features/settings/devices/v2/CurrentSessionCrossSigningInfo.kt index 790de08823..cccdb23d52 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/CurrentSessionCrossSigningInfo.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/CurrentSessionCrossSigningInfo.kt @@ -14,13 +14,13 @@ * limitations under the License. */ -package im.vector.app.features.settings.devices +package im.vector.app.features.settings.devices.v2 /** * Used to hold some info about the cross signing of the current Session. */ data class CurrentSessionCrossSigningInfo( - val deviceId: String?, - val isCrossSigningInitialized: Boolean, - val isCrossSigningVerified: Boolean, + val deviceId: String = "", + val isCrossSigningInitialized: Boolean = false, + val isCrossSigningVerified: Boolean = false, ) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewModel.kt index 00fae17cad..09de9ca8e7 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewModel.kt @@ -17,29 +17,22 @@ package im.vector.app.features.settings.devices.v2 import com.airbnb.mvrx.MavericksViewModelFactory +import com.airbnb.mvrx.Success import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import im.vector.app.core.di.MavericksAssistedViewModelFactory import im.vector.app.core.di.hiltMavericksViewModelFactory import im.vector.app.core.platform.VectorViewModel -import im.vector.app.core.resources.StringProvider -import im.vector.app.features.login.ReAuthHelper -import im.vector.app.features.settings.devices.GetCurrentSessionCrossSigningInfoUseCase -import im.vector.app.features.settings.devices.GetEncryptionTrustLevelForDeviceUseCase -import im.vector.app.features.settings.devices.v2.list.CheckIfSessionIsInactiveUseCase -import org.matrix.android.sdk.api.Matrix -import org.matrix.android.sdk.api.session.Session +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import org.matrix.android.sdk.api.extensions.orFalse +// TODO add unit tests class DevicesViewModel @AssistedInject constructor( @Assisted initialState: DevicesViewState, - private val session: Session, - private val reAuthHelper: ReAuthHelper, - private val stringProvider: StringProvider, - private val matrix: Matrix, - private val checkIfSessionIsInactiveUseCase: CheckIfSessionIsInactiveUseCase, - getCurrentSessionCrossSigningInfoUseCase: GetCurrentSessionCrossSigningInfoUseCase, - private val getEncryptionTrustLevelForDeviceUseCase: GetEncryptionTrustLevelForDeviceUseCase, + private val getCurrentSessionCrossSigningInfoUseCase: GetCurrentSessionCrossSigningInfoUseCase, + private val getDeviceFullInfoListUseCase: GetDeviceFullInfoListUseCase, ) : VectorViewModel(initialState) { @AssistedFactory @@ -49,8 +42,43 @@ class DevicesViewModel @AssistedInject constructor( companion object : MavericksViewModelFactory by hiltMavericksViewModelFactory() + init { + observeCurrentSessionCrossSigningInfo() + observeDevices() + } + + private fun observeCurrentSessionCrossSigningInfo() { + getCurrentSessionCrossSigningInfoUseCase.execute() + .onEach { crossSigningInfo -> + setState { + copy(currentSessionCrossSigningInfo = crossSigningInfo) + } + } + .launchIn(viewModelScope) + } + + private fun observeDevices() { + getDeviceFullInfoListUseCase.execute() + .execute { async -> + if (async is Success) { + val deviceFullInfoList = async.invoke() + val unverifiedSessionsCount = deviceFullInfoList.count { !it.cryptoDeviceInfo?.trustLevel?.isVerified().orFalse() } + val inactiveSessionsCount = deviceFullInfoList.count { it.isInactive } + copy( + devices = async, + unverifiedSessionsCount = unverifiedSessionsCount, + inactiveSessionsCount = inactiveSessionsCount, + ) + } else { + copy( + devices = async + ) + } + } + } + override fun handle(action: DevicesAction) { - when(action) { + when (action) { is DevicesAction.MarkAsManuallyVerified -> handleMarkAsManuallyVerifiedAction() } } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewState.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewState.kt index 284520f5b2..3fc061daa4 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewState.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewState.kt @@ -21,10 +21,9 @@ import com.airbnb.mvrx.MavericksState import com.airbnb.mvrx.Uninitialized data class DevicesViewState( - val myDeviceId: String = "", + val currentSessionCrossSigningInfo: CurrentSessionCrossSigningInfo = CurrentSessionCrossSigningInfo(), val devices: Async> = Uninitialized, - val hasAccountCrossSigning: Boolean = false, - val accountCrossSigningIsTrusted: Boolean = false, val unverifiedSessionsCount: Int = 0, val inactiveSessionsCount: Int = 0, + val isLoading: Boolean = false, ) : MavericksState diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetCurrentSessionCrossSigningInfoUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetCurrentSessionCrossSigningInfoUseCase.kt new file mode 100644 index 0000000000..9f7a3d8208 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetCurrentSessionCrossSigningInfoUseCase.kt @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.settings.devices.v2 + +import im.vector.app.core.di.ActiveSessionHolder +import im.vector.app.features.settings.devices.v2.CurrentSessionCrossSigningInfo +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.emptyFlow +import kotlinx.coroutines.flow.map +import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo +import org.matrix.android.sdk.api.util.Optional +import org.matrix.android.sdk.flow.flow +import javax.inject.Inject + +// TODO add unit tests +class GetCurrentSessionCrossSigningInfoUseCase @Inject constructor( + private val activeSessionHolder: ActiveSessionHolder, +) { + + fun execute(): Flow { + return activeSessionHolder.getSafeActiveSession() + ?.let { session -> + session.flow().liveCrossSigningInfo(session.myUserId) + .map { convertToSigningInfo(session.sessionParams.deviceId.orEmpty(), it) } + } ?: emptyFlow() + } + + private fun convertToSigningInfo(deviceId: String, mxCrossSigningInfo: Optional): CurrentSessionCrossSigningInfo { + return CurrentSessionCrossSigningInfo( + deviceId = deviceId, + isCrossSigningInitialized = mxCrossSigningInfo.getOrNull() != null, + isCrossSigningVerified = mxCrossSigningInfo.getOrNull()?.isTrusted() == true + ) + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt new file mode 100644 index 0000000000..fbe6609ef4 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.settings.devices.v2 + +import im.vector.app.core.di.ActiveSessionHolder +import im.vector.app.features.settings.devices.GetEncryptionTrustLevelForDeviceUseCase +import im.vector.app.features.settings.devices.v2.list.CheckIfSessionIsInactiveUseCase +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.emptyFlow +import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo +import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo +import org.matrix.android.sdk.flow.flow +import javax.inject.Inject + +// TODO add unit tests +class GetDeviceFullInfoListUseCase @Inject constructor( + private val activeSessionHolder: ActiveSessionHolder, + private val checkIfSessionIsInactiveUseCase: CheckIfSessionIsInactiveUseCase, + private val getEncryptionTrustLevelForDeviceUseCase: GetEncryptionTrustLevelForDeviceUseCase, + private val getCurrentSessionCrossSigningInfoUseCase: GetCurrentSessionCrossSigningInfoUseCase, +) { + + fun execute(): Flow> { + return activeSessionHolder.getSafeActiveSession()?.let { session -> + val deviceFullInfoFlow = combine( + getCurrentSessionCrossSigningInfoUseCase.execute(), + session.flow().liveUserCryptoDevices(session.myUserId), + session.flow().liveMyDevicesInfo() + ) { currentSessionCrossSigningInfo, cryptoList, infoList -> + convertToDeviceFullInfoList(currentSessionCrossSigningInfo, cryptoList, infoList) + } + + deviceFullInfoFlow.distinctUntilChanged() + } ?: emptyFlow() + } + + private fun convertToDeviceFullInfoList( + currentSessionCrossSigningInfo: CurrentSessionCrossSigningInfo, + cryptoList: List, + infoList: List, + ): List { + return infoList + .sortedByDescending { it.lastSeenTs } + .map { deviceInfo -> + val cryptoDeviceInfo = cryptoList.firstOrNull { it.deviceId == deviceInfo.deviceId } + val trustLevelForShield = getEncryptionTrustLevelForDeviceUseCase.execute(currentSessionCrossSigningInfo, cryptoDeviceInfo) + val isInactive = checkIfSessionIsInactiveUseCase.execute(deviceInfo.lastSeenTs ?: 0) + DeviceFullInfo(deviceInfo, cryptoDeviceInfo, trustLevelForShield, isInactive) + } + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt index dc72d4fe9c..acf33dc01d 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt @@ -24,8 +24,6 @@ import android.view.ViewGroup import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.core.view.isVisible -import com.airbnb.mvrx.Async -import com.airbnb.mvrx.Loading import com.airbnb.mvrx.Success import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState @@ -39,10 +37,6 @@ import im.vector.app.core.resources.DrawableProvider import im.vector.app.databinding.FragmentSettingsDevicesBinding import im.vector.app.features.crypto.recover.SetupMode import im.vector.app.features.crypto.verification.VerificationBottomSheet -import im.vector.app.features.settings.devices.DeviceFullInfo -import im.vector.app.features.settings.devices.DevicesAction -import im.vector.app.features.settings.devices.DevicesViewEvents -import im.vector.app.features.settings.devices.DevicesViewModel import im.vector.app.features.settings.devices.v2.list.OtherSessionsController import im.vector.app.features.settings.devices.v2.list.SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS import im.vector.app.features.settings.devices.v2.list.SecurityRecommendationViewState @@ -93,27 +87,27 @@ class VectorSettingsDevicesFragment : private fun observeViewEvents() { viewModel.observeViewEvents { when (it) { - is DevicesViewEvents.Loading -> showLoading(it.message) - is DevicesViewEvents.Failure -> showFailure(it.throwable) - is DevicesViewEvents.RequestReAuth -> Unit // TODO. Next PR - is DevicesViewEvents.PromptRenameDevice -> Unit // TODO. Next PR - is DevicesViewEvents.ShowVerifyDevice -> { + is DevicesViewEvent.Loading -> showLoading(it.message) + is DevicesViewEvent.Failure -> showFailure(it.throwable) + is DevicesViewEvent.RequestReAuth -> Unit // TODO. Next PR + is DevicesViewEvent.PromptRenameDevice -> Unit // TODO. Next PR + is DevicesViewEvent.ShowVerifyDevice -> { VerificationBottomSheet.withArgs( roomId = null, otherUserId = it.userId, transactionId = it.transactionId ).show(childFragmentManager, "REQPOP") } - is DevicesViewEvents.SelfVerification -> { + is DevicesViewEvent.SelfVerification -> { VerificationBottomSheet.forSelfVerification(it.session) .show(childFragmentManager, "REQPOP") } - is DevicesViewEvents.ShowManuallyVerify -> { + is DevicesViewEvent.ShowManuallyVerify -> { ManuallyVerifyDialog.show(requireActivity(), it.cryptoDeviceInfo) { viewModel.handle(DevicesAction.MarkAsManuallyVerified(it.cryptoDeviceInfo)) } } - is DevicesViewEvents.PromptResetSecrets -> { + is DevicesViewEvent.PromptResetSecrets -> { navigator.open4SSetup(requireActivity(), SetupMode.PASSPHRASE_AND_NEEDED_SECRETS_RESET) } } @@ -151,10 +145,11 @@ class VectorSettingsDevicesFragment : override fun invalidate() = withState(viewModel) { state -> if (state.devices is Success) { val devices = state.devices() + val currentDeviceId = state.currentSessionCrossSigningInfo.deviceId val currentDeviceInfo = devices?.firstOrNull { - it.deviceInfo.deviceId == state.myDeviceId + it.deviceInfo.deviceId == currentDeviceId } - val otherDevices = devices?.filter { it.deviceInfo.deviceId != state.myDeviceId } + val otherDevices = devices?.filter { it.deviceInfo.deviceId != currentDeviceId } renderSecurityRecommendations(state.inactiveSessionsCount, state.unverifiedSessionsCount) renderCurrentDevice(currentDeviceInfo) @@ -165,7 +160,7 @@ class VectorSettingsDevicesFragment : hideOtherSessionsView() } - handleRequestStatus(state.request) + handleLoadingStatus(state.isLoading) } private fun renderSecurityRecommendations(inactiveSessionsCount: Int, unverifiedSessionsCount: Int) { @@ -254,10 +249,7 @@ class VectorSettingsDevicesFragment : } } - private fun handleRequestStatus(unIgnoreRequest: Async) { - views.waitingView.root.isVisible = when (unIgnoreRequest) { - is Loading -> true - else -> false - } + private fun handleLoadingStatus(isLoading: Boolean) { + views.waitingView.root.isVisible = isLoading } } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt index 6419d02fc9..468b19c45a 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt @@ -24,7 +24,7 @@ import im.vector.app.core.epoxy.noResultItem import im.vector.app.core.resources.ColorProvider import im.vector.app.core.resources.DrawableProvider import im.vector.app.core.resources.StringProvider -import im.vector.app.features.settings.devices.DeviceFullInfo +import im.vector.app.features.settings.devices.v2.DeviceFullInfo import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel import javax.inject.Inject @@ -60,7 +60,7 @@ class OtherSessionsController @Inject constructor( SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS, formattedLastActivityDate ) - } else if (device.trustLevelForShield == RoomEncryptionTrustLevel.Trusted) { + } else if (device.roomEncryptionTrustLevel == RoomEncryptionTrustLevel.Trusted) { stringProvider.getString(R.string.device_manager_other_sessions_description_verified, formattedLastActivityDate) } else { stringProvider.getString(R.string.device_manager_other_sessions_description_unverified, formattedLastActivityDate) @@ -71,7 +71,7 @@ class OtherSessionsController @Inject constructor( otherSessionItem { id(device.deviceInfo.deviceId) deviceType(DeviceType.UNKNOWN) // TODO. We don't have this info yet. Update accordingly. - roomEncryptionTrustLevel(device.trustLevelForShield) + roomEncryptionTrustLevel(device.roomEncryptionTrustLevel) sessionName(device.deviceInfo.displayName) sessionDescription(description) sessionDescriptionDrawable(descriptionDrawable) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsView.kt index 682a9c6e64..b552664fe9 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsView.kt @@ -24,7 +24,7 @@ import im.vector.app.R import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.databinding.ViewOtherSessionsBinding -import im.vector.app.features.settings.devices.DeviceFullInfo +import im.vector.app.features.settings.devices.v2.DeviceFullInfo import javax.inject.Inject @AndroidEntryPoint diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt index 767f09482b..0cb621a502 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt @@ -57,7 +57,7 @@ class SessionInfoView @JvmOverloads constructor( ) { renderDeviceInfo(sessionInfoViewState.deviceFullInfo.deviceInfo.displayName.orEmpty()) renderVerificationStatus( - sessionInfoViewState.deviceFullInfo.trustLevelForShield, + sessionInfoViewState.deviceFullInfo.roomEncryptionTrustLevel, sessionInfoViewState.isCurrentSession, sessionInfoViewState.isLearnMoreLinkVisible, ) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoViewState.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoViewState.kt index 22ad710676..60e1234820 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoViewState.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoViewState.kt @@ -16,7 +16,7 @@ package im.vector.app.features.settings.devices.v2.list -import im.vector.app.features.settings.devices.DeviceFullInfo +import im.vector.app.features.settings.devices.v2.DeviceFullInfo data class SessionInfoViewState( val isCurrentSession: Boolean, diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt index c3579b68c3..a8a97ab326 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt @@ -18,7 +18,7 @@ package im.vector.app.features.settings.devices.v2.overview import androidx.lifecycle.asFlow import im.vector.app.core.di.ActiveSessionHolder -import im.vector.app.features.settings.devices.DeviceFullInfo +import im.vector.app.features.settings.devices.v2.DeviceFullInfo import im.vector.app.features.settings.devices.GetCurrentSessionCrossSigningInfoUseCase import im.vector.app.features.settings.devices.GetEncryptionTrustLevelForDeviceUseCase import im.vector.app.features.settings.devices.v2.list.CheckIfSessionIsInactiveUseCase @@ -51,7 +51,7 @@ class GetDeviceFullInfoUseCase @Inject constructor( DeviceFullInfo( deviceInfo = info, cryptoDeviceInfo = cryptoInfo, - trustLevelForShield = roomEncryptionTrustLevel, + roomEncryptionTrustLevel = roomEncryptionTrustLevel, isInactive = isInactive ) } else { diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt index a6bac6087b..c5cd80bd3c 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt @@ -34,7 +34,7 @@ import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.resources.ColorProvider import im.vector.app.core.resources.DrawableProvider import im.vector.app.databinding.FragmentSessionOverviewBinding -import im.vector.app.features.settings.devices.DeviceFullInfo +import im.vector.app.features.settings.devices.v2.DeviceFullInfo import im.vector.app.features.settings.devices.v2.list.SessionInfoViewState import javax.inject.Inject diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewState.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewState.kt index c9f5635cbd..a447336c23 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewState.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewState.kt @@ -19,7 +19,7 @@ package im.vector.app.features.settings.devices.v2.overview import com.airbnb.mvrx.Async import com.airbnb.mvrx.MavericksState import com.airbnb.mvrx.Uninitialized -import im.vector.app.features.settings.devices.DeviceFullInfo +import im.vector.app.features.settings.devices.v2.DeviceFullInfo data class SessionOverviewViewState( val deviceId: String, diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/GetCurrentSessionCrossSigningInfoUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/GetCurrentSessionCrossSigningInfoUseCaseTest.kt index 7c8ee008eb..1a805f4c3e 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/GetCurrentSessionCrossSigningInfoUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/GetCurrentSessionCrossSigningInfoUseCaseTest.kt @@ -16,6 +16,7 @@ package im.vector.app.features.settings.devices +import im.vector.app.features.settings.devices.v2.CurrentSessionCrossSigningInfo import im.vector.app.test.fakes.FakeActiveSessionHolder import io.mockk.every import io.mockk.mockk diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCaseTest.kt index 8d54b31ab4..e55f0969f7 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCaseTest.kt @@ -16,6 +16,7 @@ package im.vector.app.features.settings.devices +import im.vector.app.features.settings.devices.v2.CurrentSessionCrossSigningInfo import io.mockk.every import io.mockk.mockk import io.mockk.verify diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt index e3d62961a7..70af681c6f 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt @@ -18,7 +18,7 @@ package im.vector.app.features.settings.devices.v2.overview import androidx.lifecycle.MutableLiveData import androidx.lifecycle.asFlow -import im.vector.app.features.settings.devices.CurrentSessionCrossSigningInfo +import im.vector.app.features.settings.devices.v2.CurrentSessionCrossSigningInfo import im.vector.app.features.settings.devices.DeviceFullInfo import im.vector.app.features.settings.devices.GetCurrentSessionCrossSigningInfoUseCase import im.vector.app.features.settings.devices.GetEncryptionTrustLevelForDeviceUseCase