1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Revert "Fix for issue 1138: New emails after the first do not play new mail ringtone until notifications are cleared by skister2"

(Temporary revert until an NPE is dealt with)

This reverts commit 4bf862a827a456ffed20be707387b9ca4f2b721f.
This commit is contained in:
Jesse Vincent 2010-03-24 01:11:58 +00:00
parent f349af5129
commit a923d066d4
3 changed files with 23 additions and 57 deletions

View File

@ -79,9 +79,6 @@ public class Account
private String mExpungePolicy = EXPUNGE_IMMEDIATELY; private String mExpungePolicy = EXPUNGE_IMMEDIATELY;
private int mMaxPushFolders; private int mMaxPushFolders;
private Map<String, Boolean> compressionMap = new ConcurrentHashMap<String, Boolean>(); private Map<String, Boolean> compressionMap = new ConcurrentHashMap<String, Boolean>();
// Tracks if we have sent a notification for this account for
// current set of fetched messages
private boolean mRingNotified;
private List<Identity> identities; private List<Identity> identities;
@ -547,20 +544,7 @@ public class Account
mVibrate = vibrate; mVibrate = vibrate;
} }
public synchronized String getRingtone()
/* Have we sent a new mail notification on this account */
public boolean isRingNotified()
{
return mRingNotified;
}
public void setRingNotified(boolean ringNotified)
{
mRingNotified = ringNotified;
}
public synchronized String getRingtone()
{ {
return mRingtoneUri; return mRingtoneUri;
} }

View File

@ -1330,8 +1330,10 @@ public class MessagingController implements Runnable
} }
// Send a notification of this message // Send a notification of this message
if (notifyAccount(mApplication, account, message) == true) if (!message.isSet(Flag.SEEN) &&
(account.isNotifySelfNewMail() || account.isAnIdentity(message.getFrom()) == false))
{ {
notifyAccount(mApplication, account, message);
newMessages.incrementAndGet(); newMessages.incrementAndGet();
} }
@ -1423,7 +1425,6 @@ public class MessagingController implements Runnable
l.synchronizeMailboxNewMessage(account, folder, localMessage); l.synchronizeMailboxNewMessage(account, folder, localMessage);
} }
} }
notifyAccount(mApplication, account, message);
} }
catch (MessagingException me) catch (MessagingException me)
@ -1551,7 +1552,6 @@ public class MessagingController implements Runnable
l.synchronizeMailboxNewMessage(account, folder, localMessage); l.synchronizeMailboxNewMessage(account, folder, localMessage);
} }
} }
notifyAccount(mApplication, account, message);
}//for large messsages }//for large messsages
if (K9.DEBUG) if (K9.DEBUG)
Log.d(K9.LOG_TAG, "SYNC: Done fetching large messages for folder " + folder); Log.d(K9.LOG_TAG, "SYNC: Done fetching large messages for folder " + folder);
@ -3901,6 +3901,8 @@ public class MessagingController implements Runnable
{ {
if (K9.DEBUG) if (K9.DEBUG)
Log.i(K9.LOG_TAG, "Skipping synchronizing account " + account.getDescription()); Log.i(K9.LOG_TAG, "Skipping synchronizing account " + account.getDescription());
continue; continue;
} }
@ -4167,16 +4169,12 @@ public class MessagingController implements Runnable
} }
/** Creates a notification of new email messages /** Creates a notification of new email messages
* ringtone, lights, and vibration to be played * ringtone, lights, and vibration to be played
*/ */
private boolean notifyAccount(Context context, Account account, Message message) private void notifyAccount(Context context, Account account, Message message)
{ {
// Do not notify if the user does not have notifications if (!account.isNotifyNewMail())
// enabled or if the message has been read return;
if (!account.isNotifyNewMail() || message.isSet(Flag.SEEN))
{
return false;
}
// If we have a message, set the notification to "<From>: <Subject>" // If we have a message, set the notification to "<From>: <Subject>"
StringBuffer messageNotice = new StringBuffer(); StringBuffer messageNotice = new StringBuffer();
@ -4184,8 +4182,8 @@ public class MessagingController implements Runnable
{ {
if (message != null && message.getFrom() != null) if (message != null && message.getFrom() != null)
{ {
Address[] fromAddrs = message.getFrom(); Address[] addrs = message.getFrom();
String from = fromAddrs.length > 0 ? fromAddrs[0].toFriendly() : null; String from = addrs.length > 0 ? addrs[0].toFriendly() : null;
String subject = message.getSubject(); String subject = message.getSubject();
if (subject == null) if (subject == null)
{ {
@ -4194,20 +4192,13 @@ public class MessagingController implements Runnable
if (from != null) if (from != null)
{ {
// Show From: address by default // Show From: address, except show To: if sent from me
if (account.isAnIdentity(fromAddrs) == false) if (account.isAnIdentity(message.getFrom()) == false)
{ {
messageNotice.append(from + ": " + subject); messageNotice.append(from + ": " + subject);
} }
// show To: if the message was sent from me
else else
{ {
// Do not notify of mail from self if !isNotifySelfNewMail
if (!account.isNotifySelfNewMail())
{
return false;
}
Address[] rcpts = message.getRecipients(Message.RecipientType.TO); Address[] rcpts = message.getRecipients(Message.RecipientType.TO);
String to = rcpts.length > 0 ? rcpts[0].toFriendly() : null; String to = rcpts.length > 0 ? rcpts[0].toFriendly() : null;
if (to != null) if (to != null)
@ -4256,29 +4247,23 @@ public class MessagingController implements Runnable
String accountNotice = context.getString(R.string.notification_new_one_account_fmt, unreadMessageCount, account.getDescription()); String accountNotice = context.getString(R.string.notification_new_one_account_fmt, unreadMessageCount, account.getDescription());
notif.setLatestEventInfo(context, accountNotice, messageNotice, pi); notif.setLatestEventInfo(context, accountNotice, messageNotice, pi);
// Only ring or vibrate if we have not done so already on this if (account.isRing())
// account and fetch
if (!account.isRingNotified())
{ {
account.setRingNotified(true); String ringtone = account.getRingtone();
if (account.isRing()) notif.sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone);
{
String ringtone = account.getRingtone();
notif.sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone);
}
if (account.isVibrate())
{
notif.defaults |= Notification.DEFAULT_VIBRATE;
}
} }
notif.flags |= Notification.FLAG_SHOW_LIGHTS; if (account.isVibrate())
{
notif.defaults |= Notification.DEFAULT_VIBRATE;
}
notif.flags |= Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONLY_ALERT_ONCE;
notif.ledARGB = K9.NOTIFICATION_LED_COLOR; notif.ledARGB = K9.NOTIFICATION_LED_COLOR;
notif.ledOnMS = K9.NOTIFICATION_LED_ON_TIME; notif.ledOnMS = K9.NOTIFICATION_LED_ON_TIME;
notif.ledOffMS = K9.NOTIFICATION_LED_OFF_TIME; notif.ledOffMS = K9.NOTIFICATION_LED_OFF_TIME;
notifMgr.notify(account.getAccountNumber(), notif); notifMgr.notify(account.getAccountNumber(), notif);
return true;
} }
/** Cancel a notification of new email messages */ /** Cancel a notification of new email messages */
@ -4580,7 +4565,6 @@ public class MessagingController implements Runnable
localFolder= localStore.getFolder(remoteFolder.getName()); localFolder= localStore.getFolder(remoteFolder.getName());
localFolder.open(OpenMode.READ_WRITE); localFolder.open(OpenMode.READ_WRITE);
account.setRingNotified(false);
int newCount = downloadMessages(account, remoteFolder, localFolder, messages, flagSyncOnly); int newCount = downloadMessages(account, remoteFolder, localFolder, messages, flagSyncOnly);
int unreadMessageCount = setLocalUnreadCountToRemote(localFolder, remoteFolder, messages.size()); int unreadMessageCount = setLocalUnreadCountToRemote(localFolder, remoteFolder, messages.size());

View File

@ -159,8 +159,6 @@ public class PollService extends CoreService
if (K9.DEBUG) if (K9.DEBUG)
Log.v(K9.LOG_TAG, "***** PollService *****: checkMailFinished"); Log.v(K9.LOG_TAG, "***** PollService *****: checkMailFinished");
// Reset RingNotified so the next new mail will notify
account.setRingNotified(false);
release(); release();
} }
public int getStartId() public int getStartId()