From 1c48ba6b992b710234ef47fa0fbcc355ba5617a3 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 17 Aug 2020 09:33:21 +0200 Subject: [PATCH] Remove actions that have been added only for debug purpose - step 1 --- .../CrossSigningSettingsAction.kt | 6 +-- .../CrossSigningSettingsController.kt | 46 +------------------ .../CrossSigningSettingsFragment.kt | 23 +--------- .../CrossSigningSettingsViewEvents.kt | 4 -- .../CrossSigningSettingsViewModel.kt | 26 +++-------- .../CrossSigningSettingsViewState.kt | 5 +- 6 files changed, 11 insertions(+), 99 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsAction.kt b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsAction.kt index 1d7b4bf59b..af6ca9f4b7 100644 --- a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsAction.kt +++ b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsAction.kt @@ -18,8 +18,4 @@ package im.vector.app.features.settings.crosssigning import im.vector.app.core.platform.VectorViewModelAction -sealed class CrossSigningSettingsAction : VectorViewModelAction { - object SetUpRecovery : CrossSigningSettingsAction() - object VerifySession : CrossSigningSettingsAction() - object SetupCrossSigning : CrossSigningSettingsAction() -} +sealed class CrossSigningSettingsAction : VectorViewModelAction diff --git a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsController.kt b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsController.kt index e0eced9a73..82279a3906 100644 --- a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsController.kt @@ -22,7 +22,6 @@ import im.vector.app.core.resources.StringProvider import im.vector.app.core.ui.list.genericItem import im.vector.app.core.ui.list.genericItemWithValue import im.vector.app.core.utils.DimensionConverter -import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem import me.gujun.android.span.span import javax.inject.Inject @@ -32,11 +31,7 @@ class CrossSigningSettingsController @Inject constructor( private val dimensionConverter: DimensionConverter ) : TypedEpoxyController() { - interface InteractionListener { - fun setupRecovery() - fun verifySession() - fun initCrossSigning() - } + interface InteractionListener var interactionListener: InteractionListener? = null @@ -72,45 +67,6 @@ class CrossSigningSettingsController @Inject constructor( } } - if (data.recoveryHasToBeSetUp) { - if (data.xSigningIsEnableInAccount) { - bottomSheetVerificationActionItem { - id("setup_recovery") - title(stringProvider.getString(R.string.settings_setup_secure_backup)) - titleColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary)) - iconRes(R.drawable.ic_arrow_right) - listener { - interactionListener?.setupRecovery() - } - } - } else { - // Propose to setup cross signing - bottomSheetVerificationActionItem { - id("setup_xSgning") - title(stringProvider.getString(R.string.setup_cross_signing)) - titleColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary)) - subTitle(stringProvider.getString(R.string.security_prompt_text)) - iconRes(R.drawable.ic_arrow_right) - listener { - interactionListener?.initCrossSigning() - } - } - } - } - - if (data.deviceHasToBeVerified) { - bottomSheetVerificationActionItem { - id("verify") - title(stringProvider.getString(R.string.crosssigning_verify_this_session)) - titleColor(colorProvider.getColor(R.color.riotx_positive_accent)) - iconRes(R.drawable.ic_arrow_right) - iconColor(colorProvider.getColor(R.color.riotx_positive_accent)) - listener { - interactionListener?.verifySession() - } - } - } - val crossSigningKeys = data.crossSigningInfo crossSigningKeys?.masterKey()?.let { diff --git a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsFragment.kt index e70fd45251..711819f764 100644 --- a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsFragment.kt @@ -45,7 +45,7 @@ class CrossSigningSettingsFragment @Inject constructor( super.onActivityCreated(savedInstanceState) viewModel.observeViewEvents { when (it) { - is CrossSigningSettingsViewEvents.Failure -> { + is CrossSigningSettingsViewEvents.Failure -> { AlertDialog.Builder(requireContext()) .setTitle(R.string.dialog_title_error) .setMessage(errorFormatter.toHumanReadable(it.throwable)) @@ -53,15 +53,6 @@ class CrossSigningSettingsFragment @Inject constructor( .show() Unit } - CrossSigningSettingsViewEvents.VerifySession -> { - navigator.requestSelfSessionVerification(requireActivity()) - } - CrossSigningSettingsViewEvents.SetUpRecovery -> { - navigator.upgradeSessionSecurity(requireActivity(), false) - } - CrossSigningSettingsViewEvents.SetupCrossSigning -> { - navigator.upgradeSessionSecurity(requireActivity(), true) - } }.exhaustive } } @@ -90,16 +81,4 @@ class CrossSigningSettingsFragment @Inject constructor( controller.interactionListener = null super.onDestroyView() } - - override fun setupRecovery() { - viewModel.handle(CrossSigningSettingsAction.SetUpRecovery) - } - - override fun verifySession() { - viewModel.handle(CrossSigningSettingsAction.VerifySession) - } - - override fun initCrossSigning() { - viewModel.handle(CrossSigningSettingsAction.SetupCrossSigning) - } } diff --git a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewEvents.kt b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewEvents.kt index 52f939636c..b81a321f3f 100644 --- a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewEvents.kt +++ b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewEvents.kt @@ -23,8 +23,4 @@ import im.vector.app.core.platform.VectorViewEvents */ sealed class CrossSigningSettingsViewEvents : VectorViewEvents { data class Failure(val throwable: Throwable) : CrossSigningSettingsViewEvents() - - object SetUpRecovery : CrossSigningSettingsViewEvents() - object VerifySession : CrossSigningSettingsViewEvents() - object SetupCrossSigning : CrossSigningSettingsViewEvents() } diff --git a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewModel.kt index f2f108b3e4..3f70ac1fd7 100644 --- a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewModel.kt @@ -20,15 +20,14 @@ import com.airbnb.mvrx.MvRxViewModelFactory import com.airbnb.mvrx.ViewModelContext import com.squareup.inject.assisted.Assisted import com.squareup.inject.assisted.AssistedInject +import im.vector.app.core.platform.VectorViewModel +import io.reactivex.Observable +import io.reactivex.functions.BiFunction import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo import org.matrix.android.sdk.api.util.Optional import org.matrix.android.sdk.internal.crypto.crosssigning.isVerified import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo -import im.vector.app.core.extensions.exhaustive -import im.vector.app.core.platform.VectorViewModel -import io.reactivex.Observable -import io.reactivex.functions.BiFunction import org.matrix.android.sdk.rx.rx class CrossSigningSettingsViewModel @AssistedInject constructor(@Assisted private val initialState: CrossSigningSettingsViewState, @@ -48,15 +47,12 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(@Assisted privat val xSigningIsEnableInAccount = crossSigningKeys != null val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified() val xSigningKeyCanSign = session.cryptoService().crossSigningService().canCrossSign() - val hasSeveralDevices = data.invoke()?.first?.size ?: 0 > 1 copy( crossSigningInfo = crossSigningKeys, xSigningIsEnableInAccount = xSigningIsEnableInAccount, xSigningKeysAreTrusted = xSigningKeysAreTrusted, - xSigningKeyCanSign = xSigningKeyCanSign, - deviceHasToBeVerified = hasSeveralDevices && (xSigningIsEnableInAccount && !xSigningKeyCanSign), - recoveryHasToBeSetUp = !session.sharedSecretStorageService.isRecoverySetup() + xSigningKeyCanSign = xSigningKeyCanSign ) } } @@ -67,17 +63,9 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(@Assisted privat } override fun handle(action: CrossSigningSettingsAction) { - when (action) { - CrossSigningSettingsAction.SetUpRecovery -> { - _viewEvents.post(CrossSigningSettingsViewEvents.SetUpRecovery) - } - CrossSigningSettingsAction.VerifySession -> { - _viewEvents.post(CrossSigningSettingsViewEvents.VerifySession) - } - CrossSigningSettingsAction.SetupCrossSigning -> { - _viewEvents.post(CrossSigningSettingsViewEvents.SetupCrossSigning) - } - }.exhaustive + // No op for the moment + // when (action) { + // }.exhaustive } companion object : MvRxViewModelFactory { diff --git a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewState.kt b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewState.kt index 17e2a3d9eb..8a371ada68 100644 --- a/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewState.kt +++ b/vector/src/main/java/im/vector/app/features/settings/crosssigning/CrossSigningSettingsViewState.kt @@ -23,8 +23,5 @@ data class CrossSigningSettingsViewState( val crossSigningInfo: MXCrossSigningInfo? = null, val xSigningIsEnableInAccount: Boolean = false, val xSigningKeysAreTrusted: Boolean = false, - val xSigningKeyCanSign: Boolean = true, - - val deviceHasToBeVerified: Boolean = false, - val recoveryHasToBeSetUp: Boolean = false + val xSigningKeyCanSign: Boolean = true ) : MvRxState