|
|
|
@ -97,6 +97,7 @@ import java.io.BufferedWriter;
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.FileWriter;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
@ -557,8 +558,13 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
String body = args.getString("body");
|
|
|
|
|
|
|
|
|
|
File file = EntityMessage.getFile(context, id);
|
|
|
|
|
File refFile = EntityMessage.getRefFile(context, id);
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
EntityMessage draft = db.message().getMessage(id);
|
|
|
|
|
if (draft == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
File file = draft.getFile(context);
|
|
|
|
|
File refFile = draft.getRefFile(context);
|
|
|
|
|
|
|
|
|
|
String ref = Helper.readText(refFile);
|
|
|
|
|
String plain = HtmlHelper.getText(ref);
|
|
|
|
@ -1745,7 +1751,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
draft.received = new Date().getTime();
|
|
|
|
|
|
|
|
|
|
draft.id = db.message().insertMessage(draft);
|
|
|
|
|
Helper.writeText(EntityMessage.getFile(context, draft.id), body);
|
|
|
|
|
Helper.writeText(draft.getFile(context), body);
|
|
|
|
|
|
|
|
|
|
db.message().setMessageContent(draft.id, true, HtmlHelper.getPreview(body), null);
|
|
|
|
|
|
|
|
|
@ -1754,8 +1760,8 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
String refBody = String.format("<p>%s %s:</p>\n<blockquote>%s</blockquote>",
|
|
|
|
|
Html.escapeHtml(new Date(ref.received).toString()),
|
|
|
|
|
Html.escapeHtml(MessageHelper.formatAddresses(ref.from)),
|
|
|
|
|
Helper.readText(EntityMessage.getFile(context, ref.id)));
|
|
|
|
|
Helper.writeText(EntityMessage.getRefFile(context, draft.id), refBody);
|
|
|
|
|
Helper.readText(ref.getFile(context)));
|
|
|
|
|
Helper.writeText(draft.getRefFile(context), refBody);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("new".equals(action)) {
|
|
|
|
@ -2079,7 +2085,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
!MessageHelper.equal(draft.bcc, abcc) ||
|
|
|
|
|
!Objects.equals(draft.subject, subject) ||
|
|
|
|
|
last_available != available ||
|
|
|
|
|
!body.equals(Helper.readText(EntityMessage.getFile(context, draft.id))));
|
|
|
|
|
!body.equals(Helper.readText(draft.getFile(context))));
|
|
|
|
|
|
|
|
|
|
last_available = available;
|
|
|
|
|
|
|
|
|
@ -2095,14 +2101,14 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
draft.subject = subject;
|
|
|
|
|
draft.received = new Date().getTime();
|
|
|
|
|
db.message().updateMessage(draft);
|
|
|
|
|
Helper.writeText(EntityMessage.getFile(context, draft.id), body);
|
|
|
|
|
Helper.writeText(draft.getFile(context), body);
|
|
|
|
|
db.message().setMessageContent(draft.id, true, HtmlHelper.getPreview(body), null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove unused inline images
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.append(body);
|
|
|
|
|
File rfile = EntityMessage.getRefFile(context, draft.id);
|
|
|
|
|
File rfile = draft.getRefFile(context);
|
|
|
|
|
if (rfile.exists())
|
|
|
|
|
sb.append(Helper.readText(rfile));
|
|
|
|
|
List<String> cids = new ArrayList<>();
|
|
|
|
@ -2165,7 +2171,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
// Delete draft (cannot move to outbox)
|
|
|
|
|
EntityOperation.queue(context, db, draft, EntityOperation.DELETE);
|
|
|
|
|
|
|
|
|
|
File refDraftFile = EntityMessage.getRefFile(context, draft.id);
|
|
|
|
|
File refDraftFile = draft.getRefFile(context);
|
|
|
|
|
|
|
|
|
|
// Copy message to outbox
|
|
|
|
|
draft.id = null;
|
|
|
|
@ -2173,9 +2179,9 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
draft.uid = null;
|
|
|
|
|
draft.ui_hide = false;
|
|
|
|
|
draft.id = db.message().insertMessage(draft);
|
|
|
|
|
Helper.writeText(EntityMessage.getFile(context, draft.id), body);
|
|
|
|
|
Helper.writeText(draft.getFile(context), body);
|
|
|
|
|
if (refDraftFile.exists()) {
|
|
|
|
|
File refFile = EntityMessage.getRefFile(context, draft.id);
|
|
|
|
|
File refFile = draft.getRefFile(context);
|
|
|
|
|
refDraftFile.renameTo(refFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2328,11 +2334,17 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
final long id = args.getLong("id");
|
|
|
|
|
final boolean show_images = args.getBoolean("show_images", false);
|
|
|
|
|
|
|
|
|
|
String body = Helper.readText(EntityMessage.getFile(context, id));
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
EntityMessage draft = db.message().getMessage(id);
|
|
|
|
|
if (draft == null)
|
|
|
|
|
throw new FileNotFoundException();
|
|
|
|
|
|
|
|
|
|
String body = Helper.readText(draft.getFile(context));
|
|
|
|
|
Spanned spannedBody = HtmlHelper.fromHtml(body, cidGetter, null);
|
|
|
|
|
|
|
|
|
|
Spanned spannedReference = null;
|
|
|
|
|
File refFile = EntityMessage.getRefFile(context, id);
|
|
|
|
|
File refFile = draft.getRefFile(context);
|
|
|
|
|
if (refFile.exists()) {
|
|
|
|
|
String quote = HtmlHelper.sanitize(context, Helper.readText(refFile), true);
|
|
|
|
|
Spanned spannedQuote = HtmlHelper.fromHtml(quote,
|
|
|
|
|