diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 7089a8471..d90e51f8f 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -677,11 +677,13 @@ @string/account_settings_message_format_text @string/account_settings_message_format_html + @string/account_settings_message_format_auto TEXT HTML + AUTO diff --git a/res/values/strings.xml b/res/values/strings.xml index 7b0409b04..94a4449a7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -568,6 +568,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin Message Format Plain Text (images and formatting will be removed) HTML (images and formatting are preserved) + Automatic (plain text unless replying to an html message) Read receipt Always request a read receipt diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java index 3a891c286..fc324a2b8 100644 --- a/src/com/fsck/k9/Account.java +++ b/src/com/fsck/k9/Account.java @@ -191,7 +191,7 @@ public class Account implements BaseAccount { } public enum MessageFormat { - TEXT, HTML + TEXT, HTML, AUTO } protected Account(Context context) { diff --git a/src/com/fsck/k9/activity/MessageCompose.java b/src/com/fsck/k9/activity/MessageCompose.java index 3a282a947..c25279a4d 100644 --- a/src/com/fsck/k9/activity/MessageCompose.java +++ b/src/com/fsck/k9/activity/MessageCompose.java @@ -75,6 +75,7 @@ import com.fsck.k9.mail.store.LocalStore.LocalAttachmentBody; public class MessageCompose extends K9Activity implements OnClickListener, OnFocusChangeListener { private static final int DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE = 1; + private static final String ACTION_COMPOSE = "com.fsck.k9.intent.action.COMPOSE"; private static final String ACTION_REPLY = "com.fsck.k9.intent.action.REPLY"; private static final String ACTION_REPLY_ALL = "com.fsck.k9.intent.action.REPLY_ALL"; private static final String ACTION_FORWARD = "com.fsck.k9.intent.action.FORWARD"; @@ -280,6 +281,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc } Intent i = new Intent(context, MessageCompose.class); i.putExtra(EXTRA_ACCOUNT, account.getUuid()); + i.setAction(ACTION_COMPOSE); context.startActivity(i); } @@ -533,6 +535,16 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc } mMessageFormat = mAccount.getMessageFormat(); + if (mMessageFormat == MessageFormat.AUTO) { + if (ACTION_COMPOSE.equals(action)) { + mMessageFormat = MessageFormat.TEXT; + } else if (mSourceMessageBody != null) { + // mSourceMessageBody is set to something when replying to and forwarding decrypted + // messages, so we set the format to plain text. + mMessageFormat = MessageFormat.TEXT; + } + } + mReadReceipt = mAccount.isMessageReadReceiptAlways(); if (!mSourceMessageProcessed) { @@ -2243,6 +2255,12 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc * @throws MessagingException */ private void populateUIWithQuotedMessage(boolean shown) throws MessagingException { + if (mMessageFormat == MessageFormat.AUTO) { + mMessageFormat = MimeUtility.findFirstPartByMimeType(mSourceMessage, "text/html") == null + ? MessageFormat.TEXT + : MessageFormat.HTML; + } + // TODO -- I am assuming that mSourceMessageBody will always be a text part. Is this a safe assumption? // Handle the original message in the reply