Improved reply/forward handling

This commit is contained in:
M66B
2019-01-21 16:45:05 +00:00
parent 2b3d6b94da
commit 332fcb5557
14 changed files with 132 additions and 136 deletions

View File

@@ -57,9 +57,12 @@ import com.sun.mail.imap.IMAPStore;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -328,7 +331,7 @@ public class Helper {
draft.subject = context.getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " debug info";
draft.received = new Date().getTime();
draft.id = db.message().insertMessage(draft);
draft.write(context, body);
writeText(EntityMessage.getFile(context, draft.id), body);
db.message().setMessageContent(draft.id, true, HtmlHelper.getPreview(body));
attachSettings(context, draft.id, 1);
@@ -600,6 +603,34 @@ public class Helper {
return TextUtils.join("@", a);
}
static void writeText(File file, String content) throws IOException {
BufferedWriter out = null;
try {
out = new BufferedWriter(new FileWriter(file));
out.write(content == null ? "" : content);
} finally {
if (out != null)
out.close();
}
}
static String readText(File file) throws IOException {
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(file));
StringBuilder body = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
body.append(line);
body.append('\n');
}
return body.toString();
} finally {
if (in != null)
in.close();
}
}
static void copy(File src, File dst) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
try {