From 548b8e07a6f8ae10246914952712b2565fdde6c7 Mon Sep 17 00:00:00 2001
From: Joe Steele
- * No HTML headers or footers are added to the result. + * No HTML headers or footers are added to the result. Headers and footers + * are added at display time in + * {@link com.fsck.k9.view#MessageWebView.setText(String) MessageWebView.setText()} *
* * @param text @@ -187,7 +189,9 @@ public class HtmlConverter { * Attempts to do smart replacement for large documents to prevent OOM * errors. *- * No HTML headers or footers are added to the result. + * No HTML headers or footers are added to the result. Headers and footers + * are added at display time in + * {@link com.fsck.k9.view#MessageWebView.setText(String) MessageWebView.setText()} *
** To convert to a fragment, use {@link #textToHtmlFragment(String)} . diff --git a/src/com/fsck/k9/view/AccessibleWebView.java b/src/com/fsck/k9/view/AccessibleWebView.java index 5dd8bb9a8..323833d26 100644 --- a/src/com/fsck/k9/view/AccessibleWebView.java +++ b/src/com/fsck/k9/view/AccessibleWebView.java @@ -68,10 +68,8 @@ public class AccessibleWebView extends TextView { return mDummyWebView.getSettings(); } - public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, - String historyUrl) { - mHtmlSource = data; - this.setText(Html.fromHtml(mHtmlSource, null, null)); + public void setText(String text) { + this.setText(Html.fromHtml(text, null, null)); // Let everyone know that loading has finished. if (mListeners != null) { diff --git a/src/com/fsck/k9/view/MessageWebView.java b/src/com/fsck/k9/view/MessageWebView.java index 394c0aa9e..e673f4134 100644 --- a/src/com/fsck/k9/view/MessageWebView.java +++ b/src/com/fsck/k9/view/MessageWebView.java @@ -151,7 +151,19 @@ public class MessageWebView extends TitleBarWebView { } } - public void setText(String text, String contentType) { + /** + * Load a message body into a {@code MessageWebView} + * + *
+ * Before loading, the text is wrapped in an HTML header and footer + * so that it displays properly. + *
+ * + * @param text + * The message body to display. Assumed to be MIME type text/html. + */ + public void setText(String text) { + // Include a meta tag so the WebView will not use a fixed viewport width of 980 px String content = ""; if (K9.getK9MessageViewTheme() == K9.Theme.DARK) { content += " "; } content += "" + text + ""; - loadDataWithBaseURL("http://", content, contentType, "utf-8", null); + loadDataWithBaseURL("http://", content, "text/html", "utf-8", null); } /* diff --git a/src/com/fsck/k9/view/SingleMessageView.java b/src/com/fsck/k9/view/SingleMessageView.java index 40b6ba68c..b9b982422 100644 --- a/src/com/fsck/k9/view/SingleMessageView.java +++ b/src/com/fsck/k9/view/SingleMessageView.java @@ -400,7 +400,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener, // Allow network access first... setLoadPictures(true); // ...then re-populate the WebView with the message text - loadBodyFromText(mText, "text/html"); + loadBodyFromText(mText); break; } } @@ -611,7 +611,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener, } if (text != null) { - loadBodyFromText(text, "text/html"); + loadBodyFromText(text); updateCryptoLayout(account.getCryptoProvider(), pgpData, message); } else { showStatusMessage(getContext().getString(R.string.webview_empty_message)); @@ -622,15 +622,15 @@ public class SingleMessageView extends LinearLayout implements OnClickListener, String text = "