mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-11 20:50:19 -05:00
Fix defect in r996
Prepare for disabling notification on messages the account identities sent.
This commit is contained in:
parent
5977809fe0
commit
0f24c6a28b
@ -42,6 +42,7 @@ public class Account implements Serializable {
|
|||||||
int mDisplayCount;
|
int mDisplayCount;
|
||||||
long mLastAutomaticCheckTime;
|
long mLastAutomaticCheckTime;
|
||||||
boolean mNotifyNewMail;
|
boolean mNotifyNewMail;
|
||||||
|
boolean mNotifySelfNewMail;
|
||||||
String mDraftsFolderName;
|
String mDraftsFolderName;
|
||||||
String mSentFolderName;
|
String mSentFolderName;
|
||||||
String mTrashFolderName;
|
String mTrashFolderName;
|
||||||
@ -86,6 +87,7 @@ public class Account implements Serializable {
|
|||||||
mNotifyNewMail = true;
|
mNotifyNewMail = true;
|
||||||
mNotifySync = true;
|
mNotifySync = true;
|
||||||
mVibrate = false;
|
mVibrate = false;
|
||||||
|
mNotifySelfNewMail = true;
|
||||||
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
||||||
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
||||||
mFolderPushMode = 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)
|
public boolean isAnIdentity(Address addr)
|
||||||
{
|
{
|
||||||
return findIdentity(addr) != null;
|
return findIdentity(addr) != null;
|
||||||
@ -810,4 +829,14 @@ public class Account implements Serializable {
|
|||||||
this.mIsSignatureBeforeQuotedText = mIsSignatureBeforeQuotedText;
|
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) {
|
public void messageFinished(Message message, int number, int ofTotal) {
|
||||||
try {
|
try {
|
||||||
if (!message.isSet(Flag.SEEN)) {
|
if (!message.isSet(Flag.SEEN)) {
|
||||||
newMessages.incrementAndGet();
|
if ( account.isNotifySelfNewMail() || account.isAnIdentity(message.getFrom()) == false)
|
||||||
|
{
|
||||||
|
newMessages.incrementAndGet();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the new message locally
|
// 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();
|
boolean isNotifyAccount = thisAccount.isNotifyNewMail();
|
||||||
if (isNotifyAccount)
|
if (isNotifyAccount)
|
||||||
{
|
{
|
||||||
NotificationManager notifMgr =
|
NotificationManager notifMgr =
|
||||||
(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
|
(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,
|
String notice = context.getString(R.string.notification_new_one_account_fmt, unreadMessageCount,
|
||||||
thisAccount.getDescription());
|
thisAccount.getDescription());
|
||||||
@ -3744,7 +3749,7 @@ public class MessagingController implements Runnable {
|
|||||||
localFolder.open(OpenMode.READ_WRITE);
|
localFolder.open(OpenMode.READ_WRITE);
|
||||||
remoteFolder.open(OpenMode.READ_WRITE);
|
remoteFolder.open(OpenMode.READ_WRITE);
|
||||||
|
|
||||||
downloadMessages(account, remoteFolder, localFolder, messages);
|
int newCount = downloadMessages(account, remoteFolder, localFolder, messages);
|
||||||
int unreadCount = 0;
|
int unreadCount = 0;
|
||||||
for (Message message : messages)
|
for (Message message : messages)
|
||||||
{
|
{
|
||||||
@ -3759,11 +3764,11 @@ public class MessagingController implements Runnable {
|
|||||||
int unreadMessageCount = account.getUnreadMessageCount(mApplication, mApplication);
|
int unreadMessageCount = account.getUnreadMessageCount(mApplication, mApplication);
|
||||||
if (doNotify && unreadCount > 0)
|
if (doNotify && unreadCount > 0)
|
||||||
{
|
{
|
||||||
notifyAccount(mApplication, account, unreadMessageCount);
|
notifyAccount(mApplication, account, newCount, unreadMessageCount);
|
||||||
}
|
}
|
||||||
if (unreadCount == 0)
|
if (unreadCount == 0)
|
||||||
{
|
{
|
||||||
notifyAccount(mApplication, account, unreadMessageCount);
|
notifyAccount(mApplication, account, newCount, unreadMessageCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MessagingListener l : getListeners())
|
for (MessagingListener l : getListeners())
|
||||||
|
@ -145,14 +145,9 @@ public class PollService extends CoreService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
int unreadMessageCount = thisAccount.getUnreadMessageCount(context, getApplication());
|
int unreadMessageCount = thisAccount.getUnreadMessageCount(context, getApplication());
|
||||||
if (unreadMessageCount > 0 && newMailCount > 0)
|
MessagingController.getInstance(getApplication()).notifyAccount(context, thisAccount,
|
||||||
{
|
newMailCount, unreadMessageCount);
|
||||||
MessagingController.getInstance(getApplication()).notifyAccount(context, thisAccount, unreadMessageCount);
|
|
||||||
}
|
|
||||||
else if (unreadMessageCount == 0)
|
|
||||||
{
|
|
||||||
MessagingController.getInstance(getApplication()).notifyAccount(context, thisAccount, unreadMessageCount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (MessagingException me)
|
catch (MessagingException me)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user