Show settings button in backup key save error dialog only when password manager settings are accessible.

To prevent crashes when the "go to settings" button is clicked in the backup key save to password manager error dialog, the "go to settings" button will only be displayed in cases where the intent resolves successfully.
This commit is contained in:
jeffrey-signal
2025-07-08 10:24:26 -04:00
committed by Alex Hart
parent 177504a897
commit ef874c4091
3 changed files with 63 additions and 42 deletions

View File

@@ -29,20 +29,19 @@ class BackupKeyDisplayFragment : ComposeFragment() {
@Composable
override fun FragmentContent() {
val state by viewModel.uiState.collectAsStateWithLifecycle()
val passwordManagerSettingsIntent = BackupKeyCredentialManagerHandler.getCredentialManagerSettingsIntent(requireContext())
MessageBackupsKeyRecordScreen(
backupKey = SignalStore.account.accountEntropyPool.displayValue,
keySaveState = state.keySaveState,
canOpenPasswordManagerSettings = passwordManagerSettingsIntent != null,
onNavigationClick = { findNavController().popBackStack() },
onCopyToClipboardClick = { Util.copyToClipboard(requireContext(), it, CLIPBOARD_TIMEOUT_SECONDS) },
onRequestSaveToPasswordManager = viewModel::onBackupKeySaveRequested,
onConfirmSaveToPasswordManager = viewModel::onBackupKeySaveConfirmed,
onSaveToPasswordManagerComplete = viewModel::onBackupKeySaveCompleted,
onNextClick = { findNavController().popBackStack() },
onGoToDeviceSettingsClick = {
val intent = BackupKeyCredentialManagerHandler.getCredentialManagerSettingsIntent(requireContext())
requireContext().startActivity(intent)
}
onGoToPasswordManagerSettingsClick = { requireContext().startActivity(passwordManagerSettingsIntent) }
)
}
}