Added option to sync shared folders

pull/180/head
M66B 5 years ago
parent 4bd20fd369
commit bb0a3577b1

@ -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<String, EntityFolder> local = new HashMap<>();
@ -1357,7 +1358,20 @@ class Core {
// Get remote folders
long start = new Date().getTime();
Folder[] ifolders = defaultFolder.list("*");
List<Folder> 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<String> 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");

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

@ -422,6 +422,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSyncFolders" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSyncSharedFolders"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_sync_shared_folders"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSyncFolders"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSubscriptions"
android:layout_width="0dp"
@ -430,7 +441,7 @@
android:text="@string/title_advanced_subscriptions"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSyncFolders"
app:layout_constraintTop_toBottomOf="@id/swSyncSharedFolders"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView

@ -273,6 +273,7 @@
<string name="title_advanced_kept_removed">Check if old messages were removed from the server</string>
<string name="title_advanced_gmail_thread">Gmail message grouping style for Gmail accounts</string>
<string name="title_advanced_sync_folders">Synchronize folder list</string>
<string name="title_advanced_sync_shared_folders">Synchronize shared folder lists</string>
<string name="title_advanced_subscriptions">Manage folder subscriptions</string>
<string name="title_advanced_keyboard">Show keyboard by default</string>

Loading…
Cancel
Save