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 import im.vector.app.core.platform.VectorViewModelAction
sealed class CrossSigningSettingsAction : VectorViewModelAction { sealed class CrossSigningSettingsAction : VectorViewModelAction
object SetUpRecovery : CrossSigningSettingsAction()
object VerifySession : CrossSigningSettingsAction()
object SetupCrossSigning : CrossSigningSettingsAction()
}

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.genericItem
import im.vector.app.core.ui.list.genericItemWithValue import im.vector.app.core.ui.list.genericItemWithValue
import im.vector.app.core.utils.DimensionConverter import im.vector.app.core.utils.DimensionConverter
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem
import me.gujun.android.span.span import me.gujun.android.span.span
import javax.inject.Inject import javax.inject.Inject
@ -32,11 +31,7 @@ class CrossSigningSettingsController @Inject constructor(
private val dimensionConverter: DimensionConverter private val dimensionConverter: DimensionConverter
) : TypedEpoxyController<CrossSigningSettingsViewState>() { ) : TypedEpoxyController<CrossSigningSettingsViewState>() {
interface InteractionListener { interface InteractionListener
fun setupRecovery()
fun verifySession()
fun initCrossSigning()
}
var interactionListener: InteractionListener? = null 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 val crossSigningKeys = data.crossSigningInfo
crossSigningKeys?.masterKey()?.let { crossSigningKeys?.masterKey()?.let {

View File

@ -45,7 +45,7 @@ class CrossSigningSettingsFragment @Inject constructor(
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
viewModel.observeViewEvents { viewModel.observeViewEvents {
when (it) { when (it) {
is CrossSigningSettingsViewEvents.Failure -> { is CrossSigningSettingsViewEvents.Failure -> {
AlertDialog.Builder(requireContext()) AlertDialog.Builder(requireContext())
.setTitle(R.string.dialog_title_error) .setTitle(R.string.dialog_title_error)
.setMessage(errorFormatter.toHumanReadable(it.throwable)) .setMessage(errorFormatter.toHumanReadable(it.throwable))
@ -53,15 +53,6 @@ class CrossSigningSettingsFragment @Inject constructor(
.show() .show()
Unit Unit
} }
CrossSigningSettingsViewEvents.VerifySession -> {
navigator.requestSelfSessionVerification(requireActivity())
}
CrossSigningSettingsViewEvents.SetUpRecovery -> {
navigator.upgradeSessionSecurity(requireActivity(), false)
}
CrossSigningSettingsViewEvents.SetupCrossSigning -> {
navigator.upgradeSessionSecurity(requireActivity(), true)
}
}.exhaustive }.exhaustive
} }
} }
@ -90,16 +81,4 @@ class CrossSigningSettingsFragment @Inject constructor(
controller.interactionListener = null controller.interactionListener = null
super.onDestroyView() 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 { sealed class CrossSigningSettingsViewEvents : VectorViewEvents {
data class Failure(val throwable: Throwable) : CrossSigningSettingsViewEvents() 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.airbnb.mvrx.ViewModelContext
import com.squareup.inject.assisted.Assisted import com.squareup.inject.assisted.Assisted
import com.squareup.inject.assisted.AssistedInject 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.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.util.Optional import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.internal.crypto.crosssigning.isVerified import org.matrix.android.sdk.internal.crypto.crosssigning.isVerified
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo 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 import org.matrix.android.sdk.rx.rx
class CrossSigningSettingsViewModel @AssistedInject constructor(@Assisted private val initialState: CrossSigningSettingsViewState, class CrossSigningSettingsViewModel @AssistedInject constructor(@Assisted private val initialState: CrossSigningSettingsViewState,
@ -48,15 +47,12 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(@Assisted privat
val xSigningIsEnableInAccount = crossSigningKeys != null val xSigningIsEnableInAccount = crossSigningKeys != null
val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified() val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified()
val xSigningKeyCanSign = session.cryptoService().crossSigningService().canCrossSign() val xSigningKeyCanSign = session.cryptoService().crossSigningService().canCrossSign()
val hasSeveralDevices = data.invoke()?.first?.size ?: 0 > 1
copy( copy(
crossSigningInfo = crossSigningKeys, crossSigningInfo = crossSigningKeys,
xSigningIsEnableInAccount = xSigningIsEnableInAccount, xSigningIsEnableInAccount = xSigningIsEnableInAccount,
xSigningKeysAreTrusted = xSigningKeysAreTrusted, xSigningKeysAreTrusted = xSigningKeysAreTrusted,
xSigningKeyCanSign = xSigningKeyCanSign, xSigningKeyCanSign = xSigningKeyCanSign
deviceHasToBeVerified = hasSeveralDevices && (xSigningIsEnableInAccount && !xSigningKeyCanSign),
recoveryHasToBeSetUp = !session.sharedSecretStorageService.isRecoverySetup()
) )
} }
} }
@ -67,17 +63,9 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(@Assisted privat
} }
override fun handle(action: CrossSigningSettingsAction) { override fun handle(action: CrossSigningSettingsAction) {
when (action) { // No op for the moment
CrossSigningSettingsAction.SetUpRecovery -> { // when (action) {
_viewEvents.post(CrossSigningSettingsViewEvents.SetUpRecovery) // }.exhaustive
}
CrossSigningSettingsAction.VerifySession -> {
_viewEvents.post(CrossSigningSettingsViewEvents.VerifySession)
}
CrossSigningSettingsAction.SetupCrossSigning -> {
_viewEvents.post(CrossSigningSettingsViewEvents.SetupCrossSigning)
}
}.exhaustive
} }
companion object : MvRxViewModelFactory<CrossSigningSettingsViewModel, CrossSigningSettingsViewState> { companion object : MvRxViewModelFactory<CrossSigningSettingsViewModel, CrossSigningSettingsViewState> {

View File

@ -23,8 +23,5 @@ data class CrossSigningSettingsViewState(
val crossSigningInfo: MXCrossSigningInfo? = null, val crossSigningInfo: MXCrossSigningInfo? = null,
val xSigningIsEnableInAccount: Boolean = false, val xSigningIsEnableInAccount: Boolean = false,
val xSigningKeysAreTrusted: Boolean = false, val xSigningKeysAreTrusted: Boolean = false,
val xSigningKeyCanSign: Boolean = true, val xSigningKeyCanSign: Boolean = true
val deviceHasToBeVerified: Boolean = false,
val recoveryHasToBeSetUp: Boolean = false
) : MvRxState ) : MvRxState