|
|
@ -169,7 +169,6 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
private State state = State.NONE;
|
|
|
|
private State state = State.NONE;
|
|
|
|
private boolean autosave = false;
|
|
|
|
private boolean autosave = false;
|
|
|
|
private boolean busy = false;
|
|
|
|
private boolean busy = false;
|
|
|
|
private boolean dirty = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private OpenPgpServiceConnection pgpService;
|
|
|
|
private OpenPgpServiceConnection pgpService;
|
|
|
|
|
|
|
|
|
|
|
@ -1112,11 +1111,6 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
args.putParcelable("uri", uri);
|
|
|
|
args.putParcelable("uri", uri);
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<EntityAttachment>() {
|
|
|
|
new SimpleTask<EntityAttachment>() {
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onPostExecute(Bundle args) {
|
|
|
|
|
|
|
|
dirty = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected EntityAttachment onExecute(Context context, Bundle args) throws IOException {
|
|
|
|
protected EntityAttachment onExecute(Context context, Bundle args) throws IOException {
|
|
|
|
Long id = args.getLong("id");
|
|
|
|
Long id = args.getLong("id");
|
|
|
@ -1263,13 +1257,13 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
private boolean isEmpty() {
|
|
|
|
private boolean isEmpty() {
|
|
|
|
if (!TextUtils.isEmpty(etExtra.getText().toString().trim()))
|
|
|
|
if (!TextUtils.isEmpty(etExtra.getText().toString().trim()))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
if (!TextUtils.isEmpty(etTo.getText().toString().trim()))
|
|
|
|
if (!etTo.getText().toString().equals(etTo.getTag()))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
if (!TextUtils.isEmpty(etCc.getText().toString().trim()))
|
|
|
|
if (!TextUtils.isEmpty(etCc.getText().toString().trim()))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
if (!TextUtils.isEmpty(etBcc.getText().toString().trim()))
|
|
|
|
if (!TextUtils.isEmpty(etBcc.getText().toString().trim()))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
if (!TextUtils.isEmpty(etSubject.getText().toString().trim()))
|
|
|
|
if (!etSubject.getText().toString().equals(etSubject.getTag()))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
if (!TextUtils.isEmpty(Jsoup.parse(Html.toHtml(etBody.getText())).text().trim()))
|
|
|
|
if (!TextUtils.isEmpty(Jsoup.parse(Html.toHtml(etBody.getText())).text().trim()))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -1281,6 +1275,12 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
private void onAction(int action) {
|
|
|
|
private void onAction(int action) {
|
|
|
|
EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem();
|
|
|
|
EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Workaround underlines left by Android
|
|
|
|
|
|
|
|
Spannable spannable = etBody.getText();
|
|
|
|
|
|
|
|
UnderlineSpan[] uspans = spannable.getSpans(0, spannable.length(), UnderlineSpan.class);
|
|
|
|
|
|
|
|
for (UnderlineSpan uspan : uspans)
|
|
|
|
|
|
|
|
spannable.removeSpan(uspan);
|
|
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putLong("id", working);
|
|
|
|
args.putLong("id", working);
|
|
|
|
args.putInt("action", action);
|
|
|
|
args.putInt("action", action);
|
|
|
@ -1291,18 +1291,8 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
args.putString("cc", etCc.getText().toString().trim());
|
|
|
|
args.putString("cc", etCc.getText().toString().trim());
|
|
|
|
args.putString("bcc", etBcc.getText().toString().trim());
|
|
|
|
args.putString("bcc", etBcc.getText().toString().trim());
|
|
|
|
args.putString("subject", etSubject.getText().toString().trim());
|
|
|
|
args.putString("subject", etSubject.getText().toString().trim());
|
|
|
|
args.putInt("attachments", rvAttachment.getAdapter().getItemCount());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Workaround underlines left by Android
|
|
|
|
|
|
|
|
Spannable spannable = etBody.getText();
|
|
|
|
|
|
|
|
UnderlineSpan[] uspans = spannable.getSpans(0, spannable.length(), UnderlineSpan.class);
|
|
|
|
|
|
|
|
for (UnderlineSpan uspan : uspans)
|
|
|
|
|
|
|
|
spannable.removeSpan(uspan);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args.putString("body", Html.toHtml(spannable));
|
|
|
|
args.putString("body", Html.toHtml(spannable));
|
|
|
|
|
|
|
|
args.putBoolean("empty", isEmpty());
|
|
|
|
args.putBoolean("dirty", dirty);
|
|
|
|
|
|
|
|
dirty = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.i("Run execute id=" + working);
|
|
|
|
Log.i("Run execute id=" + working);
|
|
|
|
actionLoader.execute(this, args, "compose:action:" + action);
|
|
|
|
actionLoader.execute(this, args, "compose:action:" + action);
|
|
|
@ -1712,6 +1702,10 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
etBcc.setText(MessageHelper.getFormattedAddresses(result.draft.bcc, true));
|
|
|
|
etBcc.setText(MessageHelper.getFormattedAddresses(result.draft.bcc, true));
|
|
|
|
etSubject.setText(result.draft.subject);
|
|
|
|
etSubject.setText(result.draft.subject);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long reference = args.getLong("reference", -1);
|
|
|
|
|
|
|
|
etTo.setTag(reference < 0 ? "" : etTo.getText().toString());
|
|
|
|
|
|
|
|
etSubject.setTag(reference < 0 ? "" : etSubject.getText().toString());
|
|
|
|
|
|
|
|
|
|
|
|
boolean sender = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("sender", false);
|
|
|
|
boolean sender = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("sender", false);
|
|
|
|
|
|
|
|
|
|
|
|
grpHeader.setVisibility(View.VISIBLE);
|
|
|
|
grpHeader.setVisibility(View.VISIBLE);
|
|
|
@ -1838,17 +1832,8 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
String cc = args.getString("cc");
|
|
|
|
String cc = args.getString("cc");
|
|
|
|
String bcc = args.getString("bcc");
|
|
|
|
String bcc = args.getString("bcc");
|
|
|
|
String subject = args.getString("subject");
|
|
|
|
String subject = args.getString("subject");
|
|
|
|
int acount = args.getInt("attachments");
|
|
|
|
|
|
|
|
String body = args.getString("body");
|
|
|
|
String body = args.getString("body");
|
|
|
|
|
|
|
|
boolean empty = args.getBoolean("empty");
|
|
|
|
boolean dirty = args.getBoolean("dirty");
|
|
|
|
|
|
|
|
boolean empty = TextUtils.isEmpty(extra) &&
|
|
|
|
|
|
|
|
TextUtils.isEmpty(to) &&
|
|
|
|
|
|
|
|
TextUtils.isEmpty(cc) &&
|
|
|
|
|
|
|
|
TextUtils.isEmpty(bcc) &&
|
|
|
|
|
|
|
|
TextUtils.isEmpty(subject) &&
|
|
|
|
|
|
|
|
acount == 0 &&
|
|
|
|
|
|
|
|
TextUtils.isEmpty(Jsoup.parse(body).text().trim());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EntityMessage draft;
|
|
|
|
EntityMessage draft;
|
|
|
|
|
|
|
|
|
|
|
@ -1920,38 +1905,36 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
extra = null;
|
|
|
|
extra = null;
|
|
|
|
|
|
|
|
|
|
|
|
Long ident = (identity == null ? null : identity.id);
|
|
|
|
Long ident = (identity == null ? null : identity.id);
|
|
|
|
dirty = dirty ||
|
|
|
|
boolean dirty = ((draft.identity == null ? ident != null : !draft.identity.equals(ident)) ||
|
|
|
|
((draft.identity == null ? ident != null : !draft.identity.equals(ident)) ||
|
|
|
|
(draft.extra == null ? extra != null : !draft.extra.equals(extra)) ||
|
|
|
|
(draft.extra == null ? extra != null : !draft.extra.equals(extra)) ||
|
|
|
|
!MessageHelper.equal(draft.from, afrom) ||
|
|
|
|
!MessageHelper.equal(draft.from, afrom) ||
|
|
|
|
!MessageHelper.equal(draft.to, ato) ||
|
|
|
|
!MessageHelper.equal(draft.to, ato) ||
|
|
|
|
!MessageHelper.equal(draft.cc, acc) ||
|
|
|
|
!MessageHelper.equal(draft.cc, acc) ||
|
|
|
|
!MessageHelper.equal(draft.bcc, abcc) ||
|
|
|
|
!MessageHelper.equal(draft.bcc, abcc) ||
|
|
|
|
(draft.subject == null ? subject != null : !draft.subject.equals(subject)) ||
|
|
|
|
(draft.subject == null ? subject != null : !draft.subject.equals(subject)));
|
|
|
|
!body.equals(draft.read(context)));
|
|
|
|
|
|
|
|
|
|
|
|
// Update draft
|
|
|
|
|
|
|
|
draft.identity = ident;
|
|
|
|
|
|
|
|
draft.extra = extra;
|
|
|
|
|
|
|
|
draft.sender = MessageHelper.getSortKey(afrom);
|
|
|
|
|
|
|
|
draft.from = afrom;
|
|
|
|
|
|
|
|
draft.to = ato;
|
|
|
|
|
|
|
|
draft.cc = acc;
|
|
|
|
|
|
|
|
draft.bcc = abcc;
|
|
|
|
|
|
|
|
draft.subject = subject;
|
|
|
|
|
|
|
|
draft.received = new Date().getTime();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (action == R.id.action_send)
|
|
|
|
if (action == R.id.action_send)
|
|
|
|
if (draft.replying != null || draft.forwarding != null)
|
|
|
|
if (draft.replying != null || draft.forwarding != null) {
|
|
|
|
body += HtmlHelper.getQuote(context,
|
|
|
|
body += HtmlHelper.getQuote(context,
|
|
|
|
draft.replying == null ? draft.forwarding : draft.replying, false);
|
|
|
|
draft.replying == null ? draft.forwarding : draft.replying, false);
|
|
|
|
|
|
|
|
dirty = true;
|
|
|
|
dirty = (dirty || !body.equals(draft.read(context)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (dirty) {
|
|
|
|
if (dirty) {
|
|
|
|
|
|
|
|
// Update draft
|
|
|
|
|
|
|
|
draft.identity = ident;
|
|
|
|
|
|
|
|
draft.extra = extra;
|
|
|
|
|
|
|
|
draft.sender = MessageHelper.getSortKey(afrom);
|
|
|
|
|
|
|
|
draft.from = afrom;
|
|
|
|
|
|
|
|
draft.to = ato;
|
|
|
|
|
|
|
|
draft.cc = acc;
|
|
|
|
|
|
|
|
draft.bcc = abcc;
|
|
|
|
|
|
|
|
draft.subject = subject;
|
|
|
|
|
|
|
|
draft.received = new Date().getTime();
|
|
|
|
db.message().updateMessage(draft);
|
|
|
|
db.message().updateMessage(draft);
|
|
|
|
draft.write(context, body);
|
|
|
|
draft.write(context, body);
|
|
|
|
db.message().setMessageContent(
|
|
|
|
db.message().setMessageContent(draft.id, true, HtmlHelper.getPreview(body));
|
|
|
|
draft.id, true, HtmlHelper.getPreview(body));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Execute action
|
|
|
|
// Execute action
|
|
|
|