1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

possible to toggle to display the quoted message to send.

This commit is contained in:
Koji Arai 2011-05-11 00:54:17 +09:00
parent e6d4299c23
commit 5d6df85aac
2 changed files with 160 additions and 127 deletions

View File

@ -237,6 +237,16 @@
android:textColor="@android:color/primary_text_light" android:textColor="@android:color/primary_text_light"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageButton
android:id="@+id/quoted_text_show"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:visibility="gone"
android:background="@drawable/btn_dialog" />
<!-- Quoted text bar --> <!-- Quoted text bar -->
<RelativeLayout <RelativeLayout
android:id="@+id/quoted_text_bar" android:id="@+id/quoted_text_bar"

View File

@ -1,6 +1,6 @@
package com.fsck.k9.activity; package com.fsck.k9.activity;
import java.io.File; import java.io.File;
import java.io.Serializable; import java.io.Serializable;
import java.util.*; import java.util.*;
@ -89,8 +89,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
"com.fsck.k9.activity.MessageCompose.ccShown"; "com.fsck.k9.activity.MessageCompose.ccShown";
private static final String STATE_KEY_BCC_SHOWN = private static final String STATE_KEY_BCC_SHOWN =
"com.fsck.k9.activity.MessageCompose.bccShown"; "com.fsck.k9.activity.MessageCompose.bccShown";
private static final String STATE_KEY_QUOTED_TEXT_SHOWN = private static final String STATE_KEY_QUOTED_TEXT_MODE =
"com.fsck.k9.activity.MessageCompose.quotedTextShown"; "com.fsck.k9.activity.MessageCompose.QuotedTextShown";
private static final String STATE_KEY_SOURCE_MESSAGE_PROCED = private static final String STATE_KEY_SOURCE_MESSAGE_PROCED =
"com.fsck.k9.activity.MessageCompose.stateKeySourceMessageProced"; "com.fsck.k9.activity.MessageCompose.stateKeySourceMessageProced";
private static final String STATE_KEY_DRAFT_UID = private static final String STATE_KEY_DRAFT_UID =
@ -161,6 +161,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
*/ */
private boolean mSourceMessageProcessed = false; private boolean mSourceMessageProcessed = false;
private enum QuotedTextMode {
NONE,
SHOW,
HIDE
};
private QuotedTextMode mQuotedTextMode = QuotedTextMode.NONE;
private TextView mFromView; private TextView mFromView;
private LinearLayout mCcWrapper; private LinearLayout mCcWrapper;
@ -172,6 +179,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private EditText mSignatureView; private EditText mSignatureView;
private EditText mMessageContentView; private EditText mMessageContentView;
private LinearLayout mAttachments; private LinearLayout mAttachments;
private ImageButton mQuotedTextShow;
private View mQuotedTextBar; private View mQuotedTextBar;
private ImageButton mQuotedTextEdit; private ImageButton mQuotedTextEdit;
private ImageButton mQuotedTextDelete; private ImageButton mQuotedTextDelete;
@ -391,6 +399,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
mMessageContentView = (EditText)findViewById(R.id.message_content); mMessageContentView = (EditText)findViewById(R.id.message_content);
mMessageContentView.getInputExtras(true).putBoolean("allowEmoji", true); mMessageContentView.getInputExtras(true).putBoolean("allowEmoji", true);
mAttachments = (LinearLayout)findViewById(R.id.attachments); mAttachments = (LinearLayout)findViewById(R.id.attachments);
mQuotedTextShow = (ImageButton)findViewById(R.id.quoted_text_show);
mQuotedTextBar = findViewById(R.id.quoted_text_bar); mQuotedTextBar = findViewById(R.id.quoted_text_bar);
mQuotedTextEdit = (ImageButton)findViewById(R.id.quoted_text_edit); mQuotedTextEdit = (ImageButton)findViewById(R.id.quoted_text_edit);
mQuotedTextDelete = (ImageButton)findViewById(R.id.quoted_text_delete); mQuotedTextDelete = (ImageButton)findViewById(R.id.quoted_text_delete);
@ -467,11 +476,10 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
* We set this to invisible by default. Other methods will turn it back on if it's * We set this to invisible by default. Other methods will turn it back on if it's
* needed. * needed.
*/ */
mQuotedTextBar.setVisibility(View.GONE);
mQuotedText.setVisibility(View.GONE);
mQuotedHTML.setVisibility(View.GONE);
mQuotedTextEdit.setVisibility(View.GONE);
showOrHideQuotedText(QuotedTextMode.NONE);
mQuotedTextShow.setOnClickListener(this);
mQuotedTextEdit.setOnClickListener(this); mQuotedTextEdit.setOnClickListener(this);
mQuotedTextDelete.setOnClickListener(this); mQuotedTextDelete.setOnClickListener(this);
@ -801,7 +809,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
outState.putParcelableArrayList(STATE_KEY_ATTACHMENTS, attachments); outState.putParcelableArrayList(STATE_KEY_ATTACHMENTS, attachments);
outState.putBoolean(STATE_KEY_CC_SHOWN, mCcView.getVisibility() == View.VISIBLE); outState.putBoolean(STATE_KEY_CC_SHOWN, mCcView.getVisibility() == View.VISIBLE);
outState.putBoolean(STATE_KEY_BCC_SHOWN, mBccView.getVisibility() == View.VISIBLE); outState.putBoolean(STATE_KEY_BCC_SHOWN, mBccView.getVisibility() == View.VISIBLE);
outState.putBoolean(STATE_KEY_QUOTED_TEXT_SHOWN, mQuotedTextBar.getVisibility() == View.VISIBLE); outState.putSerializable(STATE_KEY_QUOTED_TEXT_MODE, mQuotedTextMode);
outState.putBoolean(STATE_KEY_SOURCE_MESSAGE_PROCED, mSourceMessageProcessed); outState.putBoolean(STATE_KEY_SOURCE_MESSAGE_PROCED, mSourceMessageProcessed);
outState.putString(STATE_KEY_DRAFT_UID, mDraftUid); outState.putString(STATE_KEY_DRAFT_UID, mDraftUid);
outState.putSerializable(STATE_IDENTITY, mIdentity); outState.putSerializable(STATE_IDENTITY, mIdentity);
@ -829,17 +837,16 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
: View.GONE); : View.GONE);
mBccWrapper.setVisibility(savedInstanceState mBccWrapper.setVisibility(savedInstanceState
.getBoolean(STATE_KEY_BCC_SHOWN) ? View.VISIBLE : View.GONE); .getBoolean(STATE_KEY_BCC_SHOWN) ? View.VISIBLE : View.GONE);
if (mMessageFormat == MessageFormat.HTML) { showOrHideQuotedText((QuotedTextMode)savedInstanceState.getSerializable(STATE_KEY_QUOTED_TEXT_MODE));
mQuotedHtmlContent = (InsertableHtmlContent) savedInstanceState.getSerializable(STATE_KEY_HTML_QUOTE);
mQuotedTextBar.setVisibility(savedInstanceState.getBoolean(STATE_KEY_QUOTED_TEXT_SHOWN) ? View.VISIBLE : View.GONE); if (mQuotedTextMode != QuotedTextMode.NONE) {
mQuotedHTML.setVisibility(savedInstanceState.getBoolean(STATE_KEY_QUOTED_TEXT_SHOWN) ? View.VISIBLE : View.GONE); if (mMessageFormat == MessageFormat.HTML) {
if (mQuotedHtmlContent != null && mQuotedHtmlContent.getQuotedContent() != null) { mQuotedHtmlContent = (InsertableHtmlContent) savedInstanceState.getSerializable(STATE_KEY_HTML_QUOTE);
mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null); if (mQuotedHtmlContent != null && mQuotedHtmlContent.getQuotedContent() != null) {
mQuotedTextEdit.setVisibility(View.VISIBLE); mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null);
mQuotedTextEdit.setVisibility(View.VISIBLE);
}
} }
} else {
mQuotedTextBar.setVisibility(savedInstanceState.getBoolean(STATE_KEY_QUOTED_TEXT_SHOWN) ? View.VISIBLE : View.GONE);
mQuotedText.setVisibility(savedInstanceState.getBoolean(STATE_KEY_QUOTED_TEXT_SHOWN) ? View.VISIBLE : View.GONE);
} }
mDraftUid = savedInstanceState.getString(STATE_KEY_DRAFT_UID); mDraftUid = savedInstanceState.getString(STATE_KEY_DRAFT_UID);
mIdentity = (Identity)savedInstanceState.getSerializable(STATE_IDENTITY); mIdentity = (Identity)savedInstanceState.getSerializable(STATE_IDENTITY);
@ -904,10 +911,27 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
String text = mMessageContentView.getText().toString(); String text = mMessageContentView.getText().toString();
boolean discardQuotedText = false;
if (!isDraft && !mQuotedTextMode.equals(QuotedTextMode.SHOW)) {
discardQuotedText = true;
}
if (discardQuotedText) {
if (!isDraft) {
text = appendSignature(text);
}
// Build the body.
TextBody body = new TextBody(text);
body.setComposedMessageLength(text.length());
body.setComposedMessageOffset(0);
return body;
}
// Handle HTML separate from the rest of the text content. HTML mode doesn't allow signature after the quoted // Handle HTML separate from the rest of the text content. HTML mode doesn't allow signature after the quoted
// text, nor does it allow reply after quote. Users who want that functionality will need to stick with text // text, nor does it allow reply after quote. Users who want that functionality will need to stick with text
// mode. // mode.
if (mMessageFormat == MessageFormat.HTML) { else if (mMessageFormat == MessageFormat.HTML) {
// Add the signature. // Add the signature.
if (!isDraft) { if (!isDraft) {
text = appendSignature(text); text = appendSignature(text);
@ -917,10 +941,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
if (K9.DEBUG && mQuotedHtmlContent != null) if (K9.DEBUG && mQuotedHtmlContent != null)
Log.d(K9.LOG_TAG, "insertable: " + mQuotedHtmlContent.toDebugString()); Log.d(K9.LOG_TAG, "insertable: " + mQuotedHtmlContent.toDebugString());
if (mQuotedHtmlContent != null) { if (mQuotedHtmlContent != null) {
// Remove the quoted part if it's no longer visible.
if (mQuotedTextBar.getVisibility() != View.VISIBLE) {
mQuotedHtmlContent.clearQuotedContent();
}
// Set the insertion location based upon our reply after quote setting. Reply after // Set the insertion location based upon our reply after quote setting. Reply after
// quote makes no sense for HEADER style replies. In addition, add some extra // quote makes no sense for HEADER style replies. In addition, add some extra
@ -965,7 +985,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
text = appendSignature(text); text = appendSignature(text);
} }
if (mQuotedTextBar.getVisibility() == View.VISIBLE) { if (mQuotedTextMode != QuotedTextMode.NONE) {
if (replyAfterQuote) { if (replyAfterQuote) {
composedMessageOffset = mQuotedText.getText().toString().length() + "\n".length(); composedMessageOffset = mQuotedText.getText().toString().length() + "\n".length();
text = mQuotedText.getText().toString() + "\n" + text; text = mQuotedText.getText().toString() + "\n" + text;
@ -1140,7 +1160,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
EMAIL("e"), EMAIL("e"),
// TODO - store a reference to the message being replied so we can mark it at the time of send. // TODO - store a reference to the message being replied so we can mark it at the time of send.
ORIGINAL_MESSAGE("m"), ORIGINAL_MESSAGE("m"),
CURSOR_POSITION("p"); // Where in the message your cursor was when you saved. CURSOR_POSITION("p"), // Where in the message your cursor was when you saved.
QUOTED_TEXT_MODE("q");
private final String value; private final String value;
@ -1205,6 +1226,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
uri.appendQueryParameter(IdentityField.CURSOR_POSITION.value(), Integer.toString(mMessageContentView.getSelectionStart())); uri.appendQueryParameter(IdentityField.CURSOR_POSITION.value(), Integer.toString(mMessageContentView.getSelectionStart()));
uri.appendQueryParameter(IdentityField.QUOTED_TEXT_MODE.value(), mQuotedTextMode.name());
String k9identity = IDENTITY_VERSION_1 + uri.build().getEncodedQuery(); String k9identity = IDENTITY_VERSION_1 + uri.build().getEncodedQuery();
if (K9.DEBUG) { if (K9.DEBUG) {
@ -1279,6 +1302,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
if (tokens.hasMoreTokens()) { if (tokens.hasMoreTokens()) {
identity.put(IdentityField.EMAIL, Utility.base64Decode(tokens.nextToken())); identity.put(IdentityField.EMAIL, Utility.base64Decode(tokens.nextToken()));
} }
if (tokens.hasMoreTokens()) {
identity.put(IdentityField.QUOTED_TEXT_MODE, Utility.base64Decode(tokens.nextToken()));
}
} }
return identity; return identity;
@ -1655,8 +1681,12 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
mAttachments.removeView((View) view.getTag()); mAttachments.removeView((View) view.getTag());
mDraftNeedsSaving = true; mDraftNeedsSaving = true;
break; break;
case R.id.quoted_text_show:
showOrHideQuotedText(QuotedTextMode.SHOW);
mDraftNeedsSaving = true;
break;
case R.id.quoted_text_delete: case R.id.quoted_text_delete:
deleteQuotedText(); showOrHideQuotedText(QuotedTextMode.HIDE);
mDraftNeedsSaving = true; mDraftNeedsSaving = true;
break; break;
case R.id.quoted_text_edit: case R.id.quoted_text_edit:
@ -1673,15 +1703,40 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} }
} }
/** /*
* Delete the quoted text. * Show or Hide the quoted text according to mQuotedTextMode.
*/ */
private void deleteQuotedText() { private void showOrHideQuotedText(QuotedTextMode mode) {
mQuotedTextBar.setVisibility(View.GONE); mQuotedTextMode = mode;
mQuotedText.setVisibility(View.GONE); if (mQuotedTextMode == QuotedTextMode.NONE) {
mQuotedHTML.setVisibility(View.GONE); mQuotedTextShow.setVisibility(View.GONE);
if (mQuotedHtmlContent != null) { mQuotedTextBar.setVisibility(View.GONE);
mQuotedHtmlContent.clearQuotedContent();
mQuotedText.setVisibility(View.GONE);
mQuotedHTML.setVisibility(View.GONE);
mQuotedTextEdit.setVisibility(View.GONE);
}
else if (mQuotedTextMode == QuotedTextMode.SHOW) {
mQuotedTextShow.setVisibility(View.GONE);
mQuotedTextBar.setVisibility(View.VISIBLE);
if (mMessageFormat == MessageFormat.HTML){
mQuotedText.setVisibility(View.GONE);
mQuotedHTML.setVisibility(View.VISIBLE);
mQuotedTextEdit.setVisibility(View.VISIBLE);
}
else {
mQuotedText.setVisibility(View.VISIBLE);
mQuotedHTML.setVisibility(View.GONE);
mQuotedTextEdit.setVisibility(View.GONE);
}
}
else if (mQuotedTextMode == QuotedTextMode.HIDE) {
mQuotedTextShow.setVisibility(View.VISIBLE);
mQuotedTextBar.setVisibility(View.GONE);
mQuotedText.setVisibility(View.GONE);
mQuotedHTML.setVisibility(View.GONE);
mQuotedTextEdit.setVisibility(View.GONE);
} }
} }
@ -1974,6 +2029,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} }
} }
} else if (ACTION_EDIT_DRAFT.equals(action)) { } else if (ACTION_EDIT_DRAFT.equals(action)) {
String showQuotedTextMode = "NONE";
mDraftUid = message.getUid(); mDraftUid = message.getUid();
mSubjectView.setText(message.getSubject()); mSubjectView.setText(message.getSubject());
addAddresses(mToView, message.getRecipients(RecipientType.TO)); addAddresses(mToView, message.getRecipients(RecipientType.TO));
@ -2059,6 +2116,10 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} }
} }
if (k9identity.containsKey(IdentityField.QUOTED_TEXT_MODE)) {
showQuotedTextMode = k9identity.get(IdentityField.QUOTED_TEXT_MODE);
}
mIdentity = newIdentity; mIdentity = newIdentity;
updateSignature(); updateSignature();
@ -2073,95 +2134,62 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
// Always respect the user's current composition format preference, even if the // Always respect the user's current composition format preference, even if the
// draft was saved in a different format. // draft was saved in a different format.
// TODO - The current implementation doesn't allow a user in HTML mode to edit a draft that wasn't saved with K9mail. // TODO - The current implementation doesn't allow a user in HTML mode to edit a draft that wasn't saved with K9mail.
String messageFormat = k9identity.get(IdentityField.MESSAGE_FORMAT);
if (messageFormat == null) {
// This message probably wasn't created by us. The exception is legacy
// drafts created before the advent of HTML composition. In those cases,
// we'll display the whole message (including the quoted part) in the
// composition window. If that's the case, try and convert it to text to
// match the behavior in text mode.
mMessageContentView.setText(getBodyTextFromMessage(message, MessageFormat.TEXT));
mMessageFormat = MessageFormat.TEXT;
showOrHideQuotedText(QuotedTextMode.valueOf(showQuotedTextMode));
return;
}
mMessageFormat = MessageFormat.valueOf(messageFormat);
if (mMessageFormat == MessageFormat.HTML) { if (mMessageFormat == MessageFormat.HTML) {
if (k9identity.get(IdentityField.MESSAGE_FORMAT) == null || !MessageFormat.valueOf(k9identity.get(IdentityField.MESSAGE_FORMAT)).equals(MessageFormat.HTML)) { Part part = MimeUtility.findFirstPartByMimeType(message, "text/html");
// This message probably wasn't created by us. The exception is legacy if (part != null) { // Shouldn't happen if we were the one who saved it.
// drafts created before the advent of HTML composition. In those cases, String text = MimeUtility.getTextFromPart(part);
// we'll display the whole message (including the quoted part) in the if (K9.DEBUG) {
// composition window. If that's the case, try and convert it to text to Log.d(K9.LOG_TAG, "Loading message with offset " + bodyOffset + ", length " + bodyLength + ". Text length is " + text.length() + ".");
// match the behavior in text mode. }
mMessageContentView.setText(getBodyTextFromMessage(message, MessageFormat.TEXT));
} else {
Part part = MimeUtility.findFirstPartByMimeType(message, "text/html");
if (part != null) { // Shouldn't happen if we were the one who saved it.
String text = MimeUtility.getTextFromPart(part);
if (K9.DEBUG) {
Log.d(K9.LOG_TAG, "Loading message with offset " + bodyOffset + ", length " + bodyLength + ". Text length is " + text.length() + ".");
}
// Grab our reply text. // Grab our reply text.
String bodyText = text.substring(bodyOffset, bodyOffset + bodyLength); String bodyText = text.substring(bodyOffset, bodyOffset + bodyLength);
mMessageContentView.setText(HtmlConverter.htmlToText(bodyText)); mMessageContentView.setText(HtmlConverter.htmlToText(bodyText));
// Regenerate the quoted html without our user content in it. // Regenerate the quoted html without our user content in it.
StringBuilder quotedHTML = new StringBuilder(); StringBuilder quotedHTML = new StringBuilder();
quotedHTML.append(text.substring(0, bodyOffset)); // stuff before the reply quotedHTML.append(text.substring(0, bodyOffset)); // stuff before the reply
quotedHTML.append(text.substring(bodyOffset + bodyLength)); quotedHTML.append(text.substring(bodyOffset + bodyLength));
if (quotedHTML.length() > 0) { if (quotedHTML.length() > 0) {
mQuotedHtmlContent = new InsertableHtmlContent(); mQuotedHtmlContent = new InsertableHtmlContent();
mQuotedHtmlContent.setQuotedContent(quotedHTML); mQuotedHtmlContent.setQuotedContent(quotedHTML);
mQuotedHtmlContent.setHeaderInsertionPoint(bodyOffset); mQuotedHtmlContent.setHeaderInsertionPoint(bodyOffset);
mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null); mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null);
mQuotedHTML.setVisibility(View.VISIBLE);
mQuotedTextBar.setVisibility(View.VISIBLE);
mQuotedTextEdit.setVisibility(View.VISIBLE);
}
} }
} }
} else if (mMessageFormat == MessageFormat.TEXT) { } else if (mMessageFormat == MessageFormat.TEXT) {
MessageFormat format = k9identity.get(IdentityField.MESSAGE_FORMAT) != null Part textPart = MimeUtility.findFirstPartByMimeType(message, "text/plain");
? MessageFormat.valueOf(k9identity.get(IdentityField.MESSAGE_FORMAT)) if (textPart != null) {
: null; String text = MimeUtility.getTextFromPart(textPart);
if (format == null) { // If we had a body length (and it was valid), separate the composition from the quoted text
mMessageContentView.setText(getBodyTextFromMessage(message, MessageFormat.TEXT)); // and put them in their respective places in the UI.
} else if (format.equals(MessageFormat.HTML)) { if (bodyLength != null && bodyLength + 1 < text.length()) { // + 1 to get rid of the newline we added when saving the draft
// We are in text mode, but have an HTML message. String bodyText = text.substring(0, bodyLength);
Part htmlPart = MimeUtility.findFirstPartByMimeType(message, "text/html"); String quotedText = text.substring(bodyLength + 1, text.length());
if (htmlPart != null) { // Shouldn't happen if we were the one who saved it.
String text = MimeUtility.getTextFromPart(htmlPart);
if (K9.DEBUG) {
Log.d(K9.LOG_TAG, "Loading message with offset " + bodyOffset + ", length " + bodyLength + ". Text length is " + text.length() + ".");
}
// Grab our reply text. mMessageContentView.setText(bodyText);
String bodyText = text.substring(bodyOffset, bodyOffset + bodyLength); mQuotedText.setText(quotedText);
mMessageContentView.setText(Html.fromHtml(bodyText).toString());
// Regenerate the quoted html without out content in it.
StringBuilder quotedHTML = new StringBuilder();
quotedHTML.append(text.substring(0, bodyOffset)); // stuff before the reply
quotedHTML.append(text.substring(bodyOffset + bodyLength));
// Convert it to text.
mQuotedText.setText(HtmlConverter.htmlToText(quotedHTML.toString()));
mQuotedTextBar.setVisibility(View.VISIBLE);
mQuotedText.setVisibility(View.VISIBLE);
} else { } else {
Log.e(K9.LOG_TAG, "Found an HTML draft but couldn't find the HTML part! Something's wrong."); mMessageContentView.setText(text);
} }
} else if (format.equals(MessageFormat.TEXT)) {
Part textPart = MimeUtility.findFirstPartByMimeType(message, "text/plain");
if (textPart != null) {
String text = MimeUtility.getTextFromPart(textPart);
// If we had a body length (and it was valid), separate the composition from the quoted text
// and put them in their respective places in the UI.
if (bodyLength != null && bodyLength + 1 < text.length()) { // + 1 to get rid of the newline we added when saving the draft
String bodyText = text.substring(0, bodyLength);
String quotedText = text.substring(bodyLength + 1, text.length());
mMessageContentView.setText(bodyText);
mQuotedText.setText(quotedText);
mQuotedTextBar.setVisibility(View.VISIBLE);
mQuotedText.setVisibility(View.VISIBLE);
mQuotedHTML.setVisibility(View.VISIBLE);
} else {
mMessageContentView.setText(text);
}
}
} else {
Log.e(K9.LOG_TAG, "Unhandled message format.");
} }
} else {
Log.e(K9.LOG_TAG, "Unhandled message format.");
} }
// Set the cursor position if we have it. // Set the cursor position if we have it.
@ -2170,6 +2198,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} catch(Exception e) { } catch(Exception e) {
Log.e(K9.LOG_TAG, "Could not set cursor position in MessageCompose; ignoring.", e); Log.e(K9.LOG_TAG, "Could not set cursor position in MessageCompose; ignoring.", e);
} }
showOrHideQuotedText(QuotedTextMode.valueOf(showQuotedTextMode));
} }
} catch (MessagingException me) { } catch (MessagingException me) {
/** /**
@ -2178,8 +2208,10 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
*/ */
Log.e(K9.LOG_TAG, "Error while processing source message: ", me); Log.e(K9.LOG_TAG, "Error while processing source message: ", me);
} }
mSourceMessageProcessed = true; finally {
mDraftNeedsSaving = false; mSourceMessageProcessed = true;
mDraftNeedsSaving = false;
}
} }
/** /**
@ -2200,20 +2232,11 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
// Load the message with the reply header. // Load the message with the reply header.
mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null); mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null);
mQuotedTextBar.setVisibility(View.VISIBLE); showOrHideQuotedText(QuotedTextMode.SHOW);
mQuotedHTML.setVisibility(View.VISIBLE);
mQuotedTextEdit.setVisibility(View.VISIBLE);
mQuotedText.setVisibility(View.GONE);
} else if (mMessageFormat == MessageFormat.TEXT) { } else if (mMessageFormat == MessageFormat.TEXT) {
mQuotedText.setText(quoteOriginalTextMessage(mSourceMessage, content, mAccount.getQuoteStyle())); mQuotedText.setText(quoteOriginalTextMessage(mSourceMessage, content, mAccount.getQuoteStyle()));
mQuotedTextBar.setVisibility(View.VISIBLE); showOrHideQuotedText(QuotedTextMode.SHOW);
mQuotedText.setVisibility(View.VISIBLE);
mQuotedHtmlContent = null;
mQuotedTextEdit.setVisibility(View.GONE);
mQuotedHTML.setVisibility(View.GONE);
} }
} }
@ -2428,7 +2451,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
populateUIWithQuotedMessage(); populateUIWithQuotedMessage();
} catch (MessagingException e) { } catch (MessagingException e) {
// Hm, if we couldn't populate the UI after source reprocessing, let's just delete it? // Hm, if we couldn't populate the UI after source reprocessing, let's just delete it?
deleteQuotedText(); showOrHideQuotedText(QuotedTextMode.HIDE);
Log.e(K9.LOG_TAG, "Could not re-process source message; deleting quoted text to be safe.", e); Log.e(K9.LOG_TAG, "Could not re-process source message; deleting quoted text to be safe.", e);
} }
} else { } else {