-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent double Discard Changes dialog on Android back swipe gesture #17907
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,13 +96,16 @@ class InstantNoteEditorActivity : | |
private lateinit var singleTapLayout: LinearLayout | ||
private lateinit var singleTapLayoutTitle: FixedTextView | ||
|
||
private var isDialogShowing = false | ||
|
||
/** Gets the actual cloze field text value **/ | ||
private val clozeFieldText: String? | ||
get() = viewModel.actualClozeFieldText.value | ||
|
||
private val dialogBackCallback = | ||
object : OnBackPressedCallback(false) { | ||
override fun handleOnBackPressed() { | ||
if (isDialogShowing) return | ||
showDiscardChangesDialog() | ||
} | ||
} | ||
|
@@ -600,7 +603,11 @@ class InstantNoteEditorActivity : | |
} | ||
|
||
private fun showDiscardChangesDialog() { | ||
DiscardChangesDialog.showDialog(this) { | ||
isDialogShowing = true | ||
DiscardChangesDialog.showDialog(this, isCancellable = false, negativeMethod = { | ||
isDialogShowing = false | ||
}) { | ||
isDialogShowing = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can use dismiss listener There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @criticalAY , I've also asked some questions about the issue on Discord. I'll update this PR as soon as I receive some responses regarding the expectations, along with your suggestions. |
||
Timber.i("InstantNoteEditorActivity:: OK button pressed to confirm discard changes") | ||
finish() | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do the same without changing the original code here, I think that the Discard dialog should be kept simple