mirror of https://github.com/M66B/FairEmail.git
Auto force sync
This commit is contained in:
parent
ba608d4e69
commit
7396d0d4b9
|
@ -361,8 +361,13 @@ public class FragmentAccounts extends FragmentBase {
|
||||||
throw new IllegalStateException(context.getString(R.string.title_no_internet));
|
throw new IllegalStateException(context.getString(R.string.title_no_internet));
|
||||||
|
|
||||||
boolean now = true;
|
boolean now = true;
|
||||||
|
boolean force = false;
|
||||||
boolean outbox = false;
|
boolean outbox = false;
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
boolean enabled = prefs.getBoolean("enabled", true);
|
||||||
|
int pollInterval = prefs.getInt("poll_interval", ServiceSynchronize.DEFAULT_POLL_INTERVAL);
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
try {
|
try {
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
|
@ -380,8 +385,12 @@ public class FragmentAccounts extends FragmentBase {
|
||||||
outbox = true;
|
outbox = true;
|
||||||
else {
|
else {
|
||||||
EntityAccount account = db.account().getAccount(folder.account);
|
EntityAccount account = db.account().getAccount(folder.account);
|
||||||
if (account != null && !"connected".equals(account.state))
|
if (account != null && !"connected".equals(account.state)) {
|
||||||
now = false;
|
now = false;
|
||||||
|
if (enabled && !account.ondemand &&
|
||||||
|
(pollInterval == 0 || account.poll_exempted))
|
||||||
|
force = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +399,11 @@ public class FragmentAccounts extends FragmentBase {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceSynchronize.eval(context, "refresh/accounts");
|
if (force)
|
||||||
|
ServiceSynchronize.reload(context, null, "forced refresh");
|
||||||
|
else
|
||||||
|
ServiceSynchronize.eval(context, "refresh");
|
||||||
|
|
||||||
if (outbox)
|
if (outbox)
|
||||||
ServiceSend.start(context);
|
ServiceSend.start(context);
|
||||||
|
|
||||||
|
|
|
@ -349,8 +349,13 @@ public class FragmentFolders extends FragmentBase {
|
||||||
throw new IllegalStateException(context.getString(R.string.title_no_internet));
|
throw new IllegalStateException(context.getString(R.string.title_no_internet));
|
||||||
|
|
||||||
boolean now = true;
|
boolean now = true;
|
||||||
|
boolean force = false;
|
||||||
boolean outbox = false;
|
boolean outbox = false;
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
boolean enabled = prefs.getBoolean("enabled", true);
|
||||||
|
int pollInterval = prefs.getInt("poll_interval", ServiceSynchronize.DEFAULT_POLL_INTERVAL);
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
try {
|
try {
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
|
@ -371,8 +376,12 @@ public class FragmentFolders extends FragmentBase {
|
||||||
outbox = true;
|
outbox = true;
|
||||||
else {
|
else {
|
||||||
EntityAccount account = db.account().getAccount(folder.account);
|
EntityAccount account = db.account().getAccount(folder.account);
|
||||||
if (account != null && !"connected".equals(account.state))
|
if (account != null && !"connected".equals(account.state)) {
|
||||||
now = false;
|
now = false;
|
||||||
|
if (enabled && !account.ondemand &&
|
||||||
|
(pollInterval == 0 || account.poll_exempted))
|
||||||
|
force = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +390,10 @@ public class FragmentFolders extends FragmentBase {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceSynchronize.eval(context, "refresh/folders");
|
if (force)
|
||||||
|
ServiceSynchronize.reload(context, null, "forced refresh");
|
||||||
|
else
|
||||||
|
ServiceSynchronize.eval(context, "refresh");
|
||||||
|
|
||||||
if (outbox)
|
if (outbox)
|
||||||
ServiceSend.start(context);
|
ServiceSend.start(context);
|
||||||
|
|
|
@ -1353,6 +1353,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
throw new IllegalStateException(context.getString(R.string.title_no_internet));
|
throw new IllegalStateException(context.getString(R.string.title_no_internet));
|
||||||
|
|
||||||
boolean now = true;
|
boolean now = true;
|
||||||
|
boolean force = false;
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
boolean enabled = prefs.getBoolean("enabled", true);
|
||||||
|
int pollInterval = prefs.getInt("poll_interval", ServiceSynchronize.DEFAULT_POLL_INTERVAL);
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
try {
|
try {
|
||||||
|
@ -1374,8 +1379,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
|
|
||||||
if (folder.account != null) {
|
if (folder.account != null) {
|
||||||
EntityAccount account = db.account().getAccount(folder.account);
|
EntityAccount account = db.account().getAccount(folder.account);
|
||||||
if (account != null && !"connected".equals(account.state))
|
if (account != null && !"connected".equals(account.state)) {
|
||||||
now = false;
|
now = false;
|
||||||
|
if (enabled && !account.ondemand &&
|
||||||
|
(pollInterval == 0 || account.poll_exempted))
|
||||||
|
force = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1384,7 +1393,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceSynchronize.eval(context, "refresh");
|
if (force)
|
||||||
|
ServiceSynchronize.reload(context, null, "forced refresh");
|
||||||
|
else
|
||||||
|
ServiceSynchronize.eval(context, "refresh");
|
||||||
|
|
||||||
if (!now)
|
if (!now)
|
||||||
throw new IllegalArgumentException(context.getString(R.string.title_no_connection));
|
throw new IllegalArgumentException(context.getString(R.string.title_no_connection));
|
||||||
|
|
Loading…
Reference in New Issue