mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-25 15:11:52 -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_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_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_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_ON = 1;
|
||||||
private static final int MSG_PROGRESS_OFF = 2;
|
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 mDraftNeedsSaving = false;
|
||||||
private boolean mPreventDraftSaving = 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
|
* 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.
|
* 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
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
mIgnoreOnStop = false;
|
||||||
MessagingController.getInstance(getApplication()).addListener(mListener);
|
MessagingController.getInstance(getApplication()).addListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
saveIfNeeded();
|
|
||||||
MessagingController.getInstance(getApplication()).removeListener(mListener);
|
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
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
saveIfNeeded();
|
|
||||||
ArrayList<Uri> attachments = new ArrayList<Uri>();
|
ArrayList<Uri> attachments = new ArrayList<Uri>();
|
||||||
for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) {
|
for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) {
|
||||||
View view = mAttachments.getChildAt(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_HTML_QUOTE, mQuotedHtmlContent);
|
||||||
outState.putSerializable(STATE_KEY_MESSAGE_FORMAT, mMessageFormat);
|
outState.putSerializable(STATE_KEY_MESSAGE_FORMAT, mMessageFormat);
|
||||||
outState.putBoolean(STATE_KEY_READ_RECEIPT, mReadReceipt);
|
outState.putBoolean(STATE_KEY_READ_RECEIPT, mReadReceipt);
|
||||||
|
outState.putBoolean(STATE_KEY_DRAFT_NEEDS_SAVING, mDraftNeedsSaving);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -910,13 +922,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
mPgpData = (PgpData) savedInstanceState.getSerializable(STATE_PGP_DATA);
|
mPgpData = (PgpData) savedInstanceState.getSerializable(STATE_PGP_DATA);
|
||||||
mInReplyTo = savedInstanceState.getString(STATE_IN_REPLY_TO);
|
mInReplyTo = savedInstanceState.getString(STATE_IN_REPLY_TO);
|
||||||
mReferences = savedInstanceState.getString(STATE_REFERENCES);
|
mReferences = savedInstanceState.getString(STATE_REFERENCES);
|
||||||
|
mDraftNeedsSaving = savedInstanceState.getBoolean(STATE_KEY_DRAFT_NEEDS_SAVING);
|
||||||
|
|
||||||
initializeCrypto();
|
initializeCrypto();
|
||||||
updateFrom();
|
updateFrom();
|
||||||
updateSignature();
|
updateSignature();
|
||||||
updateEncryptLayout();
|
updateEncryptLayout();
|
||||||
|
|
||||||
mDraftNeedsSaving = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTitle() {
|
private void updateTitle() {
|
||||||
@ -1566,7 +1578,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onSave() {
|
private void onSave() {
|
||||||
mDraftNeedsSaving = true;
|
|
||||||
saveIfNeeded();
|
saveIfNeeded();
|
||||||
finish();
|
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.
|
* Kick off a picker for whatever kind of MIME types we'll accept and let Android take over.
|
||||||
*/
|
*/
|
||||||
private void onAddAttachment() {
|
private void onAddAttachment() {
|
||||||
|
mIgnoreOnStop = true;
|
||||||
if (K9.isGalleryBuggy()) {
|
if (K9.isGalleryBuggy()) {
|
||||||
if (K9.useGalleryBugWorkaround()) {
|
if (K9.useGalleryBugWorkaround()) {
|
||||||
Toast.makeText(MessageCompose.this,
|
Toast.makeText(MessageCompose.this,
|
||||||
@ -2905,7 +2917,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
private class SaveMessageTask extends AsyncTask<Void, Void, Void> {
|
private class SaveMessageTask extends AsyncTask<Void, Void, Void> {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create the message from all the data the user has entered.
|
* 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);
|
Message draftMessage = messagingController.saveDraft(mAccount, message);
|
||||||
mDraftUid = draftMessage.getUid();
|
mDraftUid = draftMessage.getUid();
|
||||||
|
|
||||||
// Don't display the toast if the user is just changing the orientation
|
mHandler.sendEmptyMessage(MSG_SAVED_DRAFT);
|
||||||
if ((getChangingConfigurations() & ActivityInfo.CONFIG_ORIENTATION) == 0) {
|
|
||||||
mHandler.sendEmptyMessage(MSG_SAVED_DRAFT);
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user