Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Fixed contacts edits being silently discarded when using navigation arrow ([#360])

## [1.2.4] - 2025-07-31
### Changed
Expand Down Expand Up @@ -79,6 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#281]: https://github.com/FossifyOrg/Contacts/issues/281
[#289]: https://github.com/FossifyOrg/Contacts/issues/289
[#339]: https://github.com/FossifyOrg/Contacts/issues/339
[#360]: https://github.com/FossifyOrg/Contacts/issues/360

[Unreleased]: https://github.com/FossifyOrg/Contacts/compare/1.2.4...HEAD
[1.2.4]: https://github.com/FossifyOrg/Contacts/compare/1.2.3...1.2.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,23 +297,29 @@ class EditContactActivity : ContactActivity() {
}

override fun onBackPressed() {
maybeShowUnsavedChangesDialog {
super.onBackPressed()
}
}

private fun maybeShowUnsavedChangesDialog(discard: () -> Unit) {
if (System.currentTimeMillis() - mLastSavePromptTS > SAVE_DISCARD_PROMPT_INTERVAL && hasContactChanged()) {
mLastSavePromptTS = System.currentTimeMillis()
ConfirmationAdvancedDialog(
this,
"",
org.fossify.commons.R.string.save_before_closing,
org.fossify.commons.R.string.save,
org.fossify.commons.R.string.discard
activity = this,
message = "",
messageId = org.fossify.commons.R.string.save_before_closing,
positive = org.fossify.commons.R.string.save,
negative = org.fossify.commons.R.string.discard
) {
if (it) {
saveContact()
} else {
super.onBackPressed()
discard()
}
}
} else {
super.onBackPressed()
discard()
}
}

Expand Down Expand Up @@ -360,8 +366,10 @@ class EditContactActivity : ContactActivity() {
}

binding.contactToolbar.setNavigationOnClickListener {
hideKeyboard()
finish()
maybeShowUnsavedChangesDialog {
hideKeyboard()
finish()
}
}
}

Expand Down
Loading