From f6f9d35430a0b46866fefd92ba71e9edefcc63d9 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 25 Oct 2010 03:19:19 +0000 Subject: [PATCH] unify two codepaths that sent unsent messages, one of them without a notification --- .../k9/controller/MessagingController.java | 78 +++++++++---------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index 232cd9a68..39519f8ca 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -3384,7 +3384,42 @@ public class MessagingController implements Runnable { public void run() { - sendPendingMessagesSynchronous(account); + if (messagesPendingSend(account)) + { + NotificationManager notifMgr = + (NotificationManager)mApplication.getSystemService(Context.NOTIFICATION_SERVICE); + if (account.isShowOngoing()) + { + Notification notif = new Notification(R.drawable.ic_menu_refresh, + mApplication.getString(R.string.notification_bg_send_ticker, account.getDescription()), System.currentTimeMillis()); + Intent intent = MessageList.actionHandleFolderIntent(mApplication, account, K9.INBOX); + PendingIntent pi = PendingIntent.getActivity(mApplication, 0, intent, 0); + notif.setLatestEventInfo(mApplication, mApplication.getString(R.string.notification_bg_send_title), + account.getDescription() , pi); + notif.flags = Notification.FLAG_ONGOING_EVENT; + + if (K9.NOTIFICATION_LED_WHILE_SYNCING) + { + notif.flags |= Notification.FLAG_SHOW_LIGHTS; + notif.ledARGB = account.getNotificationSetting().getLedColor(); + notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME; + notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME; + } + + notifMgr.notify(K9.FETCHING_EMAIL_NOTIFICATION - account.getAccountNumber(), notif); + } + try + { + sendPendingMessagesSynchronous(account); + } + finally + { + if (account.isShowOngoing()) + { + notifMgr.cancel(K9.FETCHING_EMAIL_NOTIFICATION - account.getAccountNumber()); + } + } + } } }); } @@ -4240,47 +4275,8 @@ public class MessagingController implements Runnable account.setRingNotified(false); - putBackground("sendPending " + account.getDescription(), null, new Runnable() - { - public void run() - { - if (messagesPendingSend(account)) - { - if (account.isShowOngoing()) - { - Notification notif = new Notification(R.drawable.ic_menu_refresh, - context.getString(R.string.notification_bg_send_ticker, account.getDescription()), System.currentTimeMillis()); - Intent intent = MessageList.actionHandleFolderIntent(context, account, K9.INBOX); - PendingIntent pi = PendingIntent.getActivity(context, 0, intent, 0); - notif.setLatestEventInfo(context, context.getString(R.string.notification_bg_send_title), - account.getDescription() , pi); - notif.flags = Notification.FLAG_ONGOING_EVENT; + sendPendingMessages(account, listener); - if (K9.NOTIFICATION_LED_WHILE_SYNCING) - { - notif.flags |= Notification.FLAG_SHOW_LIGHTS; - notif.ledARGB = account.getNotificationSetting().getLedColor(); - notif.ledOnMS = K9.NOTIFICATION_LED_FAST_ON_TIME; - notif.ledOffMS = K9.NOTIFICATION_LED_FAST_OFF_TIME; - } - - notifMgr.notify(K9.FETCHING_EMAIL_NOTIFICATION - account.getAccountNumber(), notif); - } - try - { - sendPendingMessagesSynchronous(account); - } - finally - { - if (account.isShowOngoing()) - { - notifMgr.cancel(K9.FETCHING_EMAIL_NOTIFICATION - account.getAccountNumber()); - } - } - } - } - } - ); try { Account.FolderMode aDisplayMode = account.getFolderDisplayMode();