mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 09:08:49 -05:00
. Fixed issue 423:
. HTMLized version of plain text email is not loaded up as a MIME part of the message anymore. We use a custom seperate variable in the text body class.
This commit is contained in:
parent
435e2c3532
commit
23797b62ee
@ -9,7 +9,6 @@ import java.io.OutputStream;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
@ -26,11 +25,7 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Process;
|
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.text.util.Regex;
|
|
||||||
import android.util.Config;
|
import android.util.Config;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@ -56,8 +51,6 @@ import com.android.email.MessagingController;
|
|||||||
import com.android.email.MessagingListener;
|
import com.android.email.MessagingListener;
|
||||||
import com.android.email.R;
|
import com.android.email.R;
|
||||||
import com.android.email.Utility;
|
import com.android.email.Utility;
|
||||||
import com.android.email.activity.FolderMessageList.FolderMessageListAdapter.FolderInfoHolder;
|
|
||||||
import com.android.email.activity.FolderMessageList.FolderMessageListAdapter.MessageInfoHolder;
|
|
||||||
import com.android.email.mail.Address;
|
import com.android.email.mail.Address;
|
||||||
import com.android.email.mail.Flag;
|
import com.android.email.mail.Flag;
|
||||||
import com.android.email.mail.Message;
|
import com.android.email.mail.Message;
|
||||||
@ -65,11 +58,10 @@ import com.android.email.mail.MessagingException;
|
|||||||
import com.android.email.mail.Multipart;
|
import com.android.email.mail.Multipart;
|
||||||
import com.android.email.mail.Part;
|
import com.android.email.mail.Part;
|
||||||
import com.android.email.mail.Message.RecipientType;
|
import com.android.email.mail.Message.RecipientType;
|
||||||
import com.android.email.mail.internet.MimeHeader;
|
|
||||||
import com.android.email.mail.internet.MimeUtility;
|
import com.android.email.mail.internet.MimeUtility;
|
||||||
import com.android.email.mail.store.LocalStore.LocalAttachmentBody;
|
|
||||||
import com.android.email.mail.store.LocalStore.LocalAttachmentBodyPart;
|
import com.android.email.mail.store.LocalStore.LocalAttachmentBodyPart;
|
||||||
import com.android.email.mail.store.LocalStore.LocalMessage;
|
import com.android.email.mail.store.LocalStore.LocalMessage;
|
||||||
|
import com.android.email.mail.store.LocalStore.LocalTextBody;
|
||||||
import com.android.email.provider.AttachmentProvider;
|
import com.android.email.provider.AttachmentProvider;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
@ -1057,12 +1049,28 @@ public class MessageView extends Activity
|
|||||||
Spannable markup;
|
Spannable markup;
|
||||||
MessageView.this.mMessage = message;
|
MessageView.this.mMessage = message;
|
||||||
try {
|
try {
|
||||||
|
String text;
|
||||||
Part part = MimeUtility.findFirstPartByMimeType(mMessage, "text/html");
|
Part part = MimeUtility.findFirstPartByMimeType(mMessage, "text/html");
|
||||||
if (part == null) {
|
if (part == null) {
|
||||||
part = MimeUtility.findFirstPartByMimeType(mMessage, "text/plain");
|
part = MimeUtility.findFirstPartByMimeType(mMessage, "text/plain");
|
||||||
|
if (part == null) {
|
||||||
|
text = null;
|
||||||
}
|
}
|
||||||
if (part != null) {
|
else {
|
||||||
String text = MimeUtility.getTextFromPart(part);
|
LocalTextBody body = (LocalTextBody)part.getBody();
|
||||||
|
if (body == null) {
|
||||||
|
text = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
text = body.getBodyForDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
text = MimeUtility.getTextFromPart(part);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text != null) {
|
||||||
/*
|
/*
|
||||||
* TODO this should be smarter, change to regex for img, but consider how to
|
* TODO this should be smarter, change to regex for img, but consider how to
|
||||||
* get background images and a million other things that HTML allows.
|
* get background images and a million other things that HTML allows.
|
||||||
@ -1070,8 +1078,10 @@ public class MessageView extends Activity
|
|||||||
mHandler.showShowPictures(text.contains("<img"));
|
mHandler.showShowPictures(text.contains("<img"));
|
||||||
mMessageContentView.loadDataWithBaseURL("email://", text, "text/html", "utf-8", null);
|
mMessageContentView.loadDataWithBaseURL("email://", text, "text/html", "utf-8", null);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
mMessageContentView.loadUrl("file:///android_asset/empty.html");
|
mMessageContentView.loadUrl("file:///android_asset/empty.html");
|
||||||
|
}
|
||||||
|
|
||||||
renderAttachments(mMessage, 0);
|
renderAttachments(mMessage, 0);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@ -1079,8 +1089,7 @@ public class MessageView extends Activity
|
|||||||
Log.v(Email.LOG_TAG, "loadMessageForViewBodyAvailable", e);
|
Log.v(Email.LOG_TAG, "loadMessageForViewBodyAvailable", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}//loadMessageForViewBodyAvailable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -802,15 +802,14 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
String htmlContent = cursor.getString(0);
|
String htmlContent = cursor.getString(0);
|
||||||
String textContent = cursor.getString(1);
|
String textContent = cursor.getString(1);
|
||||||
|
|
||||||
if (htmlContent != null) {
|
if (textContent != null) {
|
||||||
TextBody body = new TextBody(htmlContent);
|
LocalTextBody body = new LocalTextBody(textContent, htmlContent);
|
||||||
MimeBodyPart bp = new MimeBodyPart(body, "text/html");
|
MimeBodyPart bp = new MimeBodyPart(body, "text/plain");
|
||||||
mp.addBodyPart(bp);
|
mp.addBodyPart(bp);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (textContent != null) {
|
TextBody body = new TextBody(htmlContent);
|
||||||
TextBody body = new TextBody(textContent);
|
MimeBodyPart bp = new MimeBodyPart(body, "text/html");
|
||||||
MimeBodyPart bp = new MimeBodyPart(body, "text/plain");
|
|
||||||
mp.addBodyPart(bp);
|
mp.addBodyPart(bp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1509,6 +1508,28 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class LocalTextBody extends TextBody {
|
||||||
|
private String mBodyForDisplay;
|
||||||
|
|
||||||
|
public LocalTextBody(String body) {
|
||||||
|
super(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalTextBody(String body, String bodyForDisplay) throws MessagingException {
|
||||||
|
super(body);
|
||||||
|
this.mBodyForDisplay = bodyForDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBodyForDisplay() {
|
||||||
|
return mBodyForDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyForDisplay(String mBodyForDisplay) {
|
||||||
|
this.mBodyForDisplay = mBodyForDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
}//LocalTextBody
|
||||||
|
|
||||||
public class LocalMessage extends MimeMessage {
|
public class LocalMessage extends MimeMessage {
|
||||||
private long mId;
|
private long mId;
|
||||||
private int mAttachmentCount;
|
private int mAttachmentCount;
|
||||||
|
Loading…
Reference in New Issue
Block a user