From ea3619b733bdcd1d85e35de81833a77f8d1acba3 Mon Sep 17 00:00:00 2001 From: Dan Applebaum Date: Fri, 4 Feb 2011 08:26:16 +0000 Subject: [PATCH] Display a message in the titlebar when K-9 Mail is not performing any message synchronization. This state will happen when no network is available, when background ops/background data/auto-sync settings turn off synchronization, or when no account is set for polling or pushing. This revision respects the intention of r3011 that when K-9 Mail is set for pushing only no message is displayed, as that condition is a normal state. However, it provides valuable feedback in other cases that synchronization is off-line, as was done in r1433. Although the case when the user has intentionally set no account for polling or pushing can be considered "normal" and therefore unworthy of a message, it turns out to be a significant burden to detect that situation when the network is offline, since we normally do not even try to figure out the account configurations in that case. Therefore, without making substantial, otherwise unwarranted, changes to MailService.java, "Syncing off" would be displayed sometimes to such a user, and sometimes not. Since it is presumably a rare case, and there is minimal harm to display the "Syncing off" message, the message will be consistently displayed when no account is set for polling or pushing. Note to translators: "Syncing off" is different than "Polling off". The new phrase "Syncing off" means that K-9 Mail is not performing any synchronization with any mail server. The prior non-English phrases for "Polling off" are currently in-place as translations for "Syncing off", as it seems that the meanings are close enough that it would be better to show the obsolete translations that to fallback to the English "Syncing off". However, better translations of "Syncing off" would be welcome. --- res/values-cs/strings.xml | 2 +- res/values-de/strings.xml | 2 +- res/values-es/strings.xml | 2 +- res/values-fi/strings.xml | 2 +- res/values-fr/strings.xml | 2 +- res/values-it/strings.xml | 2 +- res/values-ja/strings.xml | 2 +- res/values-nl/strings.xml | 2 +- res/values-pl/strings.xml | 2 +- res/values-pt-rBR/strings.xml | 14 +++++++------- res/values-ru/strings.xml | 2 +- res/values-sv/strings.xml | 2 +- res/values-zh-rCN/strings.xml | 2 +- res/values/strings.xml | 2 +- src/com/fsck/k9/activity/ActivityListener.java | 6 +++++- src/com/fsck/k9/service/MailService.java | 13 +++++++++++++ 16 files changed, 38 insertions(+), 21 deletions(-) diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 7130d5d72..4e5a7715d 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -43,7 +43,7 @@ \u0020%s/%s \u0020(Příští dotaz @ %s) - \u0020(Bez dotazování) + \u0020(Bez dotazování) Další diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 85526eb46..f372261ea 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -38,7 +38,7 @@ \u0020%s/%s \u0020(Nächster Abruf @ %s) - \u0020(Abrufen deaktiviert) + \u0020(Abrufen deaktiviert) Weiter diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 70d5885e5..0c507f3fe 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -38,7 +38,7 @@ \u0020%s/%s \u0020(Próxima comprobación @ %s) - \u0020(Comprobación finalizada) + \u0020(Comprobación finalizada) Siguiente diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index ca7582a78..dd1f4b226 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -38,7 +38,7 @@ \u0020%s/%s \u0020(Seuraava tarkistus @ %s) - \u0020(Tarkistus pois päältä) + \u0020(Tarkistus pois päältä) Seuraava diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 9068f936f..023a047a8 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -57,7 +57,7 @@ \u0020(Prép %s:%s%s) \u0020%s/%s \u0020(Prochaine récupération à %s) - \u0020(Récupération désactivée) + \u0020(Récupération désactivée) Suivant OK Annuler diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 652ad1b81..10889c07a 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -42,7 +42,7 @@ \u0020%s/%s \u0020(Prossima verifica alle %s) - \u0020(Verifica disattivata) + \u0020(Verifica disattivata) Successivo diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 71cc5feac..589f2bd51 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -42,7 +42,7 @@ \u0020%s/%s \u0020(次回受信 @ %s) - \u0020(受信済) + \u0020(受信済) 次へ diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index fa10b591a..f4f91c5ee 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -38,7 +38,7 @@ \u0020%s/%s \u0020(Volgende poll @ %s) - \u0020(Polling uit) + \u0020(Polling uit) Volgende diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index 6c089fad1..076c2a7a2 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -44,7 +44,7 @@ \u0020%s/%s \u0020(Sprawdzę o %s) - \u0020(Pobieranie wyłączone) + \u0020(Pobieranie wyłączone) Dalej diff --git a/res/values-pt-rBR/strings.xml b/res/values-pt-rBR/strings.xml index ff9bb3bad..6f511fbdf 100644 --- a/res/values-pt-rBR/strings.xml +++ b/res/values-pt-rBR/strings.xml @@ -35,13 +35,13 @@ \u0020(Buscando cabeçalhos %s:%s%s) \u0020(Enviando %s%s) \u0020(Proc %s:%s%s) - \u0020%s/%s - - \u0020(Nova verif. às @ %s) - \u0020(Verificação desligada) - - - Próximo + \u0020%s/%s + + \u0020(Nova verif. às @ %s) + \u0020(Verificação desligada) + + + Próximo Anterior OK Cancelar diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 8c355041a..7ef6eb217 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -31,7 +31,7 @@ \u0020%s/%s \u0020(Следующий запрос @ %s) - \u0020(Отключить авто-запрос) + \u0020(Отключить авто-запрос) Следующий diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 0f5a41b29..9b8907ebb 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -38,7 +38,7 @@ \u0020%s/%s \u0020(Nästa kontroll @ %s) - \u0020(Kontroll av) + \u0020(Kontroll av) Nästa diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index d0c39fc50..556f600a2 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -38,7 +38,7 @@ \u0020%s/%s \u0020(下次接收时间:%s - \u0020(正在接收) + \u0020(正在接收) 下一步 diff --git a/res/values/strings.xml b/res/values/strings.xml index 1b1b54226..b8a60439e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -42,7 +42,7 @@ \u0020%s/%s \u0020(Next poll @ %s) - \u0020(Polling off) + \u0020(Syncing off) Next diff --git a/src/com/fsck/k9/activity/ActivityListener.java b/src/com/fsck/k9/activity/ActivityListener.java index 1609f6375..1a1b7354f 100644 --- a/src/com/fsck/k9/activity/ActivityListener.java +++ b/src/com/fsck/k9/activity/ActivityListener.java @@ -71,9 +71,13 @@ public class ActivityListener extends MessagingListener { operation = context.getString(R.string.status_next_poll, timeFormat.format(nextPollTime)); } + else if (MailService.isSyncDisabled()) + { + operation = context.getString(R.string.status_syncing_off); + } else { - operation = ""; // context.getString(R.string.status_polling_off); + operation = ""; } } diff --git a/src/com/fsck/k9/service/MailService.java b/src/com/fsck/k9/service/MailService.java index fd291bcac..4789422a9 100644 --- a/src/com/fsck/k9/service/MailService.java +++ b/src/com/fsck/k9/service/MailService.java @@ -35,6 +35,9 @@ public class MailService extends CoreService private static final String CANCEL_CONNECTIVITY_NOTICE = "com.fsck.k9.intent.action.MAIL_SERVICE_CANCEL_CONNECTIVITY_NOTICE"; private static long nextCheck = -1; + private static boolean pushingRequested = false; + private static boolean pollingRequested = false; + private static boolean syncBlocked = false; public static void actionReset(Context context, Integer wakeLockId) { @@ -149,6 +152,8 @@ public class MailService extends CoreService } + syncBlocked = !(doBackground && hasConnectivity); + if (K9.DEBUG) Log.i(K9.LOG_TAG, "MailService.onStart(" + intent + ", " + startId + "), hasConnectivity = " + hasConnectivity + ", doBackground = " + doBackground); @@ -300,6 +305,7 @@ public class MailService extends CoreService if (shortestInterval == -1) { nextCheck = -1; + pollingRequested = false; if (K9.DEBUG) Log.i(K9.LOG_TAG, "No next check scheduled for package " + getApplication().getPackageName()); cancel(); @@ -316,6 +322,7 @@ public class MailService extends CoreService + ", lastCheckEnd = " + new Date(lastCheckEnd) + ", considerLastCheckEnd = " + considerLastCheckEnd); nextCheck = nextTime; + pollingRequested = true; try { if (K9.DEBUG) @@ -346,6 +353,11 @@ public class MailService extends CoreService } } + public static boolean isSyncDisabled() + { + return syncBlocked || (!pollingRequested && !pushingRequested); + } + private void stopPushers(final Integer startId) { execute(getApplication(), new Runnable() @@ -412,6 +424,7 @@ public class MailService extends CoreService { PushService.startService(MailService.this); } + pushingRequested = pushing; } } , K9.MAIL_SERVICE_WAKE_LOCK_TIMEOUT, startId);