Commit:
9068ac2Parent:
bd972f2Add a Save option to the discard-changes dialog
Backing out of a note with unsaved changes previously only offered Discard or Cancel. Adds a third Save button that saves before closing, matching the standard three-way "unsaved changes" prompt instead of forcing a trip back to the toolbar's save action first. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
src/Activities/NoteViewActivity.cs
+11
-1
diff --git a/src/Activities/NoteViewActivity.cs b/src/Activities/NoteViewActivity.cs
index 5ed98c1..2a40bd9 100644
@@ -140,11 +140,21 @@ public class NoteViewActivity : AppCompatActivity
new AlertDialog.Builder(this)!
.SetTitle(Resource.String.discard_changes_title)!
.SetMessage(Resource.String.discard_changes_message)!
.SetPositiveButton(Resource.String.discard, (_, _) => FinishWithResult())!
.SetPositiveButton(Resource.String.save_note, (_, _) => _ = SaveAndFinishAsync())!
.SetNeutralButton(Resource.String.discard, (_, _) => FinishWithResult())!
.SetNegativeButton(Resource.String.cancel, (_, _) => { })!
.Show();
}
private async Task SaveAndFinishAsync()
{
await SaveAsync();
// SaveAsync only clears _isDirty on success - if it's still set, the save failed (a
// Toast was already shown) and the note shouldn't be closed out from under the user.
if (!_isDirty)
FinishWithResult();
}
private void FinishWithResult()
{
// Even a note that was only viewed (never edited) usually has a better preview now