public void setQuotedText(int action, Message refMessage, boolean allow) { setVisibility(View.VISIBLE); String htmlText = getHtmlText(refMessage); StringBuilder quotedText = new StringBuilder(); DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); Date date = new Date(refMessage.dateReceivedMs); Resources resources = getContext().getResources(); if (action == ComposeActivity.REPLY || action == ComposeActivity.REPLY_ALL) { quotedText.append(sQuoteBegin); quotedText.append( String.format( resources.getString(R.string.reply_attribution), dateFormat.format(date), Utils.cleanUpString(refMessage.getFrom(), true))); quotedText.append(HEADER_SEPARATOR); quotedText.append(BLOCKQUOTE_BEGIN); quotedText.append(htmlText); quotedText.append(BLOCKQUOTE_END); quotedText.append(QUOTE_END); } else if (action == ComposeActivity.FORWARD) { quotedText.append(sQuoteBegin); quotedText.append( String.format( resources.getString(R.string.forward_attribution), Utils.cleanUpString(refMessage.getFrom(), true /* remove empty quotes */), dateFormat.format(date), Utils.cleanUpString(refMessage.subject, false /* don't remove empty quotes */), Utils.cleanUpString(refMessage.getTo(), true))); String ccAddresses = refMessage.getCc(); quotedText.append( String.format( resources.getString(R.string.cc_attribution), Utils.cleanUpString(ccAddresses, true /* remove empty quotes */))); quotedText.append(HEADER_SEPARATOR); quotedText.append(BLOCKQUOTE_BEGIN); quotedText.append(htmlText); quotedText.append(BLOCKQUOTE_END); quotedText.append(QUOTE_END); } setQuotedText(quotedText); allowQuotedText(allow); // If there is quoted text, we always allow respond inline, since this // may be a forward. allowRespondInline(true); }