diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 42f836ec68..109c76650a 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1285,6 +1285,7 @@ class Core { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean sync_folders = prefs.getBoolean("sync_folders", true); + boolean sync_shared_folders = prefs.getBoolean("sync_shared_folders", false); // Get folder names Map local = new HashMap<>(); @@ -1357,7 +1358,20 @@ class Core { // Get remote folders long start = new Date().getTime(); - Folder[] ifolders = defaultFolder.list("*"); + List ifolders = new ArrayList<>(); + ifolders.addAll(Arrays.asList(defaultFolder.list("*"))); + + if (sync_shared_folders) { + Folder[] namespaces = istore.getSharedNamespaces(); + Log.i("Namespaces=" + namespaces.length); + for (Folder namespace : namespaces) { + Log.i("Namespace=" + namespace.getFullName()); + if (namespace.getSeparator() == separator) + ifolders.addAll(Arrays.asList(namespace.list("*"))); + else + Log.e("Namespace separator=" + namespace.getSeparator() + " default=" + separator); + } + } List subscription = new ArrayList<>(); try { @@ -1370,7 +1384,7 @@ class Core { long duration = new Date().getTime() - start; - Log.i("Remote folder count=" + ifolders.length + + Log.i("Remote folder count=" + ifolders.size() + " separator=" + separator + " fetched in " + duration + " ms"); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java index d24669969a..231848ef34 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java @@ -75,6 +75,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr private SwitchCompat swSyncKept; private SwitchCompat swGmailThread; private SwitchCompat swSyncFolders; + private SwitchCompat swSyncSharedFolders; private SwitchCompat swSubscriptions; private TextView tvSubscriptionPro; private SwitchCompat swCheckMx; @@ -86,7 +87,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr private final static String[] RESET_OPTIONS = new String[]{ "enabled", "poll_interval", "schedule", "schedule_start", "schedule_end", "sync_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "gmail_thread_id", - "sync_folders", "subscriptions", + "sync_folders", "sync_shared_folders", "subscriptions", "check_mx", "check_reply" }; @@ -123,6 +124,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr swSyncKept = view.findViewById(R.id.swSyncKept); swGmailThread = view.findViewById(R.id.swGmailThread); swSyncFolders = view.findViewById(R.id.swSyncFolders); + swSyncSharedFolders = view.findViewById(R.id.swSyncSharedFolders); swSubscriptions = view.findViewById(R.id.swSubscriptions); tvSubscriptionPro = view.findViewById(R.id.tvSubscriptionPro); swCheckMx = view.findViewById(R.id.swCheckMx); @@ -270,10 +272,19 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("sync_folders", checked).apply(); + swSyncSharedFolders.setEnabled(checked); ServiceSynchronize.reload(getContext(), null, false, "sync_folders=" + checked); } }); + swSyncSharedFolders.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("sync_shared_folders", checked).apply(); + ServiceSynchronize.reload(getContext(), null, false, "sync_shared_folders=" + checked); + } + }); + swSubscriptions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -380,6 +391,8 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr swSyncKept.setChecked(prefs.getBoolean("sync_kept", true)); swGmailThread.setChecked(prefs.getBoolean("gmail_thread_id", false)); swSyncFolders.setChecked(prefs.getBoolean("sync_folders", true)); + swSyncSharedFolders.setChecked(prefs.getBoolean("sync_shared_folders", false)); + swSyncSharedFolders.setEnabled(swSyncFolders.isChecked()); swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false) && pro); swSubscriptions.setEnabled(pro); swCheckMx.setChecked(prefs.getBoolean("check_mx", false)); diff --git a/app/src/main/res/layout/fragment_options_synchronize.xml b/app/src/main/res/layout/fragment_options_synchronize.xml index 33717c47e1..06a1b48b3a 100644 --- a/app/src/main/res/layout/fragment_options_synchronize.xml +++ b/app/src/main/res/layout/fragment_options_synchronize.xml @@ -422,6 +422,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swSyncFolders" /> + + Check if old messages were removed from the server Gmail message grouping style for Gmail accounts Synchronize folder list + Synchronize shared folder lists Manage folder subscriptions Show keyboard by default