From b6964662d1b40ddb636b36640c45664689c5490b Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 15 Nov 2020 16:01:18 +0100 Subject: [PATCH] Added option to sync subscribed folders --- app/src/main/java/eu/faircode/email/Core.java | 3 ++- .../faircode/email/FragmentOptionsSynchronize.java | 14 +++++++++++++- .../res/layout/fragment_options_synchronize.xml | 13 ++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 1d679bfddc..6c30465fd7 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1529,6 +1529,7 @@ class Core { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean sync_folders = (prefs.getBoolean("sync_folders", true) || force); boolean sync_shared_folders = prefs.getBoolean("sync_shared_folders", false); + boolean sync_subscribed = prefs.getBoolean("sync_subscribed", false); // Get folder names Map local = new HashMap<>(); @@ -1709,7 +1710,7 @@ class Core { folder.account = account.id; folder.name = fullName; folder.type = (EntityFolder.SYSTEM.equals(type) ? type : EntityFolder.USER); - folder.synchronize = false; + folder.synchronize = (subscribed && sync_subscribed); folder.subscribed = subscribed; folder.poll = true; folder.sync_days = EntityFolder.DEFAULT_SYNC; diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java index bbcd0659c5..f2a639cd3c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java @@ -81,6 +81,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr private SwitchCompat swSyncFolders; private SwitchCompat swSyncSharedFolders; private SwitchCompat swSubscriptions; + private SwitchCompat swSyncSubscribed; private SwitchCompat swCheckMx; private SwitchCompat swCheckReply; private SwitchCompat swTuneKeepAlive; @@ -91,7 +92,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr private final static String[] RESET_OPTIONS = new String[]{ "enabled", "poll_interval", "auto_optimize", "schedule", "schedule_start", "schedule_end", "sync_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "gmail_thread_id", - "sync_folders", "sync_shared_folders", "subscriptions", + "sync_folders", "sync_shared_folders", "subscriptions", "sync_subscribed", "check_mx", "check_reply", "tune_keep_alive" }; @@ -135,6 +136,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr swSyncFolders = view.findViewById(R.id.swSyncFolders); swSyncSharedFolders = view.findViewById(R.id.swSyncSharedFolders); swSubscriptions = view.findViewById(R.id.swSubscriptions); + swSyncSubscribed = view.findViewById(R.id.swSyncSubscribed); swCheckMx = view.findViewById(R.id.swCheckMx); swCheckReply = view.findViewById(R.id.swCheckReply); swTuneKeepAlive = view.findViewById(R.id.swTuneKeepAlive); @@ -308,6 +310,14 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("subscriptions", checked).apply(); + swSyncSubscribed.setEnabled(checked); + } + }); + + swSyncSubscribed.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("sync_subscribed", checked).apply(); } }); @@ -420,6 +430,8 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr swSyncSharedFolders.setChecked(prefs.getBoolean("sync_shared_folders", false)); swSyncSharedFolders.setEnabled(swSyncFolders.isChecked()); swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false)); + swSyncSubscribed.setChecked(prefs.getBoolean("sync_subscribed", false)); + swSyncSubscribed.setEnabled(swSubscriptions.isChecked()); swCheckMx.setChecked(prefs.getBoolean("check_mx", false)); swCheckReply.setChecked(prefs.getBoolean("check_reply", false)); swTuneKeepAlive.setChecked(prefs.getBoolean("tune_keep_alive", true)); diff --git a/app/src/main/res/layout/fragment_options_synchronize.xml b/app/src/main/res/layout/fragment_options_synchronize.xml index f0a33a4deb..804fadb4c6 100644 --- a/app/src/main/res/layout/fragment_options_synchronize.xml +++ b/app/src/main/res/layout/fragment_options_synchronize.xml @@ -466,6 +466,17 @@ app:layout_constraintTop_toBottomOf="@id/swSyncSharedFolders" app:switchPadding="12dp" /> + + Synchronize folder list Synchronize shared folder lists Manage folder subscriptions + Automatically synchronize subscribed folders Check sender email addresses on synchronizing messages Check reply email addresses on synchronizing messages Automatically tune the keep-alive interval