1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-04 06:20:26 +00:00

Widget should show actual connected state

This commit is contained in:
M66B 2022-05-17 15:59:28 +02:00
parent 434e755dce
commit 0b4120f873

View file

@ -264,8 +264,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
coreStates.clear(); coreStates.clear();
liveAccountNetworkState.removeObserver(this); liveAccountNetworkState.removeObserver(this);
} else { } else {
int accounts = 0;
int enabled = 0; int enabled = 0;
int connected = 0;
int accounts = 0;
int operations = 0; int operations = 0;
boolean event = false; boolean event = false;
boolean runService = false; boolean runService = false;
@ -280,6 +281,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (!current.accountState.isTransient(ServiceSynchronize.this)) { if (!current.accountState.isTransient(ServiceSynchronize.this)) {
if (current.accountState.isEnabled(current.enabled)) if (current.accountState.isEnabled(current.enabled))
enabled++; enabled++;
if ("connected".equals(current.accountState.state))
connected++;
if ("connected".equals(current.accountState.state) || current.accountState.backoff_until != null) if ("connected".equals(current.accountState.state) || current.accountState.backoff_until != null)
accounts++; accounts++;
} }
@ -387,10 +390,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} }
} }
boolean connected = (enabled > 0 && accounts == enabled); boolean ok = (enabled > 0 && connected == enabled);
if (lastConnected != connected) { if (lastConnected != ok) {
lastConnected = connected; lastConnected = ok;
prefs.edit().putBoolean("connected", connected).apply(); prefs.edit().putBoolean("connected", ok).apply();
WidgetSync.update(ServiceSynchronize.this); WidgetSync.update(ServiceSynchronize.this);
} }