Skip to content

Save notes when dialog closes (screen rotation, screen turned off, user accidentally clicked outside the dialog) #2129

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

SimonCierniewski
Copy link

I extensively add notes to my tracked habits, and it's frustrating when my whole note disappears when I accidentally rotate the screen or my screen turns off.

I noticed that Dialogs are closed on purpose (dismissCurrentDialog in onPause()), because callbacks are cleared after rotation. Fixing it would involve architecture changes, so I added a quick fix instead to autosave notes when the dialog closes.

@@ -77,4 +79,17 @@ class CheckmarkDialog : AppCompatDialogFragment() {

return dialog
}

override fun onDestroyView() {
if (!wasSaved) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't save if user clicked one of values [✓, X, ? , -] to save the event.


override fun onDestroyView() {
if (!wasSaved) {
save(requireArguments().getInt("value"))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Dialog is closed by dismissCurrentDialog(), save note with previous value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant