From eabc9af9b39fc8841e9af7634febdce8654e8fda Mon Sep 17 00:00:00 2001 From: Daniel Applebaum Date: Sat, 31 Oct 2009 18:51:59 +0000 Subject: [PATCH] Fixes Issue 668 Fixes Issue 577 K-9 has earned its Canine Good Citizen. K-9 now respects the Android-global Background data preference, by default. However, there is an override, allowing K-9 to ignore the global preference, by either always running around and synchronizing in the background, or staying put and not synchronizing. A user can now elect to turn off mail synchronization across all accounts in either the K-9 Preferences page by setting Background synchronization to Never, or leaving that value as "When 'Background data' is checked" and deselecting the Android-global Background data preference. --- AndroidManifest.xml | 3 + res/values/arrays.xml | 11 +++ res/values/strings.xml | 7 ++ res/xml/global_preferences.xml | 10 +++ src/com/android/email/Email.java | 32 +++++++++ .../android/email/activity/setup/Prefs.java | 25 +++++++ .../android/email/service/BootReceiver.java | 4 ++ .../android/email/service/MailService.java | 69 +++++++++++-------- 8 files changed, 132 insertions(+), 29 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index eb09ed852..a1b674380 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -207,6 +207,9 @@ + + + dark + + @string/background_ops_enabled + @string/background_ops_always + @string/background_ops_never + + + WHEN_CHECKED + ALWAYS + NEVER + + diff --git a/res/values/strings.xml b/res/values/strings.xml index a7281f8d0..3f425b025 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -533,5 +533,12 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based Light Display Preferences Diagnostic Preferences + Operational Preferences Theme + + Background synchronization + Never + Always + When Background data is checked + diff --git a/res/xml/global_preferences.xml b/res/xml/global_preferences.xml index b00b11443..66a372b51 100644 --- a/res/xml/global_preferences.xml +++ b/res/xml/global_preferences.xml @@ -25,6 +25,16 @@ android:entryValues="@array/settings_theme_values" android:dialogTitle="@string/settings_theme_label" /> + + + + + pushers = MessagingController.getInstance(getApplication()).getPushers(); @@ -203,21 +220,15 @@ public class MailService extends Service { Log.e(Email.LOG_TAG, "Exception while refreshing pushers", e); } } - else if (CONNECTIVITY_CHANGE.equals(intent.getAction())) + else if (CONNECTIVITY_CHANGE.equals(intent.getAction()) || + BACKGROUND_DATA_CHANGED.equals(intent.getAction())) { + actionReschedule(this); boolean hasConnectivity = intent.getBooleanExtra(HAS_CONNECTIVITY, true); - Log.i(Email.LOG_TAG, "Got connectivity action with hasConnectivity = " + hasConnectivity); + + Log.i(Email.LOG_TAG, "Got connectivity action with hasConnectivity = " + hasConnectivity + ", doBackground = " + doBackground); + notifyConnectionStatus(hasConnectivity); - if (hasConnectivity) - { - reschedulePushers(); - // TODO: Make it send pending outgoing messages here - //checkMail(getApplication()); - } - else - { - stopPushers(); - } } else if (CANCEL_CONNECTIVITY_NOTICE.equals(intent.getAction())) { @@ -313,7 +324,7 @@ public class MailService extends Service { try { String checkString = "Next check for package " + getApplication().getPackageName() + " scheduled for " + new Date(nextTime); - Log.v(Email.LOG_TAG, checkString); + Log.i(Email.LOG_TAG, checkString); MessagingController.getInstance(getApplication()).log(checkString); } catch (Exception e)