Refactoring

pull/204/head
M66B 3 years ago
parent 560071b5a1
commit 9fc0d0ca00

@ -4096,11 +4096,23 @@ public class FragmentCompose extends FragmentBase {
protected DraftData onExecute(Context context, Bundle args) throws Throwable { protected DraftData onExecute(Context context, Bundle args) throws Throwable {
String action = args.getString("action"); String action = args.getString("action");
long id = args.getLong("id", -1); long id = args.getLong("id", -1);
long aid = args.getLong("account", -1);
long iid = args.getLong("identity", -1);
long reference = args.getLong("reference", -1); long reference = args.getLong("reference", -1);
int dsn = args.getInt("dsn", EntityMessage.DSN_RECEIPT); int dsn = args.getInt("dsn", EntityMessage.DSN_RECEIPT);
File ics = (File) args.getSerializable("ics"); File ics = (File) args.getSerializable("ics");
String status = args.getString("status"); String status = args.getString("status");
// raw
long answer = args.getLong("answer", -1); long answer = args.getLong("answer", -1);
String to = args.getString("to");
String cc = args.getString("cc");
String bcc = args.getString("bcc");
// inreplyto
String external_subject = args.getString("subject", "");
String external_body = args.getString("body", "");
String external_text = args.getString("text");
String selected_text = args.getString("selected");
ArrayList<Uri> uris = args.getParcelableArrayList("attachments");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean plain_only = prefs.getBoolean("plain_only", false); boolean plain_only = prefs.getBoolean("plain_only", false);
@ -4141,8 +4153,6 @@ public class FragmentCompose extends FragmentBase {
// Select identity matching from address // Select identity matching from address
EntityIdentity selected = null; EntityIdentity selected = null;
long aid = args.getLong("account", -1);
long iid = args.getLong("identity", -1);
if (aid < 0) if (aid < 0)
if (ref == null) { if (ref == null) {
@ -4263,21 +4273,18 @@ public class FragmentCompose extends FragmentBase {
data.draft.thread = data.draft.msgid; data.draft.thread = data.draft.msgid;
try { try {
String to = args.getString("to");
data.draft.to = MessageHelper.parseAddresses(context, to); data.draft.to = MessageHelper.parseAddresses(context, to);
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(ex); Log.w(ex);
} }
try { try {
String cc = args.getString("cc");
data.draft.cc = MessageHelper.parseAddresses(context, cc); data.draft.cc = MessageHelper.parseAddresses(context, cc);
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(ex); Log.w(ex);
} }
try { try {
String bcc = args.getString("bcc");
data.draft.bcc = MessageHelper.parseAddresses(context, bcc); data.draft.bcc = MessageHelper.parseAddresses(context, bcc);
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(ex); Log.w(ex);
@ -4285,11 +4292,10 @@ public class FragmentCompose extends FragmentBase {
data.draft.inreplyto = args.getString("inreplyto", null); data.draft.inreplyto = args.getString("inreplyto", null);
data.draft.subject = args.getString("subject", ""); data.draft.subject = external_subject;
String b = args.getString("body", ""); if (!TextUtils.isEmpty(external_body)) {
if (!TextUtils.isEmpty(b)) { Document d = JsoupEx.parse(external_body); // Passed html
Document d = JsoupEx.parse(b); // Passed html
Element e = document Element e = document
.createElement("div") .createElement("div")
.html(d.body().html()); .html(d.body().html());
@ -4423,10 +4429,9 @@ public class FragmentCompose extends FragmentBase {
alt_re ? R.string.title_subject_reply_alt : R.string.title_subject_reply, alt_re ? R.string.title_subject_reply_alt : R.string.title_subject_reply,
subject); subject);
String t = args.getString("text"); if (external_text != null) {
if (t != null) {
Element div = document.createElement("div"); Element div = document.createElement("div");
for (String line : t.split("\\r?\\n")) { for (String line : external_text.split("\\r?\\n")) {
Element span = document.createElement("span"); Element span = document.createElement("span");
span.text(line); span.text(line);
div.appendChild(span); div.appendChild(span);
@ -4532,10 +4537,9 @@ public class FragmentCompose extends FragmentBase {
data.draft.signature = false; data.draft.signature = false;
// Reply header // Reply header
String s = args.getString("selected");
if (ref.content && if (ref.content &&
!"editasnew".equals(action) && !"editasnew".equals(action) &&
!("list".equals(action) && TextUtils.isEmpty(s)) && !("list".equals(action) && TextUtils.isEmpty(selected_text)) &&
!"dsn".equals(action)) { !"dsn".equals(action)) {
// Reply/forward // Reply/forward
Element reply = document.createElement("div"); Element reply = document.createElement("div");
@ -4550,7 +4554,7 @@ public class FragmentCompose extends FragmentBase {
reply.appendChild(p); reply.appendChild(p);
Document d; Document d;
if (TextUtils.isEmpty(s)) { if (TextUtils.isEmpty(selected_text)) {
// Get referenced message body // Get referenced message body
d = JsoupEx.parse(ref.getFile(context)); d = JsoupEx.parse(ref.getFile(context));
HtmlHelper.normalizeNamespaces(d, false); HtmlHelper.normalizeNamespaces(d, false);
@ -4608,7 +4612,7 @@ public class FragmentCompose extends FragmentBase {
d = Document.createShell(""); d = Document.createShell("");
Element div = d.createElement("div"); Element div = d.createElement("div");
for (String line : s.split("\\r?\\n")) { for (String line : selected_text.split("\\r?\\n")) {
Element span = document.createElement("span"); Element span = document.createElement("span");
span.text(line); span.text(line);
div.appendChild(span); div.appendChild(span);
@ -4716,24 +4720,21 @@ public class FragmentCompose extends FragmentBase {
} }
} }
if ("new".equals(action)) { if ("new".equals(action) && uris != null) {
ArrayList<Uri> uris = args.getParcelableArrayList("attachments"); ArrayList<Uri> images = new ArrayList<>();
if (uris != null) { for (Uri uri : uris)
ArrayList<Uri> images = new ArrayList<>(); try {
for (Uri uri : uris) UriInfo info = getInfo(uri, context);
try { if (info.isImage())
UriInfo info = getInfo(uri, context); images.add(uri);
if (info.isImage()) else
images.add(uri); addAttachment(context, data.draft.id, uri, false, 0, false);
else } catch (IOException ex) {
addAttachment(context, data.draft.id, uri, false, 0, false); Log.e(ex);
} catch (IOException ex) { }
Log.e(ex);
}
if (images.size() > 0) if (images.size() > 0)
args.putParcelableArrayList("images", images); args.putParcelableArrayList("images", images);
}
} }
if (ref != null && if (ref != null &&

Loading…
Cancel
Save