From 5ac3d1d5c26f0752b61a3d9dd5f265f263cadc6d Mon Sep 17 00:00:00 2001 From: Andrew Chen Date: Mon, 7 Jan 2013 23:19:07 -0800 Subject: [PATCH] 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. --- .../k9/controller/MessagingController.java | 7 +++-- .../fsck/k9/mail/internet/MimeMessage.java | 26 ------------------- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index 3af466e3b..a6ebbece1 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -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 diff --git a/src/com/fsck/k9/mail/internet/MimeMessage.java b/src/com/fsck/k9/mail/internet/MimeMessage.java index 004cef186..e899afbf6 100644 --- a/src/com/fsck/k9/mail/internet/MimeMessage.java +++ b/src/com/fsck/k9/mail/internet/MimeMessage.java @@ -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 ""; }