diff --git a/src/com/android/email/MessagingController.java b/src/com/android/email/MessagingController.java index a14ed1ec6..a12d5b620 100644 --- a/src/com/android/email/MessagingController.java +++ b/src/com/android/email/MessagingController.java @@ -3330,34 +3330,42 @@ public class MessagingController implements Runnable { boolean isNotifyAccount = thisAccount.isNotifyNewMail(); if (isNotifyAccount) { - String notice = context.getString(R.string.notification_new_one_account_fmt, unreadMessageCount, - thisAccount.getDescription()); - Notification notif = new Notification(R.drawable.stat_notify_email_generic, - context.getString(R.string.notification_new_title), System.currentTimeMillis()); - - notif.number = unreadMessageCount; - - Intent i = FolderList.actionHandleAccountIntent(context, thisAccount); - - PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0); - - notif.setLatestEventInfo(context, context.getString(R.string.notification_new_title), notice, pi); - - String ringtone = thisAccount.getRingtone(); - notif.sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone); - - if (thisAccount.isVibrate()) { - notif.defaults |= Notification.DEFAULT_VIBRATE; - } - - notif.flags |= Notification.FLAG_SHOW_LIGHTS; - notif.ledARGB = Email.NOTIFICATION_LED_COLOR; - notif.ledOnMS = Email.NOTIFICATION_LED_ON_TIME; - notif.ledOffMS = Email.NOTIFICATION_LED_OFF_TIME; - NotificationManager notifMgr = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); - notifMgr.notify(thisAccount.getAccountNumber(), notif); + if (unreadMessageCount > 0) + { + String notice = context.getString(R.string.notification_new_one_account_fmt, unreadMessageCount, + thisAccount.getDescription()); + Notification notif = new Notification(R.drawable.stat_notify_email_generic, + context.getString(R.string.notification_new_title), System.currentTimeMillis()); + + notif.number = unreadMessageCount; + + Intent i = FolderList.actionHandleAccountIntent(context, thisAccount); + + PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0); + + notif.setLatestEventInfo(context, context.getString(R.string.notification_new_title), notice, pi); + + String ringtone = thisAccount.getRingtone(); + notif.sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone); + + if (thisAccount.isVibrate()) { + notif.defaults |= Notification.DEFAULT_VIBRATE; + } + + notif.flags |= Notification.FLAG_SHOW_LIGHTS; + notif.ledARGB = Email.NOTIFICATION_LED_COLOR; + notif.ledOnMS = Email.NOTIFICATION_LED_ON_TIME; + notif.ledOffMS = Email.NOTIFICATION_LED_OFF_TIME; + + + notifMgr.notify(thisAccount.getAccountNumber(), notif); + } + else + { + notifMgr.cancel(thisAccount.getAccountNumber()); + } } } @@ -3753,6 +3761,10 @@ public class MessagingController implements Runnable { { notifyAccount(mApplication, account, unreadMessageCount); } + if (unreadCount == 0) + { + notifyAccount(mApplication, account, unreadMessageCount); + } for (MessagingListener l : getListeners()) { diff --git a/src/com/android/email/service/PollService.java b/src/com/android/email/service/PollService.java index 353ff416e..cd77ecff1 100644 --- a/src/com/android/email/service/PollService.java +++ b/src/com/android/email/service/PollService.java @@ -9,7 +9,6 @@ import com.android.email.MessagingListener; import com.android.email.Preferences; import com.android.email.mail.MessagingException; -import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.os.IBinder; @@ -139,9 +138,6 @@ public class PollService extends CoreService return; } - NotificationManager notifMgr = - (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); - for (Account thisAccount : Preferences.getPreferences(context).getAccounts()) { Integer newMailCount = accountsChecked.get(thisAccount.getUuid()); if (newMailCount != null) @@ -155,7 +151,7 @@ public class PollService extends CoreService } else if (unreadMessageCount == 0) { - notifMgr.cancel(thisAccount.getAccountNumber()); + MessagingController.getInstance(getApplication()).notifyAccount(context, thisAccount, unreadMessageCount); } } catch (MessagingException me)