|
|
@ -339,8 +339,8 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
result.putLong("iid" , msg.identity);
|
|
|
|
result.putLong("iid" , msg.identity);
|
|
|
|
if (msg.replying != null)
|
|
|
|
if (msg.replying != null)
|
|
|
|
result.putLong("rid" , msg.replying);
|
|
|
|
result.putLong("rid" , msg.replying);
|
|
|
|
result.putString("cc" , msg.cc);
|
|
|
|
result.putSerializable("cc" , msg.cc);
|
|
|
|
result.putString("bcc" , msg.bcc);
|
|
|
|
result.putSerializable("bcc" , msg.bcc);
|
|
|
|
result.putString("thread" , msg.thread);
|
|
|
|
result.putString("thread" , msg.thread);
|
|
|
|
result.putString("subject" , msg.subject);
|
|
|
|
result.putString("subject" , msg.subject);
|
|
|
|
result.putString("body" , msg.body);
|
|
|
|
result.putString("body" , msg.body);
|
|
|
@ -348,50 +348,37 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(action)) {
|
|
|
|
if (TextUtils.isEmpty(action)) {
|
|
|
|
if (msg != null) {
|
|
|
|
if (msg != null) {
|
|
|
|
result.putString("from" , msg.from);
|
|
|
|
result.putSerializable("from" , msg.from);
|
|
|
|
result.putString("to" , msg.to);
|
|
|
|
result.putSerializable("to" , msg.to);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ("reply".equals(action)) {
|
|
|
|
} else if ("reply".equals(action)) {
|
|
|
|
String to = null;
|
|
|
|
Address[] to = null;
|
|
|
|
if (msg != null)
|
|
|
|
if (msg != null)
|
|
|
|
try {
|
|
|
|
to = (msg.reply == null || msg.reply.length == 0 ? msg.from : msg.reply);
|
|
|
|
Address[] reply = MessageHelper.decodeAddresses(msg.reply);
|
|
|
|
|
|
|
|
to = (reply.length == 0 ? msg.from : msg.reply);
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result.putLong("rid" , msg.id);
|
|
|
|
result.putLong("rid" , msg.id);
|
|
|
|
result.putString("from" , msg.to);
|
|
|
|
result.putSerializable("from" , msg.to);
|
|
|
|
result.putString("to" , to);
|
|
|
|
result.putSerializable("to" , to);
|
|
|
|
} else if ("reply_all".equals(action)) {
|
|
|
|
} else if ("reply_all".equals(action)) {
|
|
|
|
String to = null;
|
|
|
|
Address[] to = null;
|
|
|
|
if (msg != null) {
|
|
|
|
if (msg != null) {
|
|
|
|
try {
|
|
|
|
List<Address> addresses = new ArrayList<>();
|
|
|
|
Address[] from = MessageHelper.decodeAddresses(msg.from);
|
|
|
|
if (msg.reply != null)
|
|
|
|
Address[] reply = MessageHelper.decodeAddresses(msg.reply);
|
|
|
|
addresses.addAll(Arrays.asList(msg.reply));
|
|
|
|
Address[] cc = MessageHelper.decodeAddresses(msg.cc);
|
|
|
|
else if (msg.from != null)
|
|
|
|
List<Address> addresses = new ArrayList<>();
|
|
|
|
addresses.addAll(Arrays.asList(msg.from));
|
|
|
|
addresses.addAll(Arrays.asList(reply.length == 0 ? from : reply));
|
|
|
|
if (msg.cc != null)
|
|
|
|
addresses.addAll(Arrays.asList(cc));
|
|
|
|
addresses.addAll(Arrays.asList(msg.cc));
|
|
|
|
to = MessageHelper.encodeAddresses(addresses.toArray(new Address[0]));
|
|
|
|
to = addresses.toArray(new Address[0]);
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.putLong("rid" , msg.id);
|
|
|
|
result.putLong("rid" , msg.id);
|
|
|
|
result.putString("from" , msg.to);
|
|
|
|
result.putSerializable("from" , msg.to);
|
|
|
|
result.putString("to" , to);
|
|
|
|
result.putSerializable("to" , to);
|
|
|
|
} else if ("forward".equals(action)) {
|
|
|
|
} else if ("forward".equals(action)) {
|
|
|
|
String to = null;
|
|
|
|
Address[] to = null;
|
|
|
|
if (msg != null)
|
|
|
|
if (msg != null)
|
|
|
|
try {
|
|
|
|
to = (msg.reply == null || msg.reply.length == 0 ? msg.from : msg.reply);
|
|
|
|
Address[] reply = MessageHelper.decodeAddresses(msg.reply);
|
|
|
|
result.putSerializable("from" , msg.to);
|
|
|
|
to = (reply.length == 0 ? msg.from : msg.reply);
|
|
|
|
result.putSerializable("to" , to);
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result.putString("from" , msg.to);
|
|
|
|
|
|
|
|
result.putString("to" , to);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
|
|
|
@ -416,10 +403,10 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
long iid = result.getLong("iid" , -1);
|
|
|
|
long iid = result.getLong("iid" , -1);
|
|
|
|
long rid = result.getLong("rid" , -1);
|
|
|
|
long rid = result.getLong("rid" , -1);
|
|
|
|
String thread = result.getString("thread");
|
|
|
|
String thread = result.getString("thread");
|
|
|
|
String from = result.getString("from");
|
|
|
|
Address[] from = (Address[]) result.getSerializable("from");
|
|
|
|
String to = result.getString("to");
|
|
|
|
Address[] to = (Address[]) result.getSerializable("to");
|
|
|
|
String cc = result.getString("cc");
|
|
|
|
Address[] cc = (Address[]) result.getSerializable("cc");
|
|
|
|
String bcc = result.getString("bcc");
|
|
|
|
Address[] bcc = (Address[]) result.getSerializable("bcc");
|
|
|
|
String subject = result.getString("subject");
|
|
|
|
String subject = result.getString("subject");
|
|
|
|
String body = result.getString("body");
|
|
|
|
String body = result.getString("body");
|
|
|
|
String action = result.getString("action");
|
|
|
|
String action = result.getString("action");
|
|
|
@ -433,10 +420,11 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
|
|
|
|
|
|
|
|
ArrayAdapter adapter = (ArrayAdapter) spFrom.getAdapter();
|
|
|
|
ArrayAdapter adapter = (ArrayAdapter) spFrom.getAdapter();
|
|
|
|
if (adapter != null) {
|
|
|
|
if (adapter != null) {
|
|
|
|
InternetAddress[] afrom = MessageHelper.decodeAddresses(from);
|
|
|
|
|
|
|
|
for (int pos = 0; pos < adapter.getCount(); pos++) {
|
|
|
|
for (int pos = 0; pos < adapter.getCount(); pos++) {
|
|
|
|
EntityIdentity identity = (EntityIdentity) adapter.getItem(pos);
|
|
|
|
EntityIdentity identity = (EntityIdentity) adapter.getItem(pos);
|
|
|
|
if (iid < 0 ? afrom.length > 0 && afrom[0].getAddress().equals(identity.email) : iid == identity.id) {
|
|
|
|
if (iid < 0
|
|
|
|
|
|
|
|
? from != null && from.length > 0 && ((InternetAddress) from[0]).getAddress().equals(identity.email)
|
|
|
|
|
|
|
|
: iid == identity.id) {
|
|
|
|
spFrom.setSelection(pos);
|
|
|
|
spFrom.setSelection(pos);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -449,11 +437,11 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
|
|
|
|
|
|
|
|
Handler handler = new Handler();
|
|
|
|
Handler handler = new Handler();
|
|
|
|
|
|
|
|
|
|
|
|
etCc.setText(TextUtils.join(", " , MessageHelper.decodeAddresses(cc)));
|
|
|
|
etCc.setText(cc == null ? null : TextUtils.join(", " , cc));
|
|
|
|
etBcc.setText(TextUtils.join(", " , MessageHelper.decodeAddresses(bcc)));
|
|
|
|
etBcc.setText(bcc == null ? null : TextUtils.join(", " , bcc));
|
|
|
|
|
|
|
|
|
|
|
|
if (action == null) {
|
|
|
|
if (action == null) {
|
|
|
|
etTo.setText(TextUtils.join(", " , MessageHelper.decodeAddresses(to)));
|
|
|
|
etTo.setText(to == null ? null : TextUtils.join(", " , to));
|
|
|
|
etSubject.setText(subject);
|
|
|
|
etSubject.setText(subject);
|
|
|
|
if (body != null)
|
|
|
|
if (body != null)
|
|
|
|
etBody.setText(Html.fromHtml(HtmlHelper.sanitize(getContext(), body, false)));
|
|
|
|
etBody.setText(Html.fromHtml(HtmlHelper.sanitize(getContext(), body, false)));
|
|
|
@ -464,10 +452,10 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if ("reply".equals(action) || "reply_all".equals(action)) {
|
|
|
|
} else if ("reply".equals(action) || "reply_all".equals(action)) {
|
|
|
|
etTo.setText(TextUtils.join(", " , MessageHelper.decodeAddresses(to)));
|
|
|
|
etTo.setText(to == null ? null : TextUtils.join(", " , to));
|
|
|
|
String text = String.format("<br><br>%s %s:<br><br>%s" ,
|
|
|
|
String text = String.format("<br><br>%s %s:<br><br>%s" ,
|
|
|
|
Html.escapeHtml(new Date().toString()),
|
|
|
|
Html.escapeHtml(new Date().toString()),
|
|
|
|
Html.escapeHtml(TextUtils.join(", " , MessageHelper.decodeAddresses(to))),
|
|
|
|
Html.escapeHtml(to == null ? "" : TextUtils.join(", " , to)),
|
|
|
|
HtmlHelper.sanitize(getContext(), body, true));
|
|
|
|
HtmlHelper.sanitize(getContext(), body, true));
|
|
|
|
etSubject.setText(getContext().getString(R.string.title_subject_reply, subject));
|
|
|
|
etSubject.setText(getContext().getString(R.string.title_subject_reply, subject));
|
|
|
|
etBody.setText(Html.fromHtml(text));
|
|
|
|
etBody.setText(Html.fromHtml(text));
|
|
|
@ -480,7 +468,7 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
} else if ("forward".equals(action)) {
|
|
|
|
} else if ("forward".equals(action)) {
|
|
|
|
String text = String.format("<br><br>%s %s:<br><br>%s" ,
|
|
|
|
String text = String.format("<br><br>%s %s:<br><br>%s" ,
|
|
|
|
Html.escapeHtml(new Date().toString()),
|
|
|
|
Html.escapeHtml(new Date().toString()),
|
|
|
|
Html.escapeHtml(TextUtils.join(", " , MessageHelper.decodeAddresses(to))),
|
|
|
|
Html.escapeHtml(to == null ? "" : TextUtils.join(", " , to)),
|
|
|
|
HtmlHelper.sanitize(getContext(), body, true));
|
|
|
|
HtmlHelper.sanitize(getContext(), body, true));
|
|
|
|
etSubject.setText(getContext().getString(R.string.title_subject_forward, subject));
|
|
|
|
etSubject.setText(getContext().getString(R.string.title_subject_forward, subject));
|
|
|
|
etBody.setText(Html.fromHtml(text));
|
|
|
|
etBody.setText(Html.fromHtml(text));
|
|
|
@ -539,7 +527,7 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
String body = args.getString("body");
|
|
|
|
String body = args.getString("body");
|
|
|
|
String subject = args.getString("subject");
|
|
|
|
String subject = args.getString("subject");
|
|
|
|
|
|
|
|
|
|
|
|
Address afrom = (ident == null ? null : new InternetAddress(ident.email, ident.name));
|
|
|
|
Address afrom[] = (ident == null ? null : new Address[]{new InternetAddress(ident.email, ident.name)});
|
|
|
|
Address ato[] = (TextUtils.isEmpty(to) ? null : InternetAddress.parse(to));
|
|
|
|
Address ato[] = (TextUtils.isEmpty(to) ? null : InternetAddress.parse(to));
|
|
|
|
Address acc[] = (TextUtils.isEmpty(cc) ? null : InternetAddress.parse(cc));
|
|
|
|
Address acc[] = (TextUtils.isEmpty(cc) ? null : InternetAddress.parse(cc));
|
|
|
|
Address abcc[] = (TextUtils.isEmpty(bcc) ? null : InternetAddress.parse(bcc));
|
|
|
|
Address abcc[] = (TextUtils.isEmpty(bcc) ? null : InternetAddress.parse(bcc));
|
|
|
@ -553,10 +541,10 @@ public class FragmentCompose extends FragmentEx {
|
|
|
|
draft.identity = (ident == null ? null : ident.id);
|
|
|
|
draft.identity = (ident == null ? null : ident.id);
|
|
|
|
draft.replying = (rid < 0 ? null : rid);
|
|
|
|
draft.replying = (rid < 0 ? null : rid);
|
|
|
|
draft.thread = thread;
|
|
|
|
draft.thread = thread;
|
|
|
|
draft.from = MessageHelper.encodeAddresses(new Address[]{afrom});
|
|
|
|
draft.from = afrom;
|
|
|
|
draft.to = MessageHelper.encodeAddresses(ato);
|
|
|
|
draft.to = ato;
|
|
|
|
draft.cc = MessageHelper.encodeAddresses(acc);
|
|
|
|
draft.cc = acc;
|
|
|
|
draft.bcc = MessageHelper.encodeAddresses(abcc);
|
|
|
|
draft.bcc = abcc;
|
|
|
|
draft.subject = subject;
|
|
|
|
draft.subject = subject;
|
|
|
|
draft.body = "<pre>" + body.replaceAll("\\r?\\n" , "<br />") + "</pre>";
|
|
|
|
draft.body = "<pre>" + body.replaceAll("\\r?\\n" , "<br />") + "</pre>";
|
|
|
|
draft.received = new Date().getTime();
|
|
|
|
draft.received = new Date().getTime();
|
|
|
|