From 0b4120f8735afd9e20ca43185038ec8caffde9a8 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 17 May 2022 15:59:28 +0200 Subject: [PATCH] Widget should show actual connected state --- .../java/eu/faircode/email/ServiceSynchronize.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 7a59570402..149e8c4f3f 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -264,8 +264,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences coreStates.clear(); liveAccountNetworkState.removeObserver(this); } else { - int accounts = 0; int enabled = 0; + int connected = 0; + int accounts = 0; int operations = 0; boolean event = false; boolean runService = false; @@ -280,6 +281,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences if (!current.accountState.isTransient(ServiceSynchronize.this)) { if (current.accountState.isEnabled(current.enabled)) enabled++; + if ("connected".equals(current.accountState.state)) + connected++; if ("connected".equals(current.accountState.state) || current.accountState.backoff_until != null) accounts++; } @@ -387,10 +390,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences } } - boolean connected = (enabled > 0 && accounts == enabled); - if (lastConnected != connected) { - lastConnected = connected; - prefs.edit().putBoolean("connected", connected).apply(); + boolean ok = (enabled > 0 && connected == enabled); + if (lastConnected != ok) { + lastConnected = ok; + prefs.edit().putBoolean("connected", ok).apply(); WidgetSync.update(ServiceSynchronize.this); }