Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ac3d1d5 authored by Andrew Chen's avatar Andrew Chen
Browse files

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.
parent e7964682
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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
+0 −26
Original line number Diff line number Diff line
@@ -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 "";
    }