mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-11 20:15:03 -05:00
Minor cleanup so that we only broadcast the message received intent once
This commit is contained in:
parent
d3803e5e0f
commit
7323fe67fd
@ -0,0 +1,34 @@
|
|||||||
|
package com.android.email;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.util.Log;
|
||||||
|
import com.android.email.mail.Address;
|
||||||
|
import com.android.email.mail.Message;
|
||||||
|
import com.android.email.mail.MessagingException;
|
||||||
|
|
||||||
|
public class IntentBroadcastingMessagingListener
|
||||||
|
extends MessagingListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void synchronizeMailboxNewMessage(Context context, Account account, String folder, Message message) {
|
||||||
|
try {
|
||||||
|
Uri uri = Uri.parse("email://messages/" + account.getAccountNumber() + "/" + Uri.encode(folder) + "/" + Uri.encode(message.getUid()));
|
||||||
|
android.content.Intent intent = new android.content.Intent(Intent.ACTION_EMAIL_RECEIVED, uri);
|
||||||
|
intent.putExtra(Intent.EXTRA_ACCOUNT, account.getDescription());
|
||||||
|
intent.putExtra(Intent.EXTRA_FOLDER, folder);
|
||||||
|
intent.putExtra(Intent.EXTRA_SENT_DATE, message.getSentDate());
|
||||||
|
intent.putExtra(Intent.EXTRA_FROM, Address.toString(message.getFrom()));
|
||||||
|
intent.putExtra(Intent.EXTRA_TO, Address.toString(message.getRecipients(Message.RecipientType.TO)));
|
||||||
|
intent.putExtra(Intent.EXTRA_CC, Address.toString(message.getRecipients(Message.RecipientType.CC)));
|
||||||
|
intent.putExtra(Intent.EXTRA_BCC, Address.toString(message.getRecipients(Message.RecipientType.BCC)));
|
||||||
|
intent.putExtra(Intent.EXTRA_SUBJECT, message.getSubject());
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
Log.d(Email.LOG_TAG, "Broadcasted intent: " + message.getSubject());
|
||||||
|
}
|
||||||
|
catch (MessagingException e) {
|
||||||
|
Log.w(Email.LOG_TAG, "Account=" + account.getName() + " folder=" + folder + "message uid=" + message.getUid(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}//IntentBroadcastingMessagingListener
|
@ -227,6 +227,8 @@ public class MessagingController implements Runnable {
|
|||||||
mApplication = application;
|
mApplication = application;
|
||||||
mThread = new Thread(this);
|
mThread = new Thread(this);
|
||||||
mThread.start();
|
mThread.start();
|
||||||
|
|
||||||
|
addListener(new IntentBroadcastingMessagingListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String logmess) {
|
public void log(String logmess) {
|
||||||
|
@ -3,12 +3,8 @@ package com.android.email;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.util.Log;
|
|
||||||
import com.android.email.mail.Address;
|
|
||||||
import com.android.email.mail.Folder;
|
import com.android.email.mail.Folder;
|
||||||
import com.android.email.mail.Message;
|
import com.android.email.mail.Message;
|
||||||
import com.android.email.mail.MessagingException;
|
|
||||||
import com.android.email.mail.Part;
|
import com.android.email.mail.Part;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,24 +63,7 @@ public class MessagingListener {
|
|||||||
public void synchronizeMailboxStarted(Account account, String folder) {
|
public void synchronizeMailboxStarted(Account account, String folder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void synchronizeMailboxNewMessage(Context context, Account account, String folder, Message message) {
|
public void synchronizeMailboxNewMessage(Context context, Account account, String folder, Message message) {
|
||||||
try {
|
|
||||||
Uri uri = Uri.parse("email://messages/" + account.getAccountNumber() + "/" + Uri.encode(folder) + "/" + Uri.encode(message.getUid()));
|
|
||||||
android.content.Intent intent = new android.content.Intent(Intent.ACTION_EMAIL_RECEIVED, uri);
|
|
||||||
intent.putExtra(Intent.EXTRA_ACCOUNT, account.getDescription());
|
|
||||||
intent.putExtra(Intent.EXTRA_FOLDER, folder);
|
|
||||||
intent.putExtra(Intent.EXTRA_SENT_DATE, message.getSentDate());
|
|
||||||
intent.putExtra(Intent.EXTRA_FROM, Address.toString(message.getFrom()));
|
|
||||||
intent.putExtra(Intent.EXTRA_TO, Address.toString(message.getRecipients(Message.RecipientType.TO)));
|
|
||||||
intent.putExtra(Intent.EXTRA_CC, Address.toString(message.getRecipients(Message.RecipientType.CC)));
|
|
||||||
intent.putExtra(Intent.EXTRA_BCC, Address.toString(message.getRecipients(Message.RecipientType.BCC)));
|
|
||||||
intent.putExtra(Intent.EXTRA_SUBJECT, message.getSubject());
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
Log.d(Email.LOG_TAG, "Broadcasted intent: " + message.getSubject());
|
|
||||||
}
|
|
||||||
catch (MessagingException e) {
|
|
||||||
Log.w(Email.LOG_TAG, "Account=" + account.getName() + " folder=" + folder + "message uid=" + message.getUid(), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void synchronizeMailboxAddOrUpdateMessage(Account account, String folder, Message message) {
|
public void synchronizeMailboxAddOrUpdateMessage(Account account, String folder, Message message) {
|
||||||
|
Loading…
Reference in New Issue
Block a user