Let child folders inherit parent folder properties

pull/194/head
M66B 4 years ago
parent ca4ad64ae5
commit c93fc62271

@ -1686,7 +1686,6 @@ class Core {
boolean sync_folders = (prefs.getBoolean("sync_folders", true) || force);
boolean sync_shared_folders = prefs.getBoolean("sync_shared_folders", false);
boolean subscriptions = prefs.getBoolean("subscriptions", false);
boolean sync_subscribed = prefs.getBoolean("sync_subscribed", false);
// Get folder names
boolean drafts = false;
@ -1890,18 +1889,36 @@ class Core {
folder = db.folder().getFolderByName(account.id, fullName);
if (folder == null) {
EntityFolder parent = null;
int sep = fullName.lastIndexOf(account.separator);
if (sep > 0) {
parent = db.folder().getFolderByName(account.id, fullName.substring(0, sep));
if (parent != null && !EntityFolder.USER.equals(parent.type))
parent = null;
}
folder = new EntityFolder();
folder.account = account.id;
folder.name = fullName;
folder.type = (EntityFolder.SYSTEM.equals(type) ? type : EntityFolder.USER);
folder.synchronize = (subscribed && subscriptions && sync_subscribed);
folder.subscribed = subscribed;
folder.poll = true;
folder.sync_days = EntityFolder.DEFAULT_SYNC;
folder.keep_days = EntityFolder.DEFAULT_KEEP;
folder.selectable = selectable;
folder.inferiors = inferiors;
folder.setProperties();
folder.setSpecials(account);
if (parent != null) {
folder.synchronize = parent.synchronize;
folder.poll = parent.poll;
folder.poll_factor = parent.poll_factor;
folder.download = parent.download;
folder.auto_classify_source = parent.auto_classify_source;
folder.auto_classify_target = parent.auto_classify_target;
folder.unified = parent.unified;
folder.navigation = parent.navigation;
folder.notify = parent.notify;
}
folder.id = db.folder().insertFolder(folder);
Log.i(folder.name + " added type=" + folder.type + " sync=" + folder.synchronize);
if (folder.synchronize)

@ -81,7 +81,6 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
private SwitchCompat swSyncFolders;
private SwitchCompat swSyncSharedFolders;
private SwitchCompat swSubscriptions;
private SwitchCompat swSyncSubscribed;
private SwitchCompat swCheckMx;
private SwitchCompat swTuneKeepAlive;
private Group grpExempted;
@ -91,7 +90,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_subscribed",
"sync_folders", "sync_shared_folders", "subscriptions",
"check_mx", "tune_keep_alive"
};
@ -135,7 +134,6 @@ 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);
swTuneKeepAlive = view.findViewById(R.id.swTuneKeepAlive);
grpExempted = view.findViewById(R.id.grpExempted);
@ -308,14 +306,6 @@ 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();
}
});
@ -419,8 +409,6 @@ 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));
swTuneKeepAlive.setChecked(prefs.getBoolean("tune_keep_alive", true));
}

@ -493,17 +493,6 @@
app:layout_constraintTop_toBottomOf="@id/swSyncSharedFolders"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSyncSubscribed"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_sync_subscribed"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSubscriptions"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCheckMx"
android:layout_width="0dp"
@ -512,7 +501,7 @@
android:text="@string/title_advanced_check_mx"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSyncSubscribed"
app:layout_constraintTop_toBottomOf="@id/swSubscriptions"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView

@ -300,7 +300,6 @@
<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_sync_subscribed">Automatically synchronize subscribed folders</string>
<string name="title_advanced_check_mx">Check sender email addresses on synchronizing messages</string>
<string name="title_advanced_tune_keep_alive">Automatically tune the keep-alive interval</string>

Loading…
Cancel
Save