From ce2f4e163dde7aae2acc616fe7a6fa209a3dd0c5 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 16 Apr 2020 16:16:07 +0200 Subject: [PATCH 1/4] Update password/recovery copy + update icons --- .../crypto/recover/BootstrapBottomSheet.kt | 23 ++++++++++++------- .../recover/BootstrapMigrateBackupFragment.kt | 18 +++++++-------- .../src/main/res/drawable/ic_message_key.xml | 7 ++---- .../main/res/drawable/ic_message_password.xml | 7 ++---- vector/src/main/res/values/strings.xml | 6 ++--- vector/src/main/res/values/strings_riotX.xml | 9 ++++++++ 6 files changed, 39 insertions(+), 31 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt index 60490fc812..26c8ed25f9 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt @@ -122,43 +122,50 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment() { override fun invalidate() = withState(viewModel) { state -> when (state.step) { - is BootstrapStep.CheckingMigration -> { + is BootstrapStep.CheckingMigration -> { bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_message_password)) bootstrapTitleText.text = getString(R.string.upgrade_security) showFragment(BootstrapWaitingFragment::class, Bundle()) } - is BootstrapStep.SetupPassphrase -> { + is BootstrapStep.SetupPassphrase -> { bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_message_password)) bootstrapTitleText.text = getString(R.string.set_recovery_passphrase, getString(R.string.recovery_passphrase)) showFragment(BootstrapEnterPassphraseFragment::class, Bundle()) } - is BootstrapStep.ConfirmPassphrase -> { + is BootstrapStep.ConfirmPassphrase -> { bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_message_password)) bootstrapTitleText.text = getString(R.string.confirm_recovery_passphrase, getString(R.string.recovery_passphrase)) showFragment(BootstrapConfirmPassphraseFragment::class, Bundle()) } - is BootstrapStep.AccountPassword -> { + is BootstrapStep.AccountPassword -> { bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_user)) bootstrapTitleText.text = getString(R.string.account_password) showFragment(BootstrapAccountPasswordFragment::class, Bundle()) } - is BootstrapStep.Initializing -> { + is BootstrapStep.Initializing -> { bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_message_key)) bootstrapTitleText.text = getString(R.string.bootstrap_loading_title) showFragment(BootstrapWaitingFragment::class, Bundle()) } - is BootstrapStep.SaveRecoveryKey -> { + is BootstrapStep.SaveRecoveryKey -> { bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_message_key)) bootstrapTitleText.text = getString(R.string.keys_backup_setup_step3_please_make_copy) showFragment(BootstrapSaveRecoveryKeyFragment::class, Bundle()) } - is BootstrapStep.DoneSuccess -> { + is BootstrapStep.DoneSuccess -> { bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_message_key)) bootstrapTitleText.text = getString(R.string.bootstrap_finish_title) showFragment(BootstrapConclusionFragment::class, Bundle()) } is BootstrapStep.GetBackupSecretForMigration -> { - bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.key_small)) + val isKey = when (state.step) { + is BootstrapStep.GetBackupSecretPassForMigration -> state.step.useKey + else -> true + } + bootstrapIcon.setImageDrawable(ContextCompat.getDrawable( + requireContext(), + R.drawable.ic_message_key.takeIf { isKey } ?: R.drawable.ic_message_password) + ) bootstrapTitleText.text = getString(R.string.upgrade_security) showFragment(BootstrapMigrateBackupFragment::class, Bundle()) } diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapMigrateBackupFragment.kt b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapMigrateBackupFragment.kt index 844a16977c..589f397864 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapMigrateBackupFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapMigrateBackupFragment.kt @@ -125,7 +125,8 @@ class BootstrapMigrateBackupFragment @Inject constructor( val secret = bootstrapMigrateEditText.text?.toString() if (secret.isNullOrBlank()) { - bootstrapRecoveryKeyEnterTil.error = getString(R.string.passphrase_empty_error_message) + bootstrapRecoveryKeyEnterTil.error = getString(R.string.recovery_key_empty_error_message).takeIf { isEnteringKey } + ?: getString(R.string.passphrase_empty_error_message) } else if (isEnteringKey && !isValidRecoveryKey(secret)) { bootstrapRecoveryKeyEnterTil.error = getString(R.string.bootstrap_invalid_recovery_key) } else { @@ -153,14 +154,14 @@ class BootstrapMigrateBackupFragment @Inject constructor( bootstrapMigrateShowPassword.isVisible = false bootstrapMigrateEditText.inputType = TYPE_CLASS_TEXT or TYPE_TEXT_VARIATION_VISIBLE_PASSWORD or TYPE_TEXT_FLAG_MULTI_LINE - val recKey = getString(R.string.recovery_key) + val recKey = getString(R.string.bootstrap_migration_backup_recovery_key) bootstrapDescriptionText.text = getString(R.string.enter_account_password, recKey) .toSpannable() .colorizeMatchingText(recKey, colorProvider.getColorFromAttribute(android.R.attr.textColorLink)) bootstrapMigrateEditText.hint = recKey - bootstrapMigrateEditText.hint = getString(R.string.keys_backup_restore_key_enter_hint) + bootstrapMigrateEditText.hint = recKey bootstrapMigrateForgotPassphrase.isVisible = false bootstrapMigrateUseFile.isVisible = true } else { @@ -172,19 +173,16 @@ class BootstrapMigrateBackupFragment @Inject constructor( bootstrapMigrateShowPassword.setImageResource(if (isPasswordVisible) R.drawable.ic_eye_closed_black else R.drawable.ic_eye_black) } - val recPassPhrase = getString(R.string.backup_recovery_passphrase) - bootstrapDescriptionText.text = getString(R.string.enter_account_password, recPassPhrase) - .toSpannable() - .colorizeMatchingText(recPassPhrase, colorProvider.getColorFromAttribute(android.R.attr.textColorLink)) + bootstrapDescriptionText.text = getString(R.string.bootstrap_migration_enter_backup_password) bootstrapMigrateEditText.hint = getString(R.string.passphrase_enter_passphrase) bootstrapMigrateForgotPassphrase.isVisible = true - val recKeye = getString(R.string.keys_backup_restore_use_recovery_key) - bootstrapMigrateForgotPassphrase.text = getString(R.string.keys_backup_restore_with_passphrase_helper_with_link, recKeye) + val recKey = getString(R.string.bootstrap_migration_use_recovery_key) + bootstrapMigrateForgotPassphrase.text = getString(R.string.bootstrap_migration_with_passphrase_helper_with_link, recKey) .toSpannable() - .colorizeMatchingText(recKeye, colorProvider.getColorFromAttribute(android.R.attr.textColorLink)) + .colorizeMatchingText(recKey, colorProvider.getColorFromAttribute(android.R.attr.textColorLink)) bootstrapMigrateUseFile.isVisible = false } diff --git a/vector/src/main/res/drawable/ic_message_key.xml b/vector/src/main/res/drawable/ic_message_key.xml index c4a415477b..9c5e53571d 100644 --- a/vector/src/main/res/drawable/ic_message_key.xml +++ b/vector/src/main/res/drawable/ic_message_key.xml @@ -7,13 +7,10 @@ + android:strokeColor="#2E2F32"/> + android:strokeColor="#2E2F32"/> Verify your devices from Settings. Verification Cancelled - Message Password + Recovery Passphrase Message Key Account Password @@ -2269,8 +2269,8 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming You cannot do that from mobile - Setting a Message Password lets you secure & unlock encrypted messages and trust.\n\nIf you don’t want to set a Message Password, generate a Message Key instead. - Setting a Message Password lets you secure & unlock encrypted messages and trust. + Setting a Recovery Passphrase lets you secure & unlock encrypted messages and trust.\n\nIf you don’t want to set a Message Password, generate a Message Key instead. + Setting a Recovery Passphrase lets you secure & unlock encrypted messages and trust. Encryption enabled diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index 90496c351d..9d9d3deb07 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -20,6 +20,7 @@ Enter %s Recovery Passphrase "It's not a valid recovery key" + Please enter a recovery key Checking backup Key Checking backup Key (%s) @@ -30,6 +31,14 @@ Storing keybackup secret in SSSS %1$s (%2$s) + + + Enter your Key Backup Passphrase to continue. + use your Key Backup recovery key + + Don’t know your Key Backup Passphrase, you can %s. + Key Backup recovery key + From 7ac5f58f320d73c0c37b9273092f672f03682db2 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 16 Apr 2020 16:30:25 +0200 Subject: [PATCH 2/4] Show CrossSigning info even if not developer mode --- .../VectorSettingsSecurityPrivacyFragment.kt | 27 ------------ .../CrossSigningEpoxyController.kt | 44 +++++++++++-------- .../xml/vector_settings_security_privacy.xml | 4 +- 3 files changed, 26 insertions(+), 49 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt index 9beeea0278..bb83658ae7 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt @@ -58,23 +58,10 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( override var titleRes = R.string.settings_security_and_privacy override val preferenceXmlRes = R.xml.vector_settings_security_privacy - // devices: device IDs and device names - private val mDevicesNameList: MutableList = mutableListOf() - - private var mMyDeviceInfo: DeviceInfo? = null - // cryptography private val mCryptographyCategory by lazy { findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY)!! } - // cryptography manage - private val mCryptographyManageCategory by lazy { - findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY)!! - } - // displayed pushers - private val mPushersSettingsCategory by lazy { - findPreference(VectorPreferences.SETTINGS_NOTIFICATIONS_TARGETS_PREFERENCE_KEY)!! - } private val mCrossSigningStatePreference by lazy { findPreference(VectorPreferences.SETTINGS_ENCRYPTION_CROSS_SIGNING_PREFERENCE_KEY)!! @@ -106,7 +93,6 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( // My device name may have been updated refreshMyDevice() refreshXSigningStatus() - mCryptographyCategory.isVisible = vectorPreferences.developerMode() } override fun bindPref() { @@ -133,7 +119,6 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( } private fun refreshXSigningStatus() { - if (vectorPreferences.developerMode()) { val crossSigningKeys = session.cryptoService().crossSigningService().getMyCrossSigningKeys() val xSigningIsEnableInAccount = crossSigningKeys != null val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified() @@ -154,9 +139,6 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( } mCrossSigningStatePreference.isVisible = true - } else { - mCrossSigningStatePreference.isVisible = false - } } override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { @@ -349,15 +331,6 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( // Cryptography // ============================================================================================================== - private fun removeCryptographyPreference() { - preferenceScreen.let { - it.removePreference(mCryptographyCategory) - - // Also remove keys management section - it.removePreference(mCryptographyManageCategory) - } - } - /** * Build the cryptography preference section. * diff --git a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt index e33b12d19a..dd050c29ac 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt @@ -24,13 +24,15 @@ import im.vector.riotx.core.ui.list.genericItem import im.vector.riotx.core.ui.list.genericItemWithValue import im.vector.riotx.core.utils.DimensionConverter import im.vector.riotx.features.crypto.verification.epoxy.bottomSheetVerificationActionItem +import im.vector.riotx.features.settings.VectorPreferences import me.gujun.android.span.span import javax.inject.Inject class CrossSigningEpoxyController @Inject constructor( private val stringProvider: StringProvider, private val colorProvider: ColorProvider, - private val dimensionConverter: DimensionConverter + private val dimensionConverter: DimensionConverter, + private val vectorPreferences: VectorPreferences ) : TypedEpoxyController() { interface InteractionListener { @@ -49,7 +51,7 @@ class CrossSigningEpoxyController @Inject constructor( titleIconResourceId(R.drawable.ic_shield_trusted) title(stringProvider.getString(R.string.encryption_information_dg_xsigning_complete)) } - if (!data.isUploadingKeys) { + if (vectorPreferences.developerMode() && !data.isUploadingKeys) { bottomSheetVerificationActionItem { id("resetkeys") title("Reset keys") @@ -68,14 +70,16 @@ class CrossSigningEpoxyController @Inject constructor( title(stringProvider.getString(R.string.encryption_information_dg_xsigning_trusted)) } if (!data.isUploadingKeys) { - bottomSheetVerificationActionItem { - id("resetkeys") - title("Reset keys") - titleColor(colorProvider.getColor(R.color.riotx_destructive_accent)) - iconRes(R.drawable.ic_arrow_right) - iconColor(colorProvider.getColor(R.color.riotx_destructive_accent)) - listener { - interactionListener?.onResetCrossSigningKeys() + if (vectorPreferences.developerMode()) { + bottomSheetVerificationActionItem { + id("resetkeys") + title("Reset keys") + titleColor(colorProvider.getColor(R.color.riotx_destructive_accent)) + iconRes(R.drawable.ic_arrow_right) + iconColor(colorProvider.getColor(R.color.riotx_destructive_accent)) + listener { + interactionListener?.onResetCrossSigningKeys() + } } } @@ -106,14 +110,16 @@ class CrossSigningEpoxyController @Inject constructor( interactionListener?.verifySession() } } - bottomSheetVerificationActionItem { - id("resetkeys") - title("Reset keys") - titleColor(colorProvider.getColor(R.color.riotx_destructive_accent)) - iconRes(R.drawable.ic_arrow_right) - iconColor(colorProvider.getColor(R.color.riotx_destructive_accent)) - listener { - interactionListener?.onResetCrossSigningKeys() + if (vectorPreferences.developerMode()) { + bottomSheetVerificationActionItem { + id("resetkeys") + title("Reset keys") + titleColor(colorProvider.getColor(R.color.riotx_destructive_accent)) + iconRes(R.drawable.ic_arrow_right) + iconColor(colorProvider.getColor(R.color.riotx_destructive_accent)) + listener { + interactionListener?.onResetCrossSigningKeys() + } } } } else { @@ -121,7 +127,7 @@ class CrossSigningEpoxyController @Inject constructor( id("not") title(stringProvider.getString(R.string.encryption_information_dg_xsigning_disabled)) } - if (!data.isUploadingKeys) { + if (vectorPreferences.developerMode() && !data.isUploadingKeys) { bottomSheetVerificationActionItem { id("initKeys") title("Initialize keys") diff --git a/vector/src/main/res/xml/vector_settings_security_privacy.xml b/vector/src/main/res/xml/vector_settings_security_privacy.xml index 1002c16782..f394e319c7 100644 --- a/vector/src/main/res/xml/vector_settings_security_privacy.xml +++ b/vector/src/main/res/xml/vector_settings_security_privacy.xml @@ -6,9 +6,7 @@ + android:title="@string/settings_cryptography"> Date: Thu, 16 Apr 2020 16:53:24 +0200 Subject: [PATCH 3/4] Update vector/src/main/res/values/strings_riotX.xml Co-Authored-By: Benoit Marty --- vector/src/main/res/values/strings_riotX.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index 9d9d3deb07..a7da659b2d 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -35,7 +35,7 @@ Enter your Key Backup Passphrase to continue. use your Key Backup recovery key - + Don’t know your Key Backup Passphrase, you can %s. Key Backup recovery key From 3fe15f2d45938802cb2bf0fc277b977903d003d6 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 16 Apr 2020 17:02:01 +0200 Subject: [PATCH 4/4] code review --- .../riotx/features/crypto/recover/BootstrapBottomSheet.kt | 3 ++- .../features/crypto/recover/BootstrapMigrateBackupFragment.kt | 4 ++-- vector/src/main/res/values/strings_riotX.xml | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt index 26c8ed25f9..e48c674159 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt @@ -162,9 +162,10 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment() { is BootstrapStep.GetBackupSecretPassForMigration -> state.step.useKey else -> true } + val drawableRes = if (isKey) R.drawable.ic_message_key else R.drawable.ic_message_password bootstrapIcon.setImageDrawable(ContextCompat.getDrawable( requireContext(), - R.drawable.ic_message_key.takeIf { isKey } ?: R.drawable.ic_message_password) + drawableRes) ) bootstrapTitleText.text = getString(R.string.upgrade_security) showFragment(BootstrapMigrateBackupFragment::class, Bundle()) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapMigrateBackupFragment.kt b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapMigrateBackupFragment.kt index 589f397864..f1847e5ab5 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapMigrateBackupFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapMigrateBackupFragment.kt @@ -125,8 +125,8 @@ class BootstrapMigrateBackupFragment @Inject constructor( val secret = bootstrapMigrateEditText.text?.toString() if (secret.isNullOrBlank()) { - bootstrapRecoveryKeyEnterTil.error = getString(R.string.recovery_key_empty_error_message).takeIf { isEnteringKey } - ?: getString(R.string.passphrase_empty_error_message) + val errRes = if (isEnteringKey) R.string.recovery_key_empty_error_message else R.string.passphrase_empty_error_message + bootstrapRecoveryKeyEnterTil.error = getString(errRes) } else if (isEnteringKey && !isValidRecoveryKey(secret)) { bootstrapRecoveryKeyEnterTil.error = getString(R.string.bootstrap_invalid_recovery_key) } else { diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index a7da659b2d..2cd97098af 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -32,7 +32,6 @@ %1$s (%2$s) - Enter your Key Backup Passphrase to continue. use your Key Backup recovery key