Loading k9mail-library/src/main/java/com/fsck/k9/mail/Message.java +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ public abstract class Message implements Part, CompositeBody { public abstract void setSentDate(Date sentDate, boolean hideTimeZone) throws MessagingException; public abstract Address[] getRecipients(RecipientType type) throws MessagingException; public abstract Address[] getRecipients(RecipientType type); public abstract void setRecipients(RecipientType type, Address[] addresses) throws MessagingException; Loading k9mail-library/src/main/java/com/fsck/k9/mail/internet/MimeMessage.java +19 −15 Original line number Diff line number Diff line Loading @@ -197,27 +197,31 @@ public class MimeMessage extends Message { * found the method returns an empty array. */ @Override public Address[] getRecipients(RecipientType type) throws MessagingException { if (type == RecipientType.TO) { public Address[] getRecipients(RecipientType type) { switch (type) { case TO: { if (mTo == null) { mTo = Address.parse(MimeUtility.unfold(getFirstHeader("To"))); } return mTo; } else if (type == RecipientType.CC) { } case CC: { if (mCc == null) { mCc = Address.parse(MimeUtility.unfold(getFirstHeader("CC"))); } return mCc; } else if (type == RecipientType.BCC) { } case BCC: { if (mBcc == null) { mBcc = Address.parse(MimeUtility.unfold(getFirstHeader("BCC"))); } return mBcc; } else { throw new MessagingException("Unrecognized recipient type."); } } throw new IllegalArgumentException("Unrecognized recipient type."); } @Override public void setRecipients(RecipientType type, Address[] addresses) throws MessagingException { if (type == RecipientType.TO) { Loading k9mail/src/main/java/com/fsck/k9/K9.java +14 −23 Original line number Diff line number Diff line Loading @@ -538,7 +538,6 @@ public class K9 extends Application { MessagingController.getInstance(this).addListener(new MessagingListener() { private void broadcastIntent(String action, Account account, String folder, Message message) { try { Uri uri = Uri.parse("email://messages/" + account.getAccountNumber() + "/" + Uri.encode(folder) + "/" + Uri.encode(message.getUid())); Intent intent = new Intent(action, uri); intent.putExtra(K9.Intents.EmailReceived.EXTRA_ACCOUNT, account.getDescription()); Loading @@ -557,14 +556,6 @@ public class K9 extends Application { + " folder=" + folder + " message uid=" + message.getUid() ); } catch (MessagingException e) { Log.w(K9.LOG_TAG, "Error: action=" + action + " account=" + account.getDescription() + " folder=" + folder + " message uid=" + message.getUid() ); } } private void updateUnreadWidget() { Loading k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java +5 −2 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ import com.fsck.k9.fragment.ProgressDialogFragment.CancelListener; import com.fsck.k9.helper.Contacts; import com.fsck.k9.helper.IdentityHelper; import com.fsck.k9.helper.MailTo; import com.fsck.k9.helper.ReplyToParser; import com.fsck.k9.helper.SimpleTextWatcher; import com.fsck.k9.mail.Address; import com.fsck.k9.mail.Flag; Loading Loading @@ -400,7 +401,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, RecipientMvpView recipientMvpView = new RecipientMvpView(this); ComposePgpInlineDecider composePgpInlineDecider = new ComposePgpInlineDecider(); recipientPresenter = new RecipientPresenter(this, recipientMvpView, mAccount, composePgpInlineDecider); recipientPresenter = new RecipientPresenter(this, recipientMvpView, mAccount, composePgpInlineDecider, new ReplyToParser()); mSubjectView = (EditText) findViewById(R.id.subject); mSubjectView.getInputExtras(true).putBoolean("allowEmoji", true); Loading Loading @@ -1598,7 +1600,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, * If a reply-to was included with the message use that, otherwise use the from * or sender address. */ recipientPresenter.initFromReplyToMessage(message); boolean isReplyAll = mAction == Action.REPLY_ALL; recipientPresenter.initFromReplyToMessage(message, isReplyAll); if (message.getMessageId() != null && message.getMessageId().length() > 0) { mInReplyTo = message.getMessageId(); Loading k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java +19 −56 Original line number Diff line number Diff line Loading @@ -27,15 +27,14 @@ import com.fsck.k9.activity.compose.ComposeCryptoStatus.SendErrorState; import com.fsck.k9.helper.Contacts; import com.fsck.k9.helper.MailTo; import com.fsck.k9.helper.ReplyToParser; import com.fsck.k9.helper.Utility; import com.fsck.k9.helper.ReplyToParser.ReplyToAddresses; import com.fsck.k9.mail.Address; import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.Message; import com.fsck.k9.mail.Message.RecipientType; import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mailstore.LocalMessage; import com.fsck.k9.message.PgpMessageBuilder; import com.fsck.k9.message.ComposePgpInlineDecider; import com.fsck.k9.message.PgpMessageBuilder; import com.fsck.k9.view.RecipientSelectView.Recipient; import org.openintents.openpgp.IOpenPgpService2; import org.openintents.openpgp.util.OpenPgpApi; Loading @@ -61,6 +60,7 @@ public class RecipientPresenter implements PermissionPingCallback { private final Context context; private final RecipientMvpView recipientMvpView; private final ComposePgpInlineDecider composePgpInlineDecider; private ReplyToParser replyToParser; private Account account; private String cryptoProvider; private Boolean hasContactPicker; Loading @@ -78,10 +78,11 @@ public class RecipientPresenter implements PermissionPingCallback { public RecipientPresenter(Context context, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider) { ComposePgpInlineDecider composePgpInlineDecider, ReplyToParser replyToParser) { this.recipientMvpView = recipientMvpView; this.context = context; this.composePgpInlineDecider = composePgpInlineDecider; this.replyToParser = replyToParser; recipientMvpView.setPresenter(this); onSwitchAccount(account); Loading Loading @@ -134,51 +135,18 @@ public class RecipientPresenter implements PermissionPingCallback { return false; } public void initFromReplyToMessage(Message message) { Address[] replyToAddresses = ReplyToParser.getRecipientsToReplyTo(message); try { // if we're replying to a message we sent, we probably meant // to reply to the recipient of that message if (account.isAnIdentity(replyToAddresses)) { replyToAddresses = message.getRecipients(RecipientType.TO); } addRecipientsFromAddresses(RecipientType.TO, replyToAddresses); if (message.getReplyTo().length > 0) { for (Address address : message.getFrom()) { if (!account.isAnIdentity(address) && !Utility.arrayContains(replyToAddresses, address)) { addRecipientsFromAddresses(RecipientType.TO, address); } } } for (Address address : message.getRecipients(RecipientType.TO)) { if (!account.isAnIdentity(address) && !Utility.arrayContains(replyToAddresses, address)) { addToAddresses(address); } } if (message.getRecipients(RecipientType.CC).length > 0) { for (Address address : message.getRecipients(RecipientType.CC)) { if (!account.isAnIdentity(address) && !Utility.arrayContains(replyToAddresses, address)) { addCcAddresses(address); } public void initFromReplyToMessage(Message message, boolean isReplyAll) { ReplyToAddresses replyToAddresses = isReplyAll ? replyToParser.getRecipientsToReplyAllTo(message, account) : replyToParser.getRecipientsToReplyTo(message, account); } } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } } catch (MessagingException e) { // can't happen, we know the recipient types exist throw new AssertionError(e); } } public void initFromMailto(MailTo mailTo) { Loading Loading @@ -228,7 +196,6 @@ public class RecipientPresenter implements PermissionPingCallback { } private void initRecipientsFromDraftMessage(LocalMessage message) { try { addToAddresses(message.getRecipients(RecipientType.TO)); Address[] ccRecipients = message.getRecipients(RecipientType.CC); Loading @@ -236,10 +203,6 @@ public class RecipientPresenter implements PermissionPingCallback { Address[] bccRecipients = message.getRecipients(RecipientType.BCC); addBccAddresses(bccRecipients); } catch (MessagingException e) { // can't happen, we know the recipient types exist throw new AssertionError(e); } } private void initPgpInlineFromDraftMessage(LocalMessage message) { Loading Loading
k9mail-library/src/main/java/com/fsck/k9/mail/Message.java +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ public abstract class Message implements Part, CompositeBody { public abstract void setSentDate(Date sentDate, boolean hideTimeZone) throws MessagingException; public abstract Address[] getRecipients(RecipientType type) throws MessagingException; public abstract Address[] getRecipients(RecipientType type); public abstract void setRecipients(RecipientType type, Address[] addresses) throws MessagingException; Loading
k9mail-library/src/main/java/com/fsck/k9/mail/internet/MimeMessage.java +19 −15 Original line number Diff line number Diff line Loading @@ -197,27 +197,31 @@ public class MimeMessage extends Message { * found the method returns an empty array. */ @Override public Address[] getRecipients(RecipientType type) throws MessagingException { if (type == RecipientType.TO) { public Address[] getRecipients(RecipientType type) { switch (type) { case TO: { if (mTo == null) { mTo = Address.parse(MimeUtility.unfold(getFirstHeader("To"))); } return mTo; } else if (type == RecipientType.CC) { } case CC: { if (mCc == null) { mCc = Address.parse(MimeUtility.unfold(getFirstHeader("CC"))); } return mCc; } else if (type == RecipientType.BCC) { } case BCC: { if (mBcc == null) { mBcc = Address.parse(MimeUtility.unfold(getFirstHeader("BCC"))); } return mBcc; } else { throw new MessagingException("Unrecognized recipient type."); } } throw new IllegalArgumentException("Unrecognized recipient type."); } @Override public void setRecipients(RecipientType type, Address[] addresses) throws MessagingException { if (type == RecipientType.TO) { Loading
k9mail/src/main/java/com/fsck/k9/K9.java +14 −23 Original line number Diff line number Diff line Loading @@ -538,7 +538,6 @@ public class K9 extends Application { MessagingController.getInstance(this).addListener(new MessagingListener() { private void broadcastIntent(String action, Account account, String folder, Message message) { try { Uri uri = Uri.parse("email://messages/" + account.getAccountNumber() + "/" + Uri.encode(folder) + "/" + Uri.encode(message.getUid())); Intent intent = new Intent(action, uri); intent.putExtra(K9.Intents.EmailReceived.EXTRA_ACCOUNT, account.getDescription()); Loading @@ -557,14 +556,6 @@ public class K9 extends Application { + " folder=" + folder + " message uid=" + message.getUid() ); } catch (MessagingException e) { Log.w(K9.LOG_TAG, "Error: action=" + action + " account=" + account.getDescription() + " folder=" + folder + " message uid=" + message.getUid() ); } } private void updateUnreadWidget() { Loading
k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java +5 −2 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ import com.fsck.k9.fragment.ProgressDialogFragment.CancelListener; import com.fsck.k9.helper.Contacts; import com.fsck.k9.helper.IdentityHelper; import com.fsck.k9.helper.MailTo; import com.fsck.k9.helper.ReplyToParser; import com.fsck.k9.helper.SimpleTextWatcher; import com.fsck.k9.mail.Address; import com.fsck.k9.mail.Flag; Loading Loading @@ -400,7 +401,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, RecipientMvpView recipientMvpView = new RecipientMvpView(this); ComposePgpInlineDecider composePgpInlineDecider = new ComposePgpInlineDecider(); recipientPresenter = new RecipientPresenter(this, recipientMvpView, mAccount, composePgpInlineDecider); recipientPresenter = new RecipientPresenter(this, recipientMvpView, mAccount, composePgpInlineDecider, new ReplyToParser()); mSubjectView = (EditText) findViewById(R.id.subject); mSubjectView.getInputExtras(true).putBoolean("allowEmoji", true); Loading Loading @@ -1598,7 +1600,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, * If a reply-to was included with the message use that, otherwise use the from * or sender address. */ recipientPresenter.initFromReplyToMessage(message); boolean isReplyAll = mAction == Action.REPLY_ALL; recipientPresenter.initFromReplyToMessage(message, isReplyAll); if (message.getMessageId() != null && message.getMessageId().length() > 0) { mInReplyTo = message.getMessageId(); Loading
k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java +19 −56 Original line number Diff line number Diff line Loading @@ -27,15 +27,14 @@ import com.fsck.k9.activity.compose.ComposeCryptoStatus.SendErrorState; import com.fsck.k9.helper.Contacts; import com.fsck.k9.helper.MailTo; import com.fsck.k9.helper.ReplyToParser; import com.fsck.k9.helper.Utility; import com.fsck.k9.helper.ReplyToParser.ReplyToAddresses; import com.fsck.k9.mail.Address; import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.Message; import com.fsck.k9.mail.Message.RecipientType; import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mailstore.LocalMessage; import com.fsck.k9.message.PgpMessageBuilder; import com.fsck.k9.message.ComposePgpInlineDecider; import com.fsck.k9.message.PgpMessageBuilder; import com.fsck.k9.view.RecipientSelectView.Recipient; import org.openintents.openpgp.IOpenPgpService2; import org.openintents.openpgp.util.OpenPgpApi; Loading @@ -61,6 +60,7 @@ public class RecipientPresenter implements PermissionPingCallback { private final Context context; private final RecipientMvpView recipientMvpView; private final ComposePgpInlineDecider composePgpInlineDecider; private ReplyToParser replyToParser; private Account account; private String cryptoProvider; private Boolean hasContactPicker; Loading @@ -78,10 +78,11 @@ public class RecipientPresenter implements PermissionPingCallback { public RecipientPresenter(Context context, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider) { ComposePgpInlineDecider composePgpInlineDecider, ReplyToParser replyToParser) { this.recipientMvpView = recipientMvpView; this.context = context; this.composePgpInlineDecider = composePgpInlineDecider; this.replyToParser = replyToParser; recipientMvpView.setPresenter(this); onSwitchAccount(account); Loading Loading @@ -134,51 +135,18 @@ public class RecipientPresenter implements PermissionPingCallback { return false; } public void initFromReplyToMessage(Message message) { Address[] replyToAddresses = ReplyToParser.getRecipientsToReplyTo(message); try { // if we're replying to a message we sent, we probably meant // to reply to the recipient of that message if (account.isAnIdentity(replyToAddresses)) { replyToAddresses = message.getRecipients(RecipientType.TO); } addRecipientsFromAddresses(RecipientType.TO, replyToAddresses); if (message.getReplyTo().length > 0) { for (Address address : message.getFrom()) { if (!account.isAnIdentity(address) && !Utility.arrayContains(replyToAddresses, address)) { addRecipientsFromAddresses(RecipientType.TO, address); } } } for (Address address : message.getRecipients(RecipientType.TO)) { if (!account.isAnIdentity(address) && !Utility.arrayContains(replyToAddresses, address)) { addToAddresses(address); } } if (message.getRecipients(RecipientType.CC).length > 0) { for (Address address : message.getRecipients(RecipientType.CC)) { if (!account.isAnIdentity(address) && !Utility.arrayContains(replyToAddresses, address)) { addCcAddresses(address); } public void initFromReplyToMessage(Message message, boolean isReplyAll) { ReplyToAddresses replyToAddresses = isReplyAll ? replyToParser.getRecipientsToReplyAllTo(message, account) : replyToParser.getRecipientsToReplyTo(message, account); } } addToAddresses(replyToAddresses.to); addCcAddresses(replyToAddresses.cc); boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message); if (shouldSendAsPgpInline) { cryptoEnablePgpInline = true; } } catch (MessagingException e) { // can't happen, we know the recipient types exist throw new AssertionError(e); } } public void initFromMailto(MailTo mailTo) { Loading Loading @@ -228,7 +196,6 @@ public class RecipientPresenter implements PermissionPingCallback { } private void initRecipientsFromDraftMessage(LocalMessage message) { try { addToAddresses(message.getRecipients(RecipientType.TO)); Address[] ccRecipients = message.getRecipients(RecipientType.CC); Loading @@ -236,10 +203,6 @@ public class RecipientPresenter implements PermissionPingCallback { Address[] bccRecipients = message.getRecipients(RecipientType.BCC); addBccAddresses(bccRecipients); } catch (MessagingException e) { // can't happen, we know the recipient types exist throw new AssertionError(e); } } private void initPgpInlineFromDraftMessage(LocalMessage message) { Loading