Added option to enable sync for new folders

This commit is contained in:
M66B 2023-02-19 18:12:01 +01:00
parent ee4e9bb010
commit 5321b27df6
4 changed files with 31 additions and 2 deletions

View File

@ -2253,9 +2253,11 @@ class Core {
boolean sync_folders = prefs.getBoolean("sync_folders", true);
boolean sync_folders_poll = prefs.getBoolean("sync_folders_poll", false);
boolean sync_shared_folders = prefs.getBoolean("sync_shared_folders", false);
boolean sync_added_folders = prefs.getBoolean("sync_added_folders", false);
Log.i(account.name + " sync folders=" + sync_folders +
" poll=" + sync_folders_poll +
" shared=" + sync_shared_folders +
" added=" + sync_added_folders +
" keep_alive=" + keep_alive +
" force=" + force);
@ -2268,9 +2270,12 @@ class Core {
// Get folder names
boolean drafts = false;
boolean user = false;
Map<String, EntityFolder> local = new HashMap<>();
List<EntityFolder> folders = db.folder().getFolders(account.id, false, false);
for (EntityFolder folder : folders) {
if (EntityFolder.USER.equals(folder.type))
user = true;
if (folder.tbc != null) {
try {
// Prefix folder with namespace
@ -2675,6 +2680,8 @@ class Core {
if (selectable)
folder.inheritFrom(parent);
if (user && sync_added_folders && EntityFolder.USER.equals(type))
folder.synchronize = true;
folder.id = db.folder().insertFolder(folder);
Log.i(folder.name + " added type=" + folder.type + " sync=" + folder.synchronize);

View File

@ -94,6 +94,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
private SwitchCompat swSyncFolders;
private SwitchCompat swSyncFoldersPoll;
private SwitchCompat swSyncSharedFolders;
private SwitchCompat swSyncAdded;
private SwitchCompat swSubscriptions;
private SwitchCompat swTuneKeepAlive;
@ -118,7 +119,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
"sync_quick_imap", "sync_quick_pop",
"sync_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept",
"gmail_thread_id", "outlook_thread_id", "subject_threading",
"sync_folders", "sync_folders_poll", "sync_shared_folders", "subscriptions",
"sync_folders", "sync_folders_poll", "sync_shared_folders", "sync_added_folders", "subscriptions",
"check_authentication", "check_tls", "check_reply_domain", "check_mx",
"check_blocklist", "use_blocklist", "use_blocklist_pop",
"tune_keep_alive"
@ -173,6 +174,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swSyncFolders = view.findViewById(R.id.swSyncFolders);
swSyncFoldersPoll = view.findViewById(R.id.swSyncFoldersPoll);
swSyncSharedFolders = view.findViewById(R.id.swSyncSharedFolders);
swSyncAdded = view.findViewById(R.id.swSyncAdded);
swSubscriptions = view.findViewById(R.id.swSubscriptions);
swTuneKeepAlive = view.findViewById(R.id.swTuneKeepAlive);
@ -419,6 +421,13 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
}
});
swSyncAdded.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("sync_added_folders", checked).apply();
}
});
swSubscriptions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -603,6 +612,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swSyncFoldersPoll.setEnabled(swSyncFolders.isChecked());
swSyncSharedFolders.setChecked(prefs.getBoolean("sync_shared_folders", false));
swSyncSharedFolders.setEnabled(swSyncFolders.isChecked());
swSyncAdded.setChecked(prefs.getBoolean("sync_added_folders", false));
swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false));
swTuneKeepAlive.setChecked(prefs.getBoolean("tune_keep_alive", true));
swCheckAuthentication.setChecked(prefs.getBoolean("check_authentication", true));

View File

@ -757,6 +757,17 @@
app:layout_constraintTop_toBottomOf="@id/tvSyncFoldersPoll"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSyncAdded"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_sync_added"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSyncSharedFolders"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSubscriptions"
android:layout_width="0dp"
@ -765,7 +776,7 @@
android:text="@string/title_advanced_subscriptions"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSyncSharedFolders"
app:layout_constraintTop_toBottomOf="@id/swSyncAdded"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -416,6 +416,7 @@
<string name="title_advanced_sync_folders">Synchronize folder list</string>
<string name="title_advanced_sync_folders_poll">Actively synchronize folder list</string>
<string name="title_advanced_sync_shared_folders">Synchronize shared folder lists</string>
<string name="title_advanced_sync_added">Enable synchronization for new user folders</string>
<string name="title_advanced_subscriptions">Manage folder subscriptions</string>
<string name="title_advanced_check_authentication">Check message authentication</string>
<string name="title_advanced_check_tls">Check transport layer security (TLS)</string>