From 1bf159a3005a605d2a72ed5cc4af336269e7db8d Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 12 Jan 2015 22:09:55 +0100 Subject: [PATCH] Get rid of unused LocalTextBody --- .../fsck/k9/mailstore/LocalMessageTest.java | 44 ------------------- .../com/fsck/k9/mailstore/LocalMessage.java | 23 ---------- .../com/fsck/k9/mailstore/LocalTextBody.java | 20 --------- 3 files changed, 87 deletions(-) delete mode 100644 k9mail/src/androidTest/java/com/fsck/k9/mailstore/LocalMessageTest.java delete mode 100644 k9mail/src/main/java/com/fsck/k9/mailstore/LocalTextBody.java diff --git a/k9mail/src/androidTest/java/com/fsck/k9/mailstore/LocalMessageTest.java b/k9mail/src/androidTest/java/com/fsck/k9/mailstore/LocalMessageTest.java deleted file mode 100644 index 01b4d8e22..000000000 --- a/k9mail/src/androidTest/java/com/fsck/k9/mailstore/LocalMessageTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.fsck.k9.mailstore; - - -import android.test.AndroidTestCase; - -import com.fsck.k9.Preferences; -import com.fsck.k9.mail.internet.MimeBodyPart; -import com.fsck.k9.mail.internet.MimeMultipart; - - -public class LocalMessageTest extends AndroidTestCase { - private LocalMessage message; - - @Override - public void setUp() throws Exception { - super.setUp(); - Preferences preferences = Preferences.getPreferences(getContext()); - LocalStore store = LocalStore.getInstance(preferences.newAccount(), getContext()); - message = new LocalMessage(store, "uid", new LocalFolder(store, "test")); - } - - public void testGetDisplayTextWithPlainTextPart() throws Exception { - String textBodyText = "text body"; - - MimeMultipart multipart = new MimeMultipart(); - MimeBodyPart bodyPart1 = new MimeBodyPart(new LocalTextBody(textBodyText, textBodyText), "text/plain"); - multipart.addBodyPart(bodyPart1); - message.setBody(multipart); - assertEquals("text body", message.getTextForDisplay()); - } - - public void testGetDisplayTextWithHtmlPart() throws Exception { - String htmlBodyText = "html body"; - String textBodyText = "text body"; - - MimeMultipart multipart = new MimeMultipart(); - MimeBodyPart bodyPart1 = new MimeBodyPart(new LocalTextBody(htmlBodyText, htmlBodyText), "text/html"); - MimeBodyPart bodyPart2 = new MimeBodyPart(new LocalTextBody(textBodyText, textBodyText), "text/plain"); - multipart.addBodyPart(bodyPart1); - multipart.addBodyPart(bodyPart2); - message.setBody(multipart); - assertEquals("html body", message.getTextForDisplay()); - } -} diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalMessage.java b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalMessage.java index d377bc55d..de19dc123 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalMessage.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalMessage.java @@ -124,29 +124,6 @@ public class LocalMessage extends MimeMessage { return mimeType; } - /** - * Fetch the message text for display. This always returns an HTML-ified version of the - * message, even if it was originally a text-only message. - * @return HTML version of message for display purposes or null. - * @throws MessagingException - */ - public String getTextForDisplay() throws MessagingException { - String text = null; // First try and fetch an HTML part. - Part part = MimeUtility.findFirstPartByMimeType(this, "text/html"); - if (part == null) { - // If that fails, try and get a text part. - part = MimeUtility.findFirstPartByMimeType(this, "text/plain"); - if (part != null && part.getBody() instanceof LocalTextBody) { - text = ((LocalTextBody) part.getBody()).getBodyForDisplay(); - } - } else { - // We successfully found an HTML part; do the necessary character set decoding. - text = MessageExtractor.getTextFromPart(part); - } - return text; - } - - /* Custom version of writeTo that updates the MIME message based on localMessage * changes. */ diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalTextBody.java b/k9mail/src/main/java/com/fsck/k9/mailstore/LocalTextBody.java deleted file mode 100644 index 57c4963cf..000000000 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/LocalTextBody.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fsck.k9.mailstore; - -import com.fsck.k9.mail.internet.TextBody; - -class LocalTextBody extends TextBody { - /** - * This is an HTML-ified version of the message for display purposes. - */ - private final String mBodyForDisplay; - - public LocalTextBody(String body, String bodyForDisplay) { - super(body); - this.mBodyForDisplay = bodyForDisplay; - } - - public String getBodyForDisplay() { - return mBodyForDisplay; - } - -}//LocalTextBody