mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-23 16:18:50 -05:00
. Added silent 'on going' notification when checking email
This commit is contained in:
parent
b9dec4064e
commit
56d1ede846
@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="app_name">K-9</string>
|
||||
<string name="app_authors">Google, The K-9 Krew, and a cast of thousands.</string>
|
||||
<string name="app_authors_fmt">Authors: <xliff:g id="app_authors">%s</xliff:g></string>
|
||||
<string name="app_revision_url">http://code.google.com/p/k9mail/wiki/ReleaseNotes</string>
|
||||
<string name="app_revision_fmt">Revision Information: <xliff:g id="app_revision_url">%s</xliff:g></string>
|
||||
<string name="app_webpage_url">http://code.google.com/p/k9mail/</string>
|
||||
<string name="app_name">K-9</string>
|
||||
<string name="app_authors">Google, The K-9 Krew, and a cast of thousands.</string>
|
||||
<string name="app_authors_fmt">Authors: <xliff:g id="app_authors">%s</xliff:g></string>
|
||||
<string name="app_revision_url">http://code.google.com/p/k9mail/wiki/ReleaseNotes</string>
|
||||
<string name="app_revision_fmt">Revision Information: <xliff:g id="app_revision_url">%s</xliff:g></string>
|
||||
<string name="app_webpage_url">http://code.google.com/p/k9mail/</string>
|
||||
|
||||
<string name="read_attachment_label">read Email attachments</string>
|
||||
<string name="read_attachment_desc">Allows this application to read your Email attachments.</string>
|
||||
|
||||
<string name="about_title_fmt">About <xliff:g id="app_name">%s</xliff:g></string>
|
||||
<string name="accounts_title">Your accounts</string>
|
||||
<string name="about_title_fmt">About <xliff:g id="app_name">%s</xliff:g></string>
|
||||
<string name="accounts_title">Your accounts</string>
|
||||
<string name="compose_title">Compose</string>
|
||||
<string name="debug_title">Debug</string>
|
||||
|
||||
@ -49,8 +49,8 @@
|
||||
<string name="edit_subject_action">Edit subject</string>
|
||||
<string name="add_attachment_action">Add attachment</string>
|
||||
<string name="dump_settings_action">Dump settings</string>
|
||||
<string name="empty_trash_action">Empty Trash</string>
|
||||
<string name="about_action">About</string>
|
||||
<string name="empty_trash_action">Empty Trash</string>
|
||||
<string name="about_action">About</string>
|
||||
|
||||
<string name="accounts_context_menu_title">Account options</string>
|
||||
|
||||
@ -69,6 +69,9 @@
|
||||
<string name="notification_new_multi_account_fmt">in <xliff:g id="number_accounts">%d</xliff:g> accounts</string>
|
||||
<string name="notification_unsent_title">Message not sent</string>
|
||||
|
||||
<string name="notification_bg_sync_ticker">Checking email: <xliff:g id="account">%s</xliff:g></string>
|
||||
<string name="notification_bg_sync_title">Checking email</string>
|
||||
|
||||
<string name="special_mailbox_name_inbox">Inbox</string>
|
||||
<string name="special_mailbox_name_outbox">Outbox</string>
|
||||
<!-- The following mailbox names will be used if the user has not specified one from the server -->
|
||||
@ -139,9 +142,9 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based
|
||||
<string name="message_deleted_toast">Message deleted.</string>
|
||||
<string name="message_discarded_toast">Message discarded.</string>
|
||||
<string name="message_saved_toast">Message saved as draft.</string>
|
||||
|
||||
<string name="about_header">About <xliff:g id="app_name">%s</xliff:g></string>
|
||||
<string name="about_version">Version: <xliff:g id="version">%s</xliff:g></string>
|
||||
|
||||
<string name="about_header">About <xliff:g id="app_name">%s</xliff:g></string>
|
||||
<string name="about_version">Version: <xliff:g id="version">%s</xliff:g></string>
|
||||
|
||||
<string name="account_setup_basics_title">Set up email</string>
|
||||
<string name="account_setup_basics_instructions">Type your account email address:</string>
|
||||
@ -276,13 +279,13 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based
|
||||
|
||||
<string name="account_settings_signature_label">Signature</string>
|
||||
<string name="account_settings_signature_summary">Append a signature to every message you send</string>
|
||||
|
||||
|
||||
<string name="account_settings_sent_items_label">Sent Items Folder</string>
|
||||
<string name="account_settings_sent_items_summary">Save all sent messages to this folder</string>
|
||||
|
||||
<string name="account_settings_deleted_items_label">Deleted Items Folder</string>
|
||||
<string name="account_settings_deleted_items_summary">Set the deleted items folder</string>
|
||||
|
||||
|
||||
<string name="account_settings_deleted_items_label">Deleted Items Folder</string>
|
||||
<string name="account_settings_deleted_items_summary">Set the deleted items folder</string>
|
||||
|
||||
<string name="account_delete_dlg_title">Remove</string>
|
||||
<string name="account_delete_dlg_instructions_fmt">The account \"<xliff:g id="account">%s</xliff:g>\" will be removed from Email.</string>
|
||||
|
||||
@ -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.</string>
|
||||
these mail accounts.</string>
|
||||
<string name="account_setup_failed_dlg_invalid_certificate_title">Unrecognized Certificate</string>
|
||||
<string name="account_setup_failed_dlg_invalid_certificate_accept">Accept Key</string>
|
||||
<string name="account_setup_failed_dlg_invalid_certificate_reject">Reject Key</string>
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user