From a021ab71de6f6f53481e15b841cc8351441a1023 Mon Sep 17 00:00:00 2001 From: ashley willis Date: Tue, 1 Nov 2011 22:12:51 -0500 Subject: [PATCH] Override onStop() to save email as draft when activity is changed (go to home screen, call received) --- src/com/fsck/k9/activity/MessageCompose.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/com/fsck/k9/activity/MessageCompose.java b/src/com/fsck/k9/activity/MessageCompose.java index de1431c84..80582e028 100644 --- a/src/com/fsck/k9/activity/MessageCompose.java +++ b/src/com/fsck/k9/activity/MessageCompose.java @@ -793,6 +793,20 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc MessagingController.getInstance(getApplication()).removeListener(mListener); } + // Save email as draft when activity is changed (go to home screen, call received) + @Override + public void onStop() { + super.onStop(); + // don't do this if only changing orientations + if ((getChangingConfigurations() & ActivityInfo.CONFIG_ORIENTATION) == 0) { + // don't do this if selecting signature or if "Encrypt" is checked + if (!mPreventDraftSaving && !mEncryptCheckbox.isChecked()){ + saveIfNeeded(); + finish(); + } + } + } + /** * The framework handles most of the fields, but we need to handle stuff that we * dynamically show and hide: