mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
Fixes Issue 801
This commit is contained in:
parent
2e50cc5444
commit
c732f14c3d
@ -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())
|
||||
{
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user