diff options
author | Marc Blank <mblank@google.com> | 2012-04-19 15:09:45 -0700 |
---|---|---|
committer | Marc Blank <mblank@google.com> | 2012-04-19 15:10:21 -0700 |
commit | 5c200f433cc35d434c1a039d7f24865ef8b09782 (patch) | |
tree | 776bfabc6c8bcab914840cf0f16e00426258e8df /src/com/android/mail/compose/QuotedTextView.java | |
parent | c62440c9a3d1a827ac67e9ea772bf2673f7ff560 (diff) | |
download | android_packages_apps_UnifiedEmail-5c200f433cc35d434c1a039d7f24865ef8b09782.tar.gz android_packages_apps_UnifiedEmail-5c200f433cc35d434c1a039d7f24865ef8b09782.tar.bz2 android_packages_apps_UnifiedEmail-5c200f433cc35d434c1a039d7f24865ef8b09782.zip |
Enable use of plain text body for quoted text
Bug: 6367954
Change-Id: I707624b895c057a267a4000c64bd6dec35ab7abe
Diffstat (limited to 'src/com/android/mail/compose/QuotedTextView.java')
-rw-r--r-- | src/com/android/mail/compose/QuotedTextView.java | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/com/android/mail/compose/QuotedTextView.java b/src/com/android/mail/compose/QuotedTextView.java index 16923575a..5337ca4b2 100644 --- a/src/com/android/mail/compose/QuotedTextView.java +++ b/src/com/android/mail/compose/QuotedTextView.java @@ -15,15 +15,10 @@ */ package com.android.mail.compose; -import com.android.mail.R; -import com.android.mail.providers.Message; -import com.android.mail.utils.Utils; - -import java.text.DateFormat; -import java.util.Date; - import android.content.Context; import android.content.res.Resources; +import android.text.Html; +import android.text.SpannedString; import android.text.TextUtils; import android.util.AttributeSet; import android.view.LayoutInflater; @@ -34,10 +29,16 @@ import android.widget.Button; import android.widget.CheckBox; import android.widget.LinearLayout; +import com.android.mail.R; +import com.android.mail.providers.Message; +import com.android.mail.utils.Utils; import com.google.android.common.html.parser.HtmlDocument; import com.google.android.common.html.parser.HtmlParser; import com.google.android.common.html.parser.HtmlTreeBuilder; +import java.text.DateFormat; +import java.util.Date; + /* * View for displaying the quoted text in the compose screen for a reply * or forward. A close button is included in the upper right to remove @@ -239,8 +240,20 @@ class QuotedTextView extends LinearLayout implements OnClickListener { public void onRespondInline(String text); } + private String getHtmlText(Message message) { + if (message.bodyHtml != null) { + return message.bodyHtml; + } else if (message.bodyText != null) { + // STOPSHIP Sanitize this + return Html.toHtml(new SpannedString(message.bodyText)); + } else { + return ""; + } + } + public void setQuotedText(int action, Message refMessage, boolean allow) { setVisibility(View.VISIBLE); + String htmlText = getHtmlText(refMessage); StringBuffer quotedText = new StringBuffer(); DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); Date date = new Date(refMessage.dateReceivedMs); @@ -255,7 +268,7 @@ class QuotedTextView extends LinearLayout implements OnClickListener { refMessage.from, true))); quotedText.append(HEADER_SEPARATOR); quotedText.append(BLOCKQUOTE_BEGIN); - quotedText.append(refMessage.bodyHtml); + quotedText.append(htmlText); quotedText.append(BLOCKQUOTE_END); quotedText.append(QUOTE_END); } else if (action == ComposeActivity.FORWARD) { @@ -272,7 +285,7 @@ class QuotedTextView extends LinearLayout implements OnClickListener { Utils.cleanUpString(ccAddresses, true /* remove empty quotes */))); } quotedText.append(HEADER_SEPARATOR); - quotedText.append(refMessage.bodyHtml); + quotedText.append(htmlText); quotedText.append(QUOTE_END); setQuotedText(quotedText); allowQuotedText(allow); @@ -281,7 +294,6 @@ class QuotedTextView extends LinearLayout implements OnClickListener { allowRespondInline(true); } - /** * Set quoted text. Some use cases may not want to display the check box (i.e. forwarding) so * allow control of that. |