mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-24 02:12:15 -05:00
possible to toggle to display the quoted message to send.
This commit is contained in:
parent
e6d4299c23
commit
5d6df85aac
@ -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"
|
||||||
|
@ -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);
|
||||||
|
showOrHideQuotedText((QuotedTextMode)savedInstanceState.getSerializable(STATE_KEY_QUOTED_TEXT_MODE));
|
||||||
|
|
||||||
|
if (mQuotedTextMode != QuotedTextMode.NONE) {
|
||||||
if (mMessageFormat == MessageFormat.HTML) {
|
if (mMessageFormat == MessageFormat.HTML) {
|
||||||
mQuotedHtmlContent = (InsertableHtmlContent) savedInstanceState.getSerializable(STATE_KEY_HTML_QUOTE);
|
mQuotedHtmlContent = (InsertableHtmlContent) savedInstanceState.getSerializable(STATE_KEY_HTML_QUOTE);
|
||||||
mQuotedTextBar.setVisibility(savedInstanceState.getBoolean(STATE_KEY_QUOTED_TEXT_SHOWN) ? View.VISIBLE : View.GONE);
|
|
||||||
mQuotedHTML.setVisibility(savedInstanceState.getBoolean(STATE_KEY_QUOTED_TEXT_SHOWN) ? View.VISIBLE : View.GONE);
|
|
||||||
if (mQuotedHtmlContent != null && mQuotedHtmlContent.getQuotedContent() != null) {
|
if (mQuotedHtmlContent != null && mQuotedHtmlContent.getQuotedContent() != null) {
|
||||||
mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null);
|
mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null);
|
||||||
mQuotedTextEdit.setVisibility(View.VISIBLE);
|
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) {
|
||||||
|
mQuotedTextMode = mode;
|
||||||
|
if (mQuotedTextMode == QuotedTextMode.NONE) {
|
||||||
|
mQuotedTextShow.setVisibility(View.GONE);
|
||||||
mQuotedTextBar.setVisibility(View.GONE);
|
mQuotedTextBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
mQuotedText.setVisibility(View.GONE);
|
mQuotedText.setVisibility(View.GONE);
|
||||||
mQuotedHTML.setVisibility(View.GONE);
|
mQuotedHTML.setVisibility(View.GONE);
|
||||||
if (mQuotedHtmlContent != null) {
|
mQuotedTextEdit.setVisibility(View.GONE);
|
||||||
mQuotedHtmlContent.clearQuotedContent();
|
}
|
||||||
|
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,15 +2134,22 @@ 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.
|
||||||
if (mMessageFormat == MessageFormat.HTML) {
|
String messageFormat = k9identity.get(IdentityField.MESSAGE_FORMAT);
|
||||||
if (k9identity.get(IdentityField.MESSAGE_FORMAT) == null || !MessageFormat.valueOf(k9identity.get(IdentityField.MESSAGE_FORMAT)).equals(MessageFormat.HTML)) {
|
if (messageFormat == null) {
|
||||||
// This message probably wasn't created by us. The exception is legacy
|
// This message probably wasn't created by us. The exception is legacy
|
||||||
// drafts created before the advent of HTML composition. In those cases,
|
// drafts created before the advent of HTML composition. In those cases,
|
||||||
// we'll display the whole message (including the quoted part) in the
|
// 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
|
// composition window. If that's the case, try and convert it to text to
|
||||||
// match the behavior in text mode.
|
// match the behavior in text mode.
|
||||||
mMessageContentView.setText(getBodyTextFromMessage(message, MessageFormat.TEXT));
|
mMessageContentView.setText(getBodyTextFromMessage(message, MessageFormat.TEXT));
|
||||||
} else {
|
mMessageFormat = MessageFormat.TEXT;
|
||||||
|
showOrHideQuotedText(QuotedTextMode.valueOf(showQuotedTextMode));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mMessageFormat = MessageFormat.valueOf(messageFormat);
|
||||||
|
|
||||||
|
if (mMessageFormat == MessageFormat.HTML) {
|
||||||
Part part = MimeUtility.findFirstPartByMimeType(message, "text/html");
|
Part part = MimeUtility.findFirstPartByMimeType(message, "text/html");
|
||||||
if (part != null) { // Shouldn't happen if we were the one who saved it.
|
if (part != null) { // Shouldn't happen if we were the one who saved it.
|
||||||
String text = MimeUtility.getTextFromPart(part);
|
String text = MimeUtility.getTextFromPart(part);
|
||||||
@ -2102,44 +2170,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
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
|
|
||||||
? MessageFormat.valueOf(k9identity.get(IdentityField.MESSAGE_FORMAT))
|
|
||||||
: null;
|
|
||||||
if (format == null) {
|
|
||||||
mMessageContentView.setText(getBodyTextFromMessage(message, MessageFormat.TEXT));
|
|
||||||
} else if (format.equals(MessageFormat.HTML)) {
|
|
||||||
// We are in text mode, but have an HTML message.
|
|
||||||
Part htmlPart = MimeUtility.findFirstPartByMimeType(message, "text/html");
|
|
||||||
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.
|
|
||||||
String bodyText = text.substring(bodyOffset, bodyOffset + bodyLength);
|
|
||||||
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 {
|
|
||||||
Log.e(K9.LOG_TAG, "Found an HTML draft but couldn't find the HTML part! Something's wrong.");
|
|
||||||
}
|
|
||||||
} else if (format.equals(MessageFormat.TEXT)) {
|
|
||||||
Part textPart = MimeUtility.findFirstPartByMimeType(message, "text/plain");
|
Part textPart = MimeUtility.findFirstPartByMimeType(message, "text/plain");
|
||||||
if (textPart != null) {
|
if (textPart != null) {
|
||||||
String text = MimeUtility.getTextFromPart(textPart);
|
String text = MimeUtility.getTextFromPart(textPart);
|
||||||
@ -2151,10 +2184,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
|
|
||||||
mMessageContentView.setText(bodyText);
|
mMessageContentView.setText(bodyText);
|
||||||
mQuotedText.setText(quotedText);
|
mQuotedText.setText(quotedText);
|
||||||
|
|
||||||
mQuotedTextBar.setVisibility(View.VISIBLE);
|
|
||||||
mQuotedText.setVisibility(View.VISIBLE);
|
|
||||||
mQuotedHTML.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
} else {
|
||||||
mMessageContentView.setText(text);
|
mMessageContentView.setText(text);
|
||||||
}
|
}
|
||||||
@ -2162,7 +2191,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
} else {
|
} else {
|
||||||
Log.e(K9.LOG_TAG, "Unhandled message format.");
|
Log.e(K9.LOG_TAG, "Unhandled message format.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Set the cursor position if we have it.
|
// Set the cursor position if we have it.
|
||||||
try {
|
try {
|
||||||
@ -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,9 +2208,11 @@ 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);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
mSourceMessageProcessed = true;
|
mSourceMessageProcessed = true;
|
||||||
mDraftNeedsSaving = false;
|
mDraftNeedsSaving = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build and populate the UI with the quoted message.
|
* Build and populate the UI with the quoted message.
|
||||||
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user