Fix defect in r996
Prepare for disabling notification on messages the account identities sent.
This commit is contained in:
parent
5977809fe0
commit
0f24c6a28b
3 changed files with 43 additions and 14 deletions
|
@ -42,6 +42,7 @@ public class Account implements Serializable {
|
|||
int mDisplayCount;
|
||||
long mLastAutomaticCheckTime;
|
||||
boolean mNotifyNewMail;
|
||||
boolean mNotifySelfNewMail;
|
||||
String mDraftsFolderName;
|
||||
String mSentFolderName;
|
||||
String mTrashFolderName;
|
||||
|
@ -86,6 +87,7 @@ public class Account implements Serializable {
|
|||
mNotifyNewMail = true;
|
||||
mNotifySync = true;
|
||||
mVibrate = false;
|
||||
mNotifySelfNewMail = true;
|
||||
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
||||
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
||||
mFolderPushMode = FolderMode.FIRST_CLASS;
|
||||
|
@ -618,6 +620,23 @@ public class Account implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
public boolean isAnIdentity(Address[] addrs)
|
||||
{
|
||||
if (addrs == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (Address addr : addrs)
|
||||
{
|
||||
if (findIdentity(addr) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAnIdentity(Address addr)
|
||||
{
|
||||
return findIdentity(addr) != null;
|
||||
|
@ -810,4 +829,14 @@ public class Account implements Serializable {
|
|||
this.mIsSignatureBeforeQuotedText = mIsSignatureBeforeQuotedText;
|
||||
}
|
||||
|
||||
public boolean isNotifySelfNewMail()
|
||||
{
|
||||
return mNotifySelfNewMail;
|
||||
}
|
||||
|
||||
public void setNotifySelfNewMail(boolean notifySelfNewMail)
|
||||
{
|
||||
mNotifySelfNewMail = notifySelfNewMail;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1119,7 +1119,10 @@ public class MessagingController implements Runnable {
|
|||
public void messageFinished(Message message, int number, int ofTotal) {
|
||||
try {
|
||||
if (!message.isSet(Flag.SEEN)) {
|
||||
newMessages.incrementAndGet();
|
||||
if ( account.isNotifySelfNewMail() || account.isAnIdentity(message.getFrom()) == false)
|
||||
{
|
||||
newMessages.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
// Store the new message locally
|
||||
|
@ -3325,14 +3328,16 @@ public class MessagingController implements Runnable {
|
|||
});
|
||||
}
|
||||
|
||||
public void notifyAccount(Context context, Account thisAccount, int unreadMessageCount)
|
||||
public void notifyAccount(Context context, Account thisAccount, int newMailCount, int unreadMessageCount)
|
||||
{
|
||||
Log.i(Email.LOG_TAG, "notifyAccount Account " + thisAccount.getDescription() + ", newMailCount = " + newMailCount
|
||||
+ ", unreadMessageCount = " + unreadMessageCount);
|
||||
boolean isNotifyAccount = thisAccount.isNotifyNewMail();
|
||||
if (isNotifyAccount)
|
||||
{
|
||||
NotificationManager notifMgr =
|
||||
(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (unreadMessageCount > 0)
|
||||
if (newMailCount > 0 && unreadMessageCount > 0)
|
||||
{
|
||||
String notice = context.getString(R.string.notification_new_one_account_fmt, unreadMessageCount,
|
||||
thisAccount.getDescription());
|
||||
|
@ -3744,7 +3749,7 @@ public class MessagingController implements Runnable {
|
|||
localFolder.open(OpenMode.READ_WRITE);
|
||||
remoteFolder.open(OpenMode.READ_WRITE);
|
||||
|
||||
downloadMessages(account, remoteFolder, localFolder, messages);
|
||||
int newCount = downloadMessages(account, remoteFolder, localFolder, messages);
|
||||
int unreadCount = 0;
|
||||
for (Message message : messages)
|
||||
{
|
||||
|
@ -3759,11 +3764,11 @@ public class MessagingController implements Runnable {
|
|||
int unreadMessageCount = account.getUnreadMessageCount(mApplication, mApplication);
|
||||
if (doNotify && unreadCount > 0)
|
||||
{
|
||||
notifyAccount(mApplication, account, unreadMessageCount);
|
||||
notifyAccount(mApplication, account, newCount, unreadMessageCount);
|
||||
}
|
||||
if (unreadCount == 0)
|
||||
{
|
||||
notifyAccount(mApplication, account, unreadMessageCount);
|
||||
notifyAccount(mApplication, account, newCount, unreadMessageCount);
|
||||
}
|
||||
|
||||
for (MessagingListener l : getListeners())
|
||||
|
|
|
@ -145,14 +145,9 @@ public class PollService extends CoreService
|
|||
try
|
||||
{
|
||||
int unreadMessageCount = thisAccount.getUnreadMessageCount(context, getApplication());
|
||||
if (unreadMessageCount > 0 && newMailCount > 0)
|
||||
{
|
||||
MessagingController.getInstance(getApplication()).notifyAccount(context, thisAccount, unreadMessageCount);
|
||||
}
|
||||
else if (unreadMessageCount == 0)
|
||||
{
|
||||
MessagingController.getInstance(getApplication()).notifyAccount(context, thisAccount, unreadMessageCount);
|
||||
}
|
||||
MessagingController.getInstance(getApplication()).notifyAccount(context, thisAccount,
|
||||
newMailCount, unreadMessageCount);
|
||||
|
||||
}
|
||||
catch (MessagingException me)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue