Remove actions that have been added only for debug purpose - step 1

This commit is contained in:
Benoit Marty 2020-08-17 09:33:21 +02:00 committed by Benoit Marty
parent 35a5d9e454
commit 1c48ba6b99
6 changed files with 11 additions and 99 deletions

View file

@ -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

View file

@ -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<CrossSigningSettingsViewState>() {
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 {

View file

@ -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)
}
}

View file

@ -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()
}

View file

@ -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<CrossSigningSettingsViewModel, CrossSigningSettingsViewState> {

View file

@ -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