diff --git a/FAQ.md b/FAQ.md
index 9cf8c02879..30fd09793a 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -1711,29 +1711,32 @@ so there is little room for performance improvements.
**(78) How do I use schedules?**
-In the settingss you can enable scheduling and set the time to turn synchronizing automatically on and off.
+In the receive settings you can enable scheduling and set the time period for when messages should be received.
-An end time equal to or earlier than the start time is considered to be 24 hours later.
+Note that an end time equal to or earlier than the start time is considered to be 24 hours later.
-Turning FairEmail on or off, for example by using [a quick settings tile](#user-content-faq30), will not turn scheduling off.
-This means that the next schedule event will still turn FairEmail on or off.
+For more complex schemes you could set one or more accounts to manual synchronization
+and send this command to FairEmail to check for new messages:
-You can also automate turning synchronization on and off by sending these commands to FairEmail:
+```
+(adb shell) am startservice -a eu.faircode.email.POLL
+```
+
+For a specific account:
+
+```
+(adb shell) am startservice -a eu.faircode.email.POLL --es account Gmail
+```
+
+You can also automate turning receiving messages on and off by sending these commands to FairEmail:
```
(adb shell) am startservice -a eu.faircode.email.ENABLE
(adb shell) am startservice -a eu.faircode.email.DISABLE
```
-Sending these commands will turn scheduling off.
+To enable/disable a specific account:
-If you want to automate checking for new messages, you can send this command to FairEmail:
-
-```
-(adb shell) adb shell am startservice -a eu.faircode.email.POLL
-```
-
-It is also possible to enable/disable an account, for example the account with the name *Gmail*:
```
(adb shell) am startservice -a eu.faircode.email.ENABLE --es account Gmail
(adb shell) am startservice -a eu.faircode.email.DISABLE --es account Gmail
diff --git a/app/src/main/assets/SETUP.md b/app/src/main/assets/SETUP.md
index 1313a9c11e..d133712257 100644
--- a/app/src/main/assets/SETUP.md
+++ b/app/src/main/assets/SETUP.md
@@ -62,5 +62,4 @@ Tap *Disable battery optimizations* and follow the instructions.
## Questions or problems
-If you have a question or problem, please [see here](https://github.com/M66B/FairEmail/blob/master/FAQ.md)
-or use [this contact form](https://contact.faircode.eu/?product=fairemailsupport) to ask for help (you can use the transaction number "*setup help*").
+If you have a question or problem, please [see here](https://github.com/M66B/FairEmail/blob/master/FAQ.md) for help.
diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java
index 4d2cb059d9..ddb4b08506 100644
--- a/app/src/main/java/eu/faircode/email/ActivityView.java
+++ b/app/src/main/java/eu/faircode/email/ActivityView.java
@@ -779,7 +779,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
new SimpleTask() {
@Override
protected Void onExecute(Context context, Bundle args) {
- WorkerPoll.sync(context);
+ WorkerPoll.sync(context, null);
return null;
}
diff --git a/app/src/main/java/eu/faircode/email/ServiceExternal.java b/app/src/main/java/eu/faircode/email/ServiceExternal.java
index d9d5fecc47..3d06c5a47d 100644
--- a/app/src/main/java/eu/faircode/email/ServiceExternal.java
+++ b/app/src/main/java/eu/faircode/email/ServiceExternal.java
@@ -29,6 +29,8 @@ import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import androidx.preference.PreferenceManager;
+import java.util.Collections;
+import java.util.List;
import java.util.concurrent.ExecutorService;
public class ServiceExternal extends Service {
@@ -36,7 +38,7 @@ public class ServiceExternal extends Service {
private static final String ACTION_ENABLE = BuildConfig.APPLICATION_ID + ".ENABLE";
private static final String ACTION_DISABLE = BuildConfig.APPLICATION_ID + ".DISABLE";
- // adb shell am startservice -a eu.faircode.email.POLL
+ // adb shell am startservice -a eu.faircode.email.POLL --es account Gmail
// adb shell am startservice -a eu.faircode.email.ENABLE --es account Gmail
// adb shell am startservice -a eu.faircode.email.DISABLE --es account Gmail
@@ -73,20 +75,11 @@ public class ServiceExternal extends Service {
if (!ActivityBilling.isPro(this))
return START_NOT_STICKY;
- String action = intent.getAction();
-
- if (ACTION_POLL.equals(action)) {
- final Context context = getApplicationContext();
- executor.submit(new Runnable() {
- @Override
- public void run() {
- WorkerPoll.sync(context);
- }
- });
- return START_NOT_STICKY;
- }
+ final Context context = getApplicationContext();
+ final String accountName = intent.getStringExtra("account");
final Boolean enabled;
+ String action = intent.getAction();
if (ACTION_ENABLE.equals(action))
enabled = true;
else if (ACTION_DISABLE.equals(action))
@@ -94,32 +87,35 @@ public class ServiceExternal extends Service {
else
enabled = null;
- if (enabled != null) {
- final String accountName = intent.getStringExtra("account");
- if (accountName == null) {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- prefs.edit().putBoolean("schedule", false).apply();
-
- boolean previous = prefs.getBoolean("enabled", true);
- if (!enabled.equals(previous)) {
- prefs.edit().putBoolean("enabled", enabled).apply();
- ServiceSynchronize.eval(this, "external");
- }
- } else {
- final Context context = getApplicationContext();
- executor.submit(new Runnable() {
- @Override
- public void run() {
- DB db = DB.getInstance(context);
- EntityAccount account = db.account().getAccount(accountName);
- if (account != null) {
- db.account().setAccountSynchronize(account.id, enabled);
- ServiceSynchronize.eval(context, "account enabled=" + enabled);
- }
+ executor.submit(new Runnable() {
+ @Override
+ public void run() {
+ if (accountName == null) {
+ if (enabled == null)
+ WorkerPoll.sync(context, null);
+ else {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ prefs.edit().putBoolean("enabled", enabled).apply();
+ ServiceSynchronize.eval(context, "external enabled=" + enabled);
}
- });
+ } else {
+ DB db = DB.getInstance(context);
+
+ EntityAccount account = db.account().getAccount(accountName);
+ if (account == null) {
+ EntityLog.log(context, "Account not found name=" + accountName);
+ return;
+ }
+
+ if (enabled == null)
+ WorkerPoll.sync(context, account.id);
+ else {
+ db.account().setAccountSynchronize(account.id, enabled);
+ ServiceSynchronize.eval(context, "external account=" + accountName + " enabled=" + enabled);
+ }
+ }
}
- }
+ });
return START_NOT_STICKY;
} finally {
diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java
index a174f4a12b..9ae6fc0837 100644
--- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java
+++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java
@@ -1304,27 +1304,27 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(@NonNull Network network) {
- ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- EntityLog.log(ServiceSynchronize.this, "Available network=" + network +
- " capabilities " + cm.getNetworkCapabilities(network));
+ EntityLog.log(ServiceSynchronize.this, "Available network=" + network);
updateState();
}
@Override
public void onCapabilitiesChanged(@NonNull Network network, @NonNull NetworkCapabilities capabilities) {
- ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- EntityLog.log(ServiceSynchronize.this, "Changed network=" + network +
- " capabilities " + cm.getNetworkCapabilities(network));
+ EntityLog.log(ServiceSynchronize.this, "Changed network=" + network + " capabilities " + capabilities);
updateState();
}
@Override
public void onLost(@NonNull Network network) {
- ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo active = cm.getActiveNetworkInfo();
- EntityLog.log(ServiceSynchronize.this, "Lost network=" + network + " active=" + active);
- if (active == null)
- lastLost = new Date().getTime();
+ try {
+ ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo active = cm.getActiveNetworkInfo();
+ EntityLog.log(ServiceSynchronize.this, "Lost network=" + network + " active=" + active);
+ if (active == null)
+ lastLost = new Date().getTime();
+ } catch (Throwable ex) {
+ Log.w(ex);
+ }
updateState();
}
diff --git a/app/src/main/java/eu/faircode/email/ServiceTileUnseen.java b/app/src/main/java/eu/faircode/email/ServiceTileUnseen.java
index a75e00776d..d42fdaff15 100644
--- a/app/src/main/java/eu/faircode/email/ServiceTileUnseen.java
+++ b/app/src/main/java/eu/faircode/email/ServiceTileUnseen.java
@@ -101,7 +101,7 @@ public class ServiceTileUnseen extends TileService {
new Thread(new Runnable() {
@Override
public void run() {
- WorkerPoll.sync(context);
+ WorkerPoll.sync(context, null);
}
}).start();
}
diff --git a/app/src/main/java/eu/faircode/email/WorkerPoll.java b/app/src/main/java/eu/faircode/email/WorkerPoll.java
index a06b63f80a..3685ace48d 100644
--- a/app/src/main/java/eu/faircode/email/WorkerPoll.java
+++ b/app/src/main/java/eu/faircode/email/WorkerPoll.java
@@ -45,7 +45,7 @@ public class WorkerPoll extends Worker {
public Result doWork() {
Log.i("Running " + getName());
- sync(getApplicationContext());
+ sync(getApplicationContext(), null);
return Result.success();
}
@@ -76,19 +76,20 @@ public class WorkerPoll extends Worker {
}
}
- static void sync(Context context) {
+ static void sync(Context context, Long aid) {
DB db = DB.getInstance(context);
try {
db.beginTransaction();
List accounts = db.account().getSynchronizingAccounts();
- for (EntityAccount account : accounts) {
- List folders = db.folder().getSynchronizingFolders(account.id);
- if (folders.size() > 0)
- Collections.sort(folders, folders.get(0).getComparator(context));
- for (EntityFolder folder : folders)
- EntityOperation.sync(context, folder.id, false);
- }
+ for (EntityAccount account : accounts)
+ if (aid == null || account.id.equals(aid)) {
+ List folders = db.folder().getSynchronizingFolders(account.id);
+ if (folders.size() > 0)
+ Collections.sort(folders, folders.get(0).getComparator(context));
+ for (EntityFolder folder : folders)
+ EntityOperation.sync(context, folder.id, false);
+ }
db.setTransactionSuccessful();
} finally {
diff --git a/app/src/main/res/layout/fragment_options_synchronize.xml b/app/src/main/res/layout/fragment_options_synchronize.xml
index db69a1ba15..cb4120fffb 100644
--- a/app/src/main/res/layout/fragment_options_synchronize.xml
+++ b/app/src/main/res/layout/fragment_options_synchronize.xml
@@ -30,7 +30,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
- android:text="@string/title_advanced_enabled"
+ android:text="@string/title_advanced_receive"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAdvancedHint"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5f479125e1..18a76a8069 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -221,7 +221,7 @@
Privacy
Miscellaneous
- Enabled
+ Receive messages
When
Schedule
All unread messages