External enable/disable by toggling on demand

pull/199/head
M66B 4 years ago
parent c4c3192a6a
commit 6d0cc9d322

@ -2275,6 +2275,7 @@ To enable/disable a specific account:
```
Note that disabling an account will hide the account and all associated folders and messages.
From version 1.1600 an account will be disabled/enabled by setting the account to manual/automatic sync, so the folders and messages keep being accessible.
To set the poll interval:

@ -130,6 +130,9 @@ public interface DaoAccount {
@Query("UPDATE account SET synchronize = :synchronize WHERE id = :id AND NOT (synchronize IS :synchronize)")
int setAccountSynchronize(long id, boolean synchronize);
@Query("UPDATE account SET ondemand = :ondemand WHERE id = :id AND NOT (ondemand IS :ondemand)")
int setAccountOnDemand(long id, boolean ondemand);
@Query("UPDATE account SET `primary` = :primary WHERE id = :id AND NOT (`primary` IS :primary)")
int setAccountPrimary(long id, boolean primary);

@ -44,8 +44,6 @@ public class ServiceExternal extends Service {
private static final String ACTION_INTERVAL = BuildConfig.APPLICATION_ID + ".INTERVAL";
private static final String ACTION_DISCONNECT_ME = BuildConfig.APPLICATION_ID + ".DISCONNECT.ME";
static final int PI_WIDGET_ENABLE = 1;
// adb shell am start-foreground-service -a eu.faircode.email.POLL --es account Gmail
// adb shell am start-foreground-service -a eu.faircode.email.ENABLE --es account Gmail
// adb shell am start-foreground-service -a eu.faircode.email.DISABLE --es account Gmail
@ -192,9 +190,10 @@ public class ServiceExternal extends Service {
if (account == null)
throw new IllegalArgumentException("Account not found name=" + accountName);
db.account().setAccountSynchronize(account.id, enabled);
ServiceSynchronize.eval(context, "external account=" + accountName + " enabled=" + enabled);
db.account().setAccountOnDemand(account.id, !enabled);
}
ServiceSynchronize.eval(context, "external account=" + accountName + " enabled=" + enabled);
}
private static void disconnect(Context context, Intent intent) throws IOException, JSONException {

Loading…
Cancel
Save