allow exiting the Event screen with unsaved changes by spamming Back

This commit is contained in:
tibbi 2020-09-28 15:53:52 +02:00
parent f5a602863f
commit 35d60d8027

View File

@ -79,6 +79,7 @@ class EventActivity : SimpleActivity() {
private var mEventTypeId = REGULAR_EVENT_TYPE_ID private var mEventTypeId = REGULAR_EVENT_TYPE_ID
private var mDialogTheme = 0 private var mDialogTheme = 0
private var mEventOccurrenceTS = 0L private var mEventOccurrenceTS = 0L
private var mLastSavePromptTS = 0L
private var mEventCalendarId = STORED_LOCALLY_ONLY private var mEventCalendarId = STORED_LOCALLY_ONLY
private var mWasActivityInitialized = false private var mWasActivityInitialized = false
private var mWasContactsPermissionChecked = false private var mWasContactsPermissionChecked = false
@ -303,7 +304,8 @@ class EventActivity : SimpleActivity() {
} }
override fun onBackPressed() { override fun onBackPressed() {
if (isEventChanged()) { if (isEventChanged() && System.currentTimeMillis() - mLastSavePromptTS > SAVE_DISCARD_PROMPT_INTERVAL) {
mLastSavePromptTS = System.currentTimeMillis()
ConfirmationAdvancedDialog(this, "", R.string.save_before_closing, R.string.save, R.string.discard) { ConfirmationAdvancedDialog(this, "", R.string.save_before_closing, R.string.save, R.string.discard) {
if (it) { if (it) {
saveCurrentEvent() saveCurrentEvent()