mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Merge pull request #82 from ashleywillis/issue-1424
Issue 1424: saving duplicate or similar drafts fixed.
This commit is contained in:
commit
4b548169d6
@ -114,6 +114,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
private static final String STATE_REFERENCES = "com.fsck.k9.activity.MessageCompose.references";
|
||||
private static final String STATE_KEY_MESSAGE_FORMAT = "com.fsck.k9.activity.MessageCompose.messageFormat";
|
||||
private static final String STATE_KEY_READ_RECEIPT = "com.fsck.k9.activity.MessageCompose.messageReadReceipt";
|
||||
private static final String STATE_KEY_DRAFT_NEEDS_SAVING = "com.fsck.k9.activity.MessageCompose.mDraftNeedsSaving";
|
||||
|
||||
private static final int MSG_PROGRESS_ON = 1;
|
||||
private static final int MSG_PROGRESS_OFF = 2;
|
||||
@ -222,6 +223,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
private boolean mDraftNeedsSaving = false;
|
||||
private boolean mPreventDraftSaving = false;
|
||||
|
||||
private boolean mIgnoreOnStop = false;
|
||||
|
||||
/**
|
||||
* The draft uid of this message. This is used when saving drafts so that the same draft is
|
||||
* overwritten instead of being created anew. This property is null until the first save.
|
||||
@ -835,14 +838,23 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mIgnoreOnStop = false;
|
||||
MessagingController.getInstance(getApplication()).addListener(mListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
saveIfNeeded();
|
||||
MessagingController.getInstance(getApplication()).removeListener(mListener);
|
||||
// Save email as draft when activity is changed (go to home screen, call received) or screen locked
|
||||
// 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 or if adding an attachment
|
||||
if (!mPreventDraftSaving && !mEncryptCheckbox.isChecked() && !mIgnoreOnStop){
|
||||
saveIfNeeded();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -856,7 +868,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
saveIfNeeded();
|
||||
ArrayList<Uri> attachments = new ArrayList<Uri>();
|
||||
for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) {
|
||||
View view = mAttachments.getChildAt(i);
|
||||
@ -877,6 +888,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
outState.putSerializable(STATE_KEY_HTML_QUOTE, mQuotedHtmlContent);
|
||||
outState.putSerializable(STATE_KEY_MESSAGE_FORMAT, mMessageFormat);
|
||||
outState.putBoolean(STATE_KEY_READ_RECEIPT, mReadReceipt);
|
||||
outState.putBoolean(STATE_KEY_DRAFT_NEEDS_SAVING, mDraftNeedsSaving);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -910,13 +922,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
mPgpData = (PgpData) savedInstanceState.getSerializable(STATE_PGP_DATA);
|
||||
mInReplyTo = savedInstanceState.getString(STATE_IN_REPLY_TO);
|
||||
mReferences = savedInstanceState.getString(STATE_REFERENCES);
|
||||
mDraftNeedsSaving = savedInstanceState.getBoolean(STATE_KEY_DRAFT_NEEDS_SAVING);
|
||||
|
||||
initializeCrypto();
|
||||
updateFrom();
|
||||
updateSignature();
|
||||
updateEncryptLayout();
|
||||
|
||||
mDraftNeedsSaving = false;
|
||||
}
|
||||
|
||||
private void updateTitle() {
|
||||
@ -1566,7 +1578,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
}
|
||||
|
||||
private void onSave() {
|
||||
mDraftNeedsSaving = true;
|
||||
saveIfNeeded();
|
||||
finish();
|
||||
}
|
||||
@ -1593,6 +1604,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
* Kick off a picker for whatever kind of MIME types we'll accept and let Android take over.
|
||||
*/
|
||||
private void onAddAttachment() {
|
||||
mIgnoreOnStop = true;
|
||||
if (K9.isGalleryBuggy()) {
|
||||
if (K9.useGalleryBugWorkaround()) {
|
||||
Toast.makeText(MessageCompose.this,
|
||||
@ -2905,7 +2917,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
private class SaveMessageTask extends AsyncTask<Void, Void, Void> {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
/*
|
||||
* Create the message from all the data the user has entered.
|
||||
*/
|
||||
@ -2936,10 +2947,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
Message draftMessage = messagingController.saveDraft(mAccount, message);
|
||||
mDraftUid = draftMessage.getUid();
|
||||
|
||||
// Don't display the toast if the user is just changing the orientation
|
||||
if ((getChangingConfigurations() & ActivityInfo.CONFIG_ORIENTATION) == 0) {
|
||||
mHandler.sendEmptyMessage(MSG_SAVED_DRAFT);
|
||||
}
|
||||
mHandler.sendEmptyMessage(MSG_SAVED_DRAFT);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user