Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
The dialog shouldn't automatically dismiss when the user clicks details.
Browse files Browse the repository at this point in the history
They may not have read the dialog message completely or want to re-read it.
  • Loading branch information
d4rken committed Oct 20, 2020
1 parent 557adc4 commit e4e2280
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MainFragment : Fragment(R.layout.fragment_main) {
if (errorResetTool.isResetNoticeToBeShown) {
RecoveryByResetDialogFactory(this).showDialog(
detailsLink = R.string.errors_generic_text_catastrophic_error_encryption_failure,
onDismiss = {
onPositive = {
errorResetTool.isResetNoticeToBeShown = false
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ class RecoveryByResetDialogFactory(private val fragment: Fragment) {

fun showDialog(
@StringRes detailsLink: Int,
onDismiss: () -> Unit
onPositive: () -> Unit
) {
AlertDialog.Builder(context)
val dialog = AlertDialog.Builder(context)
.setTitle(R.string.errors_generic_headline)
.setMessage(R.string.errors_generic_text_catastrophic_error_recovery_via_reset)
.setCancelable(false)
.setOnDismissListener { onDismiss() }
.setNeutralButton(R.string.errors_generic_button_negative) { _, _ ->
ExternalActionHelper.openUrl(fragment, context.getString(detailsLink))
.setNeutralButton(R.string.errors_generic_button_negative, null)
.setPositiveButton(R.string.errors_generic_button_positive) { _, _ ->
onPositive()
}
.setPositiveButton(R.string.errors_generic_button_positive) { _, _ -> }
.show()
.create()
dialog.show()
dialog.getButton(AlertDialog.BUTTON_NEUTRAL)?.setOnClickListener {
ExternalActionHelper.openUrl(fragment, context.getString(detailsLink))
}
}
}

0 comments on commit e4e2280

Please sign in to comment.