1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00

Fixes Issue 801

This commit is contained in:
Daniel Applebaum 2009-11-22 17:15:11 +00:00
parent 2e50cc5444
commit c732f14c3d
2 changed files with 39 additions and 31 deletions

View File

@ -3330,34 +3330,42 @@ public class MessagingController implements Runnable {
boolean isNotifyAccount = thisAccount.isNotifyNewMail(); boolean isNotifyAccount = thisAccount.isNotifyNewMail();
if (isNotifyAccount) 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 notifMgr =
(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); (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); notifyAccount(mApplication, account, unreadMessageCount);
} }
if (unreadCount == 0)
{
notifyAccount(mApplication, account, unreadMessageCount);
}
for (MessagingListener l : getListeners()) for (MessagingListener l : getListeners())
{ {

View File

@ -9,7 +9,6 @@ import com.android.email.MessagingListener;
import com.android.email.Preferences; import com.android.email.Preferences;
import com.android.email.mail.MessagingException; import com.android.email.mail.MessagingException;
import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.IBinder; import android.os.IBinder;
@ -139,9 +138,6 @@ public class PollService extends CoreService
return; return;
} }
NotificationManager notifMgr =
(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
for (Account thisAccount : Preferences.getPreferences(context).getAccounts()) { for (Account thisAccount : Preferences.getPreferences(context).getAccounts()) {
Integer newMailCount = accountsChecked.get(thisAccount.getUuid()); Integer newMailCount = accountsChecked.get(thisAccount.getUuid());
if (newMailCount != null) if (newMailCount != null)
@ -155,7 +151,7 @@ public class PollService extends CoreService
} }
else if (unreadMessageCount == 0) else if (unreadMessageCount == 0)
{ {
notifMgr.cancel(thisAccount.getAccountNumber()); MessagingController.getInstance(getApplication()).notifyAccount(context, thisAccount, unreadMessageCount);
} }
} }
catch (MessagingException me) catch (MessagingException me)