Merge pull request #1906 from vector-im/feature/verify_developer_mode

Cleanup temporary code added during developpement
This commit is contained in:
Benoit Marty 2020-08-17 16:32:28 +02:00 committed by GitHub
commit 1b9b18851d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 20 additions and 130 deletions

View file

@ -44,9 +44,7 @@ enum class Command(val command: String, val parameters: String, @StringRes val d
POLL("/poll", "Question | Option 1 | Option 2 ...", R.string.command_description_poll),
SHRUG("/shrug", "<message>", R.string.command_description_shrug),
PLAIN("/plain", "<message>", R.string.command_description_plain),
DISCARD_SESSION("/discardsession", "", R.string.command_description_discard_session),
// TODO temporary command
VERIFY_USER("/verify", "<user-id>", R.string.command_description_verify);
DISCARD_SESSION("/discardsession", "", R.string.command_description_discard_session);
val length
get() = command.length + 1

View file

@ -279,11 +279,6 @@ object CommandParser {
ParsedCommand.SendShrug(message)
}
Command.VERIFY_USER.command -> {
val message = textMessage.substring(Command.VERIFY_USER.command.length).trim()
ParsedCommand.VerifyUser(message)
}
Command.POLL.command -> {
val rawCommand = textMessage.substring(Command.POLL.command.length).trim()
val split = rawCommand.split("|").map { it.trim() }

View file

@ -53,7 +53,6 @@ sealed class ParsedCommand {
object ClearScalarToken : ParsedCommand()
class SendSpoiler(val message: String) : ParsedCommand()
class SendShrug(val message: CharSequence) : ParsedCommand()
class VerifyUser(val userId: String) : ParsedCommand()
class SendPoll(val question: String, val options: List<String>) : ParsedCommand()
object DiscardSession: ParsedCommand()
}

View file

@ -656,14 +656,6 @@ class RoomDetailViewModel @AssistedInject constructor(
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())
popDraft()
}
is ParsedCommand.VerifyUser -> {
session
.cryptoService()
.verificationService()
.requestKeyVerificationInDMs(supportedVerificationMethodsProvider.provide(), slashCommandResult.userId, room.roomId)
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())
popDraft()
}
is ParsedCommand.SendPoll -> {
room.sendPoll(slashCommandResult.question, slashCommandResult.options.mapIndexed { index, s -> OptionItem(s, "$index. $s") })
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())

View file

@ -305,6 +305,10 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
}
mCrossSigningStatePreference.isVisible = true
if (!vectorPreferences.developerMode()) {
// When not in developer mode, intercept click on this preference
mCrossSigningStatePreference.onPreferenceClickListener = Preference.OnPreferenceClickListener { true }
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

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

@ -29,6 +29,9 @@ import im.vector.app.core.platform.VectorBaseFragment
import kotlinx.android.synthetic.main.fragment_generic_recycler.*
import javax.inject.Inject
/**
* This Fragment is only used when user activates developer mode from the settings
*/
class CrossSigningSettingsFragment @Inject constructor(
private val controller: CrossSigningSettingsController,
val viewModelFactory: CrossSigningSettingsViewModel.Factory
@ -50,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
}
}
@ -87,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

View file

@ -1909,7 +1909,6 @@ Vaši e-mailovou adresu můžete přidat k profilu v nastavení.</string>
<string name="settings_developer_mode_fail_fast_title">Fail-fast</string>
<string name="settings_developer_mode_fail_fast_summary">Element se může zbořit častěji, když se objeví neočekávané chyby</string>
<string name="command_description_verify">Požadavek ověření daného uživatelského ID</string>
<string name="command_description_shrug">Předsune ¯\\_(ツ)_/¯ do textové zprávy</string>
<string name="create_room_encryption_title">Zapnout šifrování</string>

View file

@ -1987,7 +1987,6 @@ Verwahre deinen Wiederherstellungsschlüssel an einem sehr sicheren Ort wie eine
<string name="settings_developer_mode_fail_fast_title">Ausfallsicher</string>
<string name="settings_developer_mode_fail_fast_summary">Element kann häufiger abstürzen, wenn ein unerwarteter Fehler auftritt</string>
<string name="command_description_verify">Überprüfe die angegebenen Nutzer-ID</string>
<string name="command_description_shrug">Stellt einer Klartextnachricht ¯\\_(ツ)_/¯ voran</string>
<string name="create_room_encryption_title">Aktiviere Verschlüsselung</string>

View file

@ -1929,7 +1929,6 @@ Abisua: Fitxategi hau ezabatu daiteke aplikazioa desinstalatzen bada.</string>
<string name="settings_developer_mode_fail_fast_title">Hutsegin-azkar</string>
<string name="settings_developer_mode_fail_fast_summary">Element aplikazioa ustekabeko erroreen aurrean maizago kraskatu daiteke</string>
<string name="command_description_verify">Eskatu emandako erabiltzaile IDa egiaztatzea</string>
<string name="command_description_shrug">"Jarri ¯\\_(ツ)_/¯ testu-soileko mezuaren aurretik"</string>
<string name="create_room_encryption_title">Gaitu zifratzea</string>

View file

@ -2016,7 +2016,6 @@ Haluatko lisätä paketteja?</string>
<string name="verification_conclusion_not_secure">Ei turvallinen</string>
<string name="sent_a_video">Video.</string>
<string name="sent_an_image">Kuva.</string>
<string name="command_description_verify">Pyyntö annetun käyttäjä-ID:n vahvistamiseksi</string>
<string name="verification_conclusion_compromised">Johonkin näistä on mahdollisesti murtauduttu:
\n
\n - Kotipalvelimesi

View file

@ -1933,7 +1933,6 @@ Si vous navez pas configuré de nouvelle méthode de récupération, un attaq
<string name="settings_developer_mode_fail_fast_title">Défaillance rapide</string>
<string name="settings_developer_mode_fail_fast_summary">Element peut planter plus souvent quand une erreur inattendue survient</string>
<string name="command_description_verify">Demande de vérification de lidentifiant utilisateur fourni</string>
<string name="command_description_shrug">Préfixe ¯\\_(ツ)_/¯ à un message en texte brut</string>
<string name="create_room_encryption_title">Activer le chiffrement</string>

View file

@ -1930,7 +1930,6 @@ Ha nem te állítottad be a visszaállítási metódust, akkor egy támadó pró
<string name="settings_developer_mode_fail_fast_title">Összeomlás-hamar</string>
<string name="settings_developer_mode_fail_fast_summary">Element a nem várt hibák esetén többször fog összeomlani</string>
<string name="command_description_verify">Az adott felhasználói azonosító ellenőrzésének kérése</string>
<string name="command_description_shrug">Hozzáteszi a sima szöveges üzenethez ezt: ¯\\_(ツ)_/¯</string>
<string name="create_room_encryption_title">Titkosítás engedélyezése</string>

View file

@ -1981,7 +1981,6 @@
<string name="settings_developer_mode_fail_fast_title">Crash facile</string>
<string name="settings_developer_mode_fail_fast_summary">Element potrebbe crashare più spesso quando si verifica un errore imprevisto</string>
<string name="command_description_verify">Richiedi di verificare l\'ID utente in questione</string>
<string name="command_description_shrug">Antepone ¯\\_(ツ)_/¯ ad un messaggio testuale</string>
<string name="create_room_encryption_title">Attiva la cifratura</string>

View file

@ -1915,7 +1915,6 @@ Spróbuj uruchomić ponownie aplikację.</string>
<string name="settings_developer_mode_fail_fast_title">Bezproblemowy</string>
<string name="settings_developer_mode_fail_fast_summary">Element może zawieszać się częściej gdy napotka na niespodziewany błąd</string>
<string name="command_description_verify">Żądanie weryfikujące podany userID</string>
<string name="command_description_shrug">Preparuje ¯\\_(ツ)_/¯ dla zwykłej wiadomości tekstowej</string>
<string name="create_room_encryption_title">Aktywuj szyfrowanie</string>

View file

@ -2112,7 +2112,6 @@ Na próxima tela, você será solicitado a permitir que o Element funcione sempr
<string name="settings_developer_mode_fail_fast_title">Relatar imediatamente as falhas</string>
<string name="settings_developer_mode_fail_fast_summary">Element pode quebrar com mais freqüência quando ocorre um erro inesperado</string>
<string name="command_description_verify">Solicitação para verificar o ID do usuário</string>
<string name="command_description_shrug">Adicionar ¯\\_(ツ)_/¯ para uma mensagem de texto simples</string>
<string name="create_room_encryption_title">Ativar criptografia</string>

View file

@ -2214,7 +2214,6 @@
<string name="settings_developer_mode_fail_fast_title">Раннее падение</string>
<string name="settings_developer_mode_fail_fast_summary">Element может падать чаще, когда происходит непредвиденная ошибка</string>
<string name="command_description_verify">Запрос на проверку данного идентификатора пользователя</string>
<string name="command_description_shrug">Добавляет смайл ¯\\_(ツ)_/¯ в начало сообщения</string>
<string name="create_room_encryption_description">После включения шифрования оно не может быть отключено.</string>

View file

@ -1890,7 +1890,6 @@
<string name="settings_developer_mode_fail_fast_summary">Element mund të vithiset më shpesh, kur ndodh një gabim i papritur</string>
<string name="settings_call_ringtone_use_default_stun">Lejoni shërbyes rrugëzgjidhje asistimi thirrjesh</string>
<string name="command_description_verify">Kërko të verifikohet userID-ja i dhënë</string>
<string name="command_description_shrug">Parashtoji ¯\\_(ツ)_/¯ një mesazhi tekst të thjeshtë</string>
<string name="create_room_encryption_title">Aktivizoni fshehtëzim</string>

View file

@ -2020,7 +2020,6 @@ Element 在后台时的工作将被显著的限制,这可能会影响消息通
<string name="settings_developer_mode_fail_fast_title">快速失败</string>
<string name="settings_developer_mode_fail_fast_summary">发生意外错误时Element 可能更经常崩溃</string>
<string name="command_description_verify">请求验证给定 userID</string>
<string name="command_description_shrug">在明文消息前添加 ¯\\_(ツ)_/¯</string>
<string name="create_room_encryption_title">启用加密</string>

View file

@ -1884,7 +1884,6 @@ Matrix 中的消息可見度類似于電子郵件。我們忘記您的郵件意
<string name="settings_developer_mode_fail_fast_title">快速失敗</string>
<string name="settings_developer_mode_fail_fast_summary">在發生非預期的錯誤時Element 可能更常當機</string>
<string name="command_description_verify">請求驗證給定的 userID</string>
<string name="command_description_shrug">"將 ¯\\_(ツ)_/¯ 附加到純文字訊息中"</string>
<string name="create_room_encryption_title">啟用加密</string>

View file

@ -2022,7 +2022,6 @@
<string name="settings_developer_mode_fail_fast_title">Fail-fast</string>
<string name="settings_developer_mode_fail_fast_summary">Element may crash more often when an unexpected error occurs</string>
<string name="command_description_verify">Request to verify the given userID</string>
<string name="command_description_shrug">Prepends ¯\\_(ツ)_/¯ to a plain-text message</string>
<string name="create_room_encryption_title">"Enable encryption"</string>

View file

@ -17,6 +17,7 @@
<im.vector.app.core.preference.VectorPreferenceCategory
android:key="SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY"
android:title="@string/settings_cryptography">
<im.vector.app.core.preference.VectorPreference
android:key="SETTINGS_ENCRYPTION_CROSS_SIGNING_PREFERENCE_KEY"
android:persistent="false"