diff --git a/res/values/strings.xml b/res/values/strings.xml index 59705b11a..625620785 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,17 +1,17 @@ - K-9 - Google, The K-9 Krew, and a cast of thousands. - Authors: %s - http://code.google.com/p/k9mail/wiki/ReleaseNotes - Revision Information: %s - http://code.google.com/p/k9mail/ + K-9 + Google, The K-9 Krew, and a cast of thousands. + Authors: %s + http://code.google.com/p/k9mail/wiki/ReleaseNotes + Revision Information: %s + http://code.google.com/p/k9mail/ read Email attachments Allows this application to read your Email attachments. - About %s - Your accounts + About %s + Your accounts Compose Debug @@ -49,8 +49,8 @@ Edit subject Add attachment Dump settings - Empty Trash - About + Empty Trash + About Account options @@ -69,6 +69,9 @@ in %d accounts Message not sent + Checking email: %s + Checking email + Inbox Outbox @@ -139,9 +142,9 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based Message deleted. Message discarded. Message saved as draft. - - About %s - Version: %s + + About %s + Version: %s Set up email Type your account email address: @@ -276,13 +279,13 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based Signature Append a signature to every message you send - + Sent Items Folder Save all sent messages to this folder - - Deleted Items Folder - Set the deleted items folder - + + Deleted Items Folder + Set the deleted items folder + Remove The account \"%s\" will be removed from Email. @@ -291,7 +294,7 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based allowing this program to connect. If you are not able to sign in with your correct email address and password, you may not have a paid \"Plus\" account. Please launch the Web browser to gain access to - these mail accounts. + these mail accounts. Unrecognized Certificate Accept Key Reject Key diff --git a/src/com/android/email/Email.java b/src/com/android/email/Email.java index 9b5291b06..fa925660b 100644 --- a/src/com/android/email/Email.java +++ b/src/com/android/email/Email.java @@ -120,7 +120,8 @@ public class Email extends Application { */ public static final int NOTIFICATION_LED_OFF_TIME = 2000; - public static final int NEW_EMAIL_NOTIFICATION_ID = 1; + public static final int NEW_EMAIL_NOTIFICATION_ID = 1; + public static final int FETCHING_EMAIL_NOTIFICATION_ID = 2; /** * Called throughout the application when the number of accounts has changed. This method diff --git a/src/com/android/email/MessagingController.java b/src/com/android/email/MessagingController.java index bbbdebf77..ff40d340a 100644 --- a/src/com/android/email/MessagingController.java +++ b/src/com/android/email/MessagingController.java @@ -10,11 +10,16 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import android.app.Application; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; import android.content.Context; +import android.content.Intent; import android.os.Process; import android.util.Config; import android.util.Log; +import com.android.email.activity.FolderMessageList; import com.android.email.mail.FetchProfile; import com.android.email.mail.Flag; import com.android.email.mail.Folder; @@ -1432,33 +1437,52 @@ s * critical data as fast as possible, and then we'll fill in the de } put("checkMail", listener, new Runnable() { public void run() { - Account[] accounts; - if (account != null) { - accounts = new Account[] { - account - }; - } else { - accounts = Preferences.getPreferences(context).getAccounts(); - } - for (Account account : accounts) { - //We do the math in seconds and not millis - //since timers are not that accurate - long now = (long)Math.floor(System.currentTimeMillis() / 1000); - long autoCheckIntervalTime = account.getAutomaticCheckIntervalMinutes() * 60; - long lastAutoCheckTime = (long)Math.ceil(account.getLastAutomaticCheckTime() / 1000); - if (autoCheckIntervalTime>0 - && (now-lastAutoCheckTime)>autoCheckIntervalTime) { - sendPendingMessagesSynchronous(account); - synchronizeMailboxSynchronous(account, Email.INBOX); - //This saves the last auto check time even if sync fails - //TODO: Listen for both send and sync success and failures - //and only save last auto check time is not errors - account.setLastAutomaticCheckTime(now*1000); - account.save(Preferences.getPreferences(context)); + NotificationManager notifMgr = (NotificationManager)context + .getSystemService(Context.NOTIFICATION_SERVICE); + try { + Account[] accounts; + if (account != null) { + accounts = new Account[] { + account + }; + } else { + accounts = Preferences.getPreferences(context).getAccounts(); + } + for (Account account : accounts) { + //We do the math in seconds and not millis + //since timers are not that accurate + long now = (long)Math.floor(System.currentTimeMillis() / 1000); + long autoCheckIntervalTime = account.getAutomaticCheckIntervalMinutes() * 60; + long lastAutoCheckTime = (long)Math.ceil(account.getLastAutomaticCheckTime() / 1000); + if (autoCheckIntervalTime>0 + && (now-lastAutoCheckTime)>autoCheckIntervalTime) { + Notification notif = new Notification(R.drawable.ic_menu_refresh, context.getString(R.string.notification_bg_sync_ticker, account.getDescription()), System.currentTimeMillis()); + Intent intent = FolderMessageList.actionHandleAccountIntent(context, account, Email.INBOX); + PendingIntent pi = PendingIntent.getActivity(context, 0, intent, 0); + notif.setLatestEventInfo(context, context.getString(R.string.notification_bg_sync_title), account.getDescription(), pi); + notif.flags = Notification.FLAG_ONGOING_EVENT; + notifMgr.notify(Email.FETCHING_EMAIL_NOTIFICATION_ID, notif); + + sendPendingMessagesSynchronous(account); + synchronizeMailboxSynchronous(account, Email.INBOX); + //This saves the last auto check time even if sync fails + //TODO: Listen for both send and sync success and failures + //and only save last auto check time is not errors + account.setLastAutomaticCheckTime(now*1000); + account.save(Preferences.getPreferences(context)); + } + } + for (MessagingListener l : mListeners) { + l.checkMailFinished(context, account); } } - for (MessagingListener l : mListeners) { - l.checkMailFinished(context, account); + catch (Exception e) { + for (MessagingListener l : mListeners) { + l.checkMailFailed(context, account, e.getMessage()); + } + } + finally { + notifMgr.cancel(Email.FETCHING_EMAIL_NOTIFICATION_ID); } } });