Special text for re-verification after update

This commit is contained in:
valere 2023-05-23 13:08:14 +02:00
parent bb09bee641
commit 27f9be5eda
7 changed files with 53 additions and 3 deletions

1
changelog.d/8445.bugfix Normal file
View File

@ -0,0 +1 @@
Fix: Update verification popup text when a re-verification is needed after rust migration (read only sessions)

View File

@ -2446,6 +2446,7 @@
</plurals> </plurals>
<string name="crosssigning_verify_this_session">Verify this device</string> <string name="crosssigning_verify_this_session">Verify this device</string>
<string name="crosssigning_verify_after_update">App updated</string>
<string name="crosssigning_cannot_verify_this_session">Unable to verify this device</string> <string name="crosssigning_cannot_verify_this_session">Unable to verify this device</string>
<string name="crosssigning_cannot_verify_this_session_desc">You wont be able to access encrypted message history. Reset your Secure Message Backup and verification keys to start fresh.</string> <string name="crosssigning_cannot_verify_this_session_desc">You wont be able to access encrypted message history. Reset your Secure Message Backup and verification keys to start fresh.</string>
@ -2707,6 +2708,7 @@
<string tools:ignore="UnusedResources" name="crosssigning_verify_session">Verify login</string> <string tools:ignore="UnusedResources" name="crosssigning_verify_session">Verify login</string>
<string name="cross_signing_verify_by_emoji">Interactively Verify by Emoji</string> <string name="cross_signing_verify_by_emoji">Interactively Verify by Emoji</string>
<string name="confirm_your_identity">Confirm your identity by verifying this login from one of your other sessions, granting it access to encrypted messages.</string> <string name="confirm_your_identity">Confirm your identity by verifying this login from one of your other sessions, granting it access to encrypted messages.</string>
<string name="confirm_your_identity_after_update">Secure messaging has been improved with the latest update. Please re-verify your device.</string>
<string name="confirm_your_identity_quad_s">Confirm your identity by verifying this login, granting it access to encrypted messages.</string> <string name="confirm_your_identity_quad_s">Confirm your identity by verifying this login, granting it access to encrypted messages.</string>
<string name="failed_to_initialize_cross_signing">Failed to set up Cross Signing</string> <string name="failed_to_initialize_cross_signing">Failed to set up Cross Signing</string>

View File

@ -29,6 +29,7 @@ import com.airbnb.mvrx.viewModel
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.BuildConfig
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.extensions.startSyncing import im.vector.app.core.extensions.startSyncing
import im.vector.app.core.extensions.vectorStore import im.vector.app.core.extensions.vectorStore
@ -170,6 +171,19 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
} }
private fun handleAppStarted() { private fun handleAppStarted() {
// On the first run with rust crypto this would be false
if (!vectorPreferences.isOnRustCrypto()) {
if (activeSessionHolder.hasActiveSession()) {
vectorPreferences.setHadExistingLegacyData(activeSessionHolder.getActiveSession().isOpenable)
} else {
vectorPreferences.setHadExistingLegacyData(false)
}
}
if (BuildConfig.FLAVOR == "rustCrypto") {
vectorPreferences.setIsOnRustCrypto(true)
}
if (intent.hasExtra(EXTRA_NEXT_INTENT)) { if (intent.hasExtra(EXTRA_NEXT_INTENT)) {
// Start the next Activity // Start the next Activity
startSyncing() startSyncing()

View File

@ -469,11 +469,21 @@ class HomeActivity :
private fun handleOnNewSession(event: HomeActivityViewEvents.CurrentSessionNotVerified) { private fun handleOnNewSession(event: HomeActivityViewEvents.CurrentSessionNotVerified) {
// We need to ask // We need to ask
val titleRes = if (event.afterMigration) {
R.string.crosssigning_verify_after_update
} else {
R.string.crosssigning_verify_this_session
}
val descRes = if (event.afterMigration) {
R.string.confirm_your_identity_after_update
} else {
R.string.confirm_your_identity
}
promptSecurityEvent( promptSecurityEvent(
uid = PopupAlertManager.VERIFY_SESSION_UID, uid = PopupAlertManager.VERIFY_SESSION_UID,
userItem = event.userItem, userItem = event.userItem,
titleRes = R.string.crosssigning_verify_this_session, titleRes = titleRes,
descRes = R.string.confirm_your_identity, descRes = descRes,
) { ) {
it.navigator.requestSelfSessionVerification(it) it.navigator.requestSelfSessionVerification(it)
} }

View File

@ -23,7 +23,7 @@ sealed interface HomeActivityViewEvents : VectorViewEvents {
data class AskPasswordToInitCrossSigning(val userItem: MatrixItem.UserItem) : HomeActivityViewEvents data class AskPasswordToInitCrossSigning(val userItem: MatrixItem.UserItem) : HomeActivityViewEvents
data class CurrentSessionNotVerified( data class CurrentSessionNotVerified(
val userItem: MatrixItem.UserItem, val userItem: MatrixItem.UserItem,
// val waitForIncomingRequest: Boolean = true, val afterMigration: Boolean
) : HomeActivityViewEvents ) : HomeActivityViewEvents
data class CurrentSessionCannotBeVerified( data class CurrentSessionCannotBeVerified(

View File

@ -453,6 +453,7 @@ class HomeActivityViewModel @AssistedInject constructor(
_viewEvents.post( _viewEvents.post(
HomeActivityViewEvents.CurrentSessionNotVerified( HomeActivityViewEvents.CurrentSessionNotVerified(
session.getUserOrDefault(session.myUserId).toMatrixItem(), session.getUserOrDefault(session.myUserId).toMatrixItem(),
vectorPreferences.isOnRustCrypto() && vectorPreferences.hadExistingLegacyData()
) )
) )
} else { } else {

View File

@ -254,6 +254,8 @@ class VectorPreferences @Inject constructor(
const val TAKE_PHOTO_VIDEO_MODE_PHOTO = 1 const val TAKE_PHOTO_VIDEO_MODE_PHOTO = 1
const val TAKE_PHOTO_VIDEO_MODE_VIDEO = 2 const val TAKE_PHOTO_VIDEO_MODE_VIDEO = 2
const val HAD_EXISTING_LEGACY_DATA = "HAD_EXISTING_LEGACY_DATA"
const val IS_ON_RUST_CRYPTO = "IS_ON_RUST_CRYPTO"
// Background sync modes // Background sync modes
// some preferences keys must be kept after a logout // some preferences keys must be kept after a logout
@ -1278,4 +1280,24 @@ class VectorPreferences @Inject constructor(
putBoolean(SETTINGS_NEW_LOGIN_ALERT_SHOWN_FOR_DEVICE + deviceId, true) putBoolean(SETTINGS_NEW_LOGIN_ALERT_SHOWN_FOR_DEVICE + deviceId, true)
} }
} }
fun hadExistingLegacyData(): Boolean {
return defaultPrefs.getBoolean(HAD_EXISTING_LEGACY_DATA, false)
}
fun setHadExistingLegacyData(had: Boolean) {
defaultPrefs.edit {
putBoolean(HAD_EXISTING_LEGACY_DATA, had)
}
}
fun isOnRustCrypto(): Boolean {
return defaultPrefs.getBoolean(IS_ON_RUST_CRYPTO, false)
}
fun setIsOnRustCrypto(boolean: Boolean) {
defaultPrefs.edit {
putBoolean(IS_ON_RUST_CRYPTO, boolean)
}
}
} }