From df90d4fe0db6c3753a4681e60922ea4bd9e463eb Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 24 Jan 2023 18:29:52 +0100 Subject: [PATCH] Cloud sync: require network connection --- FAQ.md | 2 +- app/src/main/java/eu/faircode/email/WorkerSync.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/FAQ.md b/FAQ.md index 192631704d..01a384f465 100644 --- a/FAQ.md +++ b/FAQ.md @@ -5176,7 +5176,7 @@ To activate a cloud sync account, use the *Activate* button to send an email to The email needs to come from an address used to activate the pro features before. You'll receive an email in response indicating whether the activation was succesful or not. -The app will automatically synchronize once a day around 1:30am, but you can manually synchronize too. +The app will automatically synchronize once a day around 1:30am, provided that there is an internet connection, but you can manually synchronize too. Synchronization will currently add and update enabled accounts and identities only, but on the roadmap is synchronizing blocked senders and filter rules too. diff --git a/app/src/main/java/eu/faircode/email/WorkerSync.java b/app/src/main/java/eu/faircode/email/WorkerSync.java index 88e0e30f92..2717bc9366 100644 --- a/app/src/main/java/eu/faircode/email/WorkerSync.java +++ b/app/src/main/java/eu/faircode/email/WorkerSync.java @@ -27,7 +27,9 @@ import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.preference.PreferenceManager; +import androidx.work.Constraints; import androidx.work.ExistingPeriodicWorkPolicy; +import androidx.work.NetworkType; import androidx.work.PeriodicWorkRequest; import androidx.work.WorkManager; import androidx.work.Worker; @@ -90,7 +92,9 @@ public class WorkerSync extends Worker { "Queuing " + getName() + " delay=" + (delay / (60 * 1000L)) + "m"); PeriodicWorkRequest.Builder builder = new PeriodicWorkRequest.Builder(WorkerSync.class, 1, TimeUnit.DAYS) - .setInitialDelay(delay, TimeUnit.MILLISECONDS); + .setInitialDelay(delay, TimeUnit.MILLISECONDS) + .setConstraints(new Constraints.Builder() + .setRequiredNetworkType(NetworkType.CONNECTED).build()); WorkManager.getInstance(context) .enqueueUniquePeriodicWork(getName(), ExistingPeriodicWorkPolicy.KEEP, builder.build()); Log.i("Queued " + getName());