Skip to content

Commit

Permalink
Merge pull request #601 from Automattic/fix/update-error-dialog
Browse files Browse the repository at this point in the history
Add hideCancel flag to FrameSaveErrorDialog
  • Loading branch information
mzorz authored Nov 4, 2020
2 parents 179b016 + a1c5a80 commit 8093946
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ class FrameSaveErrorDialog : DialogFragment() {
.setMessage(arguments?.getString(ARG_MESSAGE))

okListener?.let {
builder.setNegativeButton(android.R.string.cancel) { _, _ -> dismiss() }
val hideCancel = arguments?.getBoolean(ARG_HIDE_CANCEL) ?: false
if (!hideCancel) {
builder.setNegativeButton(android.R.string.cancel) { _, _ -> dismiss() }
}
builder.setPositiveButton(
arguments?.getString(ARG_OK_LABEL) ?: activity?.getString(android.R.string.ok)) {
_, _ -> okListener?.OnOkClicked(this)
Expand All @@ -33,18 +36,21 @@ class FrameSaveErrorDialog : DialogFragment() {
@JvmStatic private val ARG_MESSAGE = "message"
@JvmStatic private val ARG_TITLE = "title"
@JvmStatic private val ARG_OK_LABEL = "ok_label"
@JvmStatic private val ARG_HIDE_CANCEL = "hide_cancel"

@JvmStatic fun newInstance(
title: String,
message: String,
okButtonLabel: String? = null,
listener: FrameSaveErrorDialogOk? = null
listener: FrameSaveErrorDialogOk? = null,
hideCancelButton: Boolean = false
): FrameSaveErrorDialog =
FrameSaveErrorDialog().apply {
arguments = Bundle().apply {
putString(ARG_TITLE, title)
putString(ARG_MESSAGE, message)
putString(ARG_OK_LABEL, okButtonLabel)
putBoolean(ARG_HIDE_CANCEL, hideCancelButton)
}
okListener = listener
}
Expand Down

0 comments on commit 8093946

Please sign in to comment.