1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-04 16:45:09 -05:00

Get rid of unused LocalTextBody

This commit is contained in:
cketti 2015-01-12 22:09:55 +01:00
parent bcd64017e3
commit 1bf159a300
3 changed files with 0 additions and 87 deletions

View File

@ -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());
}
}

View File

@ -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.
*/

View File

@ -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