1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Only show "save or discard" dialog before leaving the message compose activity if the message needs saving.

This commit is contained in:
cketti 2010-07-28 23:17:46 +00:00
parent 3d5fb524ef
commit 4c1060ecae

View File

@ -36,7 +36,6 @@ import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener; import android.view.View.OnFocusChangeListener;
import android.view.Window; import android.view.Window;
import android.widget.AutoCompleteTextView.Validator; import android.widget.AutoCompleteTextView.Validator;
import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
@ -1528,13 +1527,21 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
return true; return true;
} }
@Override
public void onBackPressed() public void onBackPressed()
{ {
// This will be called either automatically for you on 2.0 // This will be called either automatically for you on 2.0
// or later, or by the code above on earlier versions of the // or later, or by the code above on earlier versions of the
// platform. // platform.
if (mDraftNeedsSaving)
{
showDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE); showDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
} }
else
{
finish();
}
}
@Override @Override
public Dialog onCreateDialog(int id) public Dialog onCreateDialog(int id)
@ -2156,6 +2163,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private class SendMessageTask extends AsyncTask<Void, Void, Void> private class SendMessageTask extends AsyncTask<Void, Void, Void>
{ {
@Override
protected Void doInBackground(Void... params) protected Void doInBackground(Void... params)
{ {
/* /*
@ -2185,6 +2193,7 @@ 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
protected Void doInBackground(Void... params) protected Void doInBackground(Void... params)
{ {