1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-01-13 14:48:04 -05:00

Split out sendmessage and savemessage - the sendorsavemessage method

didn't actually have them sharing code.
This commit is contained in:
Jesse Vincent 2010-07-22 03:40:14 +00:00
parent 338919a9a0
commit 8182b8a8ee

View File

@ -867,7 +867,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
return text;
}
private void sendOrSaveMessage(boolean save)
private void sendMessage()
{
/*
* Create the message from all the data the user has entered.
@ -875,7 +877,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
MimeMessage message;
try
{
message = createMessage(!save); // Only append sig on save
message = createMessage(true); // Only append sig on save
}
catch (MessagingException me)
{
@ -883,8 +885,29 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
throw new RuntimeException("Failed to create a new message for send or save.", me);
}
if (save)
MessagingController.getInstance(getApplication()).sendMessage(mAccount, message, null);
if (mDraftUid != null)
{
MessagingController.getInstance(getApplication()).deleteDraft(mAccount, mDraftUid);
mDraftUid = null;
}
}
private void saveMessage()
{
/*
* Create the message from all the data the user has entered.
*/
MimeMessage message;
try
{
message = createMessage(false); // Only append sig on save
}
catch (MessagingException me)
{
Log.e(K9.LOG_TAG, "Failed to create new message for send or save.", me);
throw new RuntimeException("Failed to create a new message for send or save.", me);
}
/*
* Save a draft
*/
@ -930,16 +953,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
mHandler.sendEmptyMessage(MSG_SAVED_DRAFT);
}
}
else
{
MessagingController.getInstance(getApplication()).sendMessage(mAccount, message, null);
if (mDraftUid != null)
{
MessagingController.getInstance(getApplication()).deleteDraft(mAccount, mDraftUid);
mDraftUid = null;
}
}
}
private void saveIfNeeded()
{
@ -948,7 +961,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
return;
}
mDraftNeedsSaving = false;
sendOrSaveMessage(true);
saveMessage();
}
private void onSend()
@ -959,7 +972,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
Toast.makeText(this, getString(R.string.message_compose_error_no_recipients), Toast.LENGTH_LONG).show();
return;
}
sendOrSaveMessage(false);
sendMessage();
mDraftNeedsSaving = false;
finish();
}
@ -1171,7 +1184,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
{
Log.v(K9.LOG_TAG, "Account switch, saving new draft in new account");
}
sendOrSaveMessage(true);
saveMessage();
if (previousDraftUid != null)
{