Merge pull request #8462 from vector-im/feature/bca/fix_8445

Special text for re-verification after update
This commit is contained in:
Valere 2023-05-24 10:10:52 +02:00 committed by GitHub
commit 6da05a3804
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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>
<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_desc">You wont be able to access encrypted message history. Reset your Secure Message Backup and verification keys to start fresh.</string>
@ -2709,6 +2710,7 @@
<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="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="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.google.android.material.dialog.MaterialAlertDialogBuilder
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.BuildConfig
import im.vector.app.R
import im.vector.app.core.extensions.startSyncing
import im.vector.app.core.extensions.vectorStore
@ -170,6 +171,19 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
}
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)) {
// Start the next Activity
startSyncing()

View file

@ -469,11 +469,21 @@ class HomeActivity :
private fun handleOnNewSession(event: HomeActivityViewEvents.CurrentSessionNotVerified) {
// 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(
uid = PopupAlertManager.VERIFY_SESSION_UID,
userItem = event.userItem,
titleRes = R.string.crosssigning_verify_this_session,
descRes = R.string.confirm_your_identity,
titleRes = titleRes,
descRes = descRes,
) {
it.navigator.requestSelfSessionVerification(it)
}

View file

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

View file

@ -453,6 +453,7 @@ class HomeActivityViewModel @AssistedInject constructor(
_viewEvents.post(
HomeActivityViewEvents.CurrentSessionNotVerified(
session.getUserOrDefault(session.myUserId).toMatrixItem(),
vectorPreferences.isOnRustCrypto() && vectorPreferences.hadExistingLegacyData()
)
)
} 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_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
// 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)
}
}
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)
}
}
}