Use existing LocalMessage for the JB notifications.
LocalMessage already has a content preview in it; reuse that. Remove unneeded MimeMessage#getPreview() method now that we don't need to generate a preview anymore.
This commit is contained in:
parent
e796468256
commit
5ac3d1d5c2
2 changed files with 5 additions and 28 deletions
|
@ -1558,7 +1558,8 @@ public class MessagingController implements Runnable {
|
|||
// Send a notification of this message
|
||||
|
||||
if (shouldNotifyForMessage(account, localFolder, message)) {
|
||||
notifyAccount(mApplication, account, message, unreadBeforeStart);
|
||||
// Notify with the localMessage so that we don't have to recalculate the content preview.
|
||||
notifyAccount(mApplication, account, localMessage, unreadBeforeStart);
|
||||
}
|
||||
|
||||
} catch (MessagingException me) {
|
||||
|
@ -1676,6 +1677,7 @@ public class MessagingController implements Runnable {
|
|||
|
||||
// Update the listener with what we've found
|
||||
progress.incrementAndGet();
|
||||
// TODO do we need to re-fetch this here?
|
||||
Message localMessage = localFolder.getMessage(message.getUid());
|
||||
|
||||
// Increment the number of "new messages" if the newly downloaded message is
|
||||
|
@ -1694,7 +1696,8 @@ public class MessagingController implements Runnable {
|
|||
|
||||
// Send a notification of this message
|
||||
if (shouldNotifyForMessage(account, localFolder, message)) {
|
||||
notifyAccount(mApplication, account, message, unreadBeforeStart);
|
||||
// Notify with the localMessage so that we don't have to recalculate the content preview.
|
||||
notifyAccount(mApplication, account, localMessage, unreadBeforeStart);
|
||||
}
|
||||
|
||||
}//for large messages
|
||||
|
|
|
@ -595,32 +595,6 @@ public class MimeMessage extends Message {
|
|||
}
|
||||
|
||||
public String getPreview() {
|
||||
String preview = null;
|
||||
|
||||
try {
|
||||
Part part = MimeUtility.findFirstPartByMimeType(this, "text/html");
|
||||
if (part != null) {
|
||||
// We successfully found an HTML part; do the necessary character set decoding.
|
||||
preview = MimeUtility.getTextFromPart(part);
|
||||
if (preview != null) {
|
||||
preview = HtmlConverter.htmlToText(preview);
|
||||
}
|
||||
}
|
||||
if (preview == null) {
|
||||
// no HTML part -> try and get a text part.
|
||||
part = MimeUtility.findFirstPartByMimeType(this, "text/plain");
|
||||
if (part != null) {
|
||||
preview = MimeUtility.getTextFromPart(part);
|
||||
}
|
||||
}
|
||||
} catch (MessagingException e) {
|
||||
Log.d(K9.LOG_TAG, "Could not extract message preview", e);
|
||||
}
|
||||
|
||||
if (preview != null) {
|
||||
return calculateContentPreview(preview);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue