From 73864b23bd4fb3b7b4dd99c5531ae46c5b8a17a2 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 28 Jun 2020 11:22:56 +0200 Subject: [PATCH] Folder polling is available with always sync only --- .../java/eu/faircode/email/FragmentFolder.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentFolder.java b/app/src/main/java/eu/faircode/email/FragmentFolder.java index d82e8d6af7..917c31d745 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolder.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolder.java @@ -21,6 +21,7 @@ package eu.faircode.email; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; @@ -43,6 +44,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.Group; import androidx.lifecycle.Lifecycle; +import androidx.preference.PreferenceManager; import com.google.android.material.snackbar.Snackbar; @@ -234,8 +236,10 @@ public class FragmentFolder extends FragmentBase { if (folder != null) { EntityAccount account = db.account().getAccount(folder.account); - if (account != null) + if (account != null) { args.putInt("interval", account.poll_interval); + args.putBoolean("exempted", account.poll_exempted); + } } return folder; @@ -243,8 +247,12 @@ public class FragmentFolder extends FragmentBase { @Override protected void onExecuted(Bundle args, EntityFolder folder) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + int pollInterval = prefs.getInt("poll_interval", ServiceSynchronize.DEFAULT_POLL_INTERVAL); + int interval = args.getInt("interval", EntityAccount.DEFAULT_KEEP_ALIVE_INTERVAL); + boolean exempted = args.getBoolean("exempted", false); + if (savedInstanceState == null) { - int interval = args.getInt("interval", EntityAccount.DEFAULT_KEEP_ALIVE_INTERVAL); etName.setText(folder == null ? null : folder.name); etDisplay.setText(folder == null ? null : folder.display); etDisplay.setHint(folder == null ? null : EntityFolder.localizeName(getContext(), folder.name)); @@ -282,9 +290,9 @@ public class FragmentFolder extends FragmentBase { Helper.setViewsEnabled(view, true); etName.setEnabled(folder == null || EntityFolder.USER.equals(folder.type)); - cbPoll.setEnabled(cbSynchronize.isChecked()); - etPoll.setEnabled(cbSynchronize.isChecked()); - tvPoll.setEnabled(cbSynchronize.isChecked()); + cbPoll.setEnabled(cbSynchronize.isChecked() && (pollInterval == 0 || exempted)); + etPoll.setEnabled(cbSynchronize.isChecked() && (pollInterval == 0 || exempted)); + tvPoll.setEnabled(cbSynchronize.isChecked() && (pollInterval == 0 || exempted)); grpPoll.setVisibility(cbPoll.isEnabled() && cbPoll.isChecked() ? View.VISIBLE : View.GONE); etKeepDays.setEnabled(!cbKeepAll.isChecked()); cbAutoDelete.setEnabled(!cbKeepAll.isChecked());