mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-25 15:11:52 -05:00
. Minor memory usage optimization of how we HTMLize plain text emails
This commit is contained in:
parent
23797b62ee
commit
d8724784dd
@ -1087,11 +1087,8 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String text = sbText.toString();
|
||||||
|
String html = markupContent(text, sbHtml.toString());
|
||||||
sbHtml = markupContent(sbText,sbHtml);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ContentValues cv = new ContentValues();
|
ContentValues cv = new ContentValues();
|
||||||
@ -1105,8 +1102,8 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
cv.put("to_list", Address.pack(message.getRecipients(RecipientType.TO)));
|
cv.put("to_list", Address.pack(message.getRecipients(RecipientType.TO)));
|
||||||
cv.put("cc_list", Address.pack(message.getRecipients(RecipientType.CC)));
|
cv.put("cc_list", Address.pack(message.getRecipients(RecipientType.CC)));
|
||||||
cv.put("bcc_list", Address.pack(message.getRecipients(RecipientType.BCC)));
|
cv.put("bcc_list", Address.pack(message.getRecipients(RecipientType.BCC)));
|
||||||
cv.put("html_content", sbHtml.length() > 0 ? sbHtml.toString() : null);
|
cv.put("html_content", html.length() > 0 ? html : null);
|
||||||
cv.put("text_content", sbText.length() > 0 ? sbText.toString() : null);
|
cv.put("text_content", text.length() > 0 ? text : null);
|
||||||
cv.put("reply_to_list", Address.pack(message.getReplyTo()));
|
cv.put("reply_to_list", Address.pack(message.getReplyTo()));
|
||||||
cv.put("attachment_count", attachments.size());
|
cv.put("attachment_count", attachments.size());
|
||||||
cv.put("internal_date", message.getInternalDate() == null
|
cv.put("internal_date", message.getInternalDate() == null
|
||||||
@ -1163,8 +1160,8 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sbHtml = markupContent(sbText,sbHtml);
|
String text = sbText.toString();
|
||||||
|
String html = markupContent(text, sbHtml.toString());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mDb.execSQL("UPDATE messages SET "
|
mDb.execSQL("UPDATE messages SET "
|
||||||
@ -1187,8 +1184,8 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
.getRecipients(RecipientType.CC)),
|
.getRecipients(RecipientType.CC)),
|
||||||
Address.pack(message
|
Address.pack(message
|
||||||
.getRecipients(RecipientType.BCC)),
|
.getRecipients(RecipientType.BCC)),
|
||||||
sbHtml.length() > 0 ? sbHtml.toString() : null,
|
html.length() > 0 ? html : null,
|
||||||
sbText.length() > 0 ? sbText.toString() : null,
|
text.length() > 0 ? text : null,
|
||||||
Address.pack(message.getReplyTo()),
|
Address.pack(message.getReplyTo()),
|
||||||
attachments.size(),
|
attachments.size(),
|
||||||
message.mId
|
message.mId
|
||||||
@ -1441,23 +1438,19 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public StringBuffer markupContent(StringBuffer sbText, StringBuffer sbHtml) {
|
public String markupContent(String text, String html) {
|
||||||
if (sbText.length() > 0 && sbHtml.length() == 0) {
|
if (text.length() > 0 && html.length() == 0) {
|
||||||
sbHtml.append(htmlifyString(sbText.toString()));
|
html = htmlifyString(text);
|
||||||
}
|
|
||||||
|
|
||||||
String html = sbHtml.toString();
|
|
||||||
if (html.indexOf("cid:")!=-1) {
|
|
||||||
html = html.replaceAll("cid:", "http://cid/");
|
|
||||||
}
|
|
||||||
Spannable markup = new SpannableString(html);
|
|
||||||
Linkify.addLinks(markup, Linkify.ALL);
|
|
||||||
StringBuffer sb = new StringBuffer(markup.length());
|
|
||||||
sb.append(markup.toString());
|
|
||||||
return sb;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (html.indexOf("cid:") != -1) {
|
||||||
|
return html.replaceAll("cid:", "http://cid/");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String htmlifyString(String text) {
|
public String htmlifyString(String text) {
|
||||||
StringReader reader = new StringReader(text);
|
StringReader reader = new StringReader(text);
|
||||||
StringBuilder buff = new StringBuilder(text.length() + 512);
|
StringBuilder buff = new StringBuilder(text.length() + 512);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user