Cloud sync: require network connection

This commit is contained in:
M66B 2023-01-24 18:29:52 +01:00
parent bb8e7950dc
commit df90d4fe0d
2 changed files with 6 additions and 2 deletions

2
FAQ.md
View File

@ -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.

View File

@ -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());