Added debug option to add new folders to the nav menu

This commit is contained in:
M66B
2025-10-26 09:29:35 +01:00
parent d0b6492f5c
commit 49ec91e1d3
6 changed files with 34 additions and 5 deletions

View File

@@ -3025,7 +3025,7 @@ class Core {
folder.setSpecials(account);
if (selectable) {
folder.inheritFrom(parent);
folder.inheritFrom(parent, context);
if (user && sync_added_folders && EntityFolder.USER.equals(type)) {
folder.synchronize = true;
folder.notify = true;

View File

@@ -22,9 +22,11 @@ package eu.faircode.email;
import static androidx.room.ForeignKey.CASCADE;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;
@@ -331,7 +333,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
display = "Envoyés";
}
void inheritFrom(EntityFolder parent) {
void inheritFrom(EntityFolder parent, Context context) {
if (parent == null)
return;
if (!EntityFolder.USER.equals(type))
@@ -344,6 +346,11 @@ public class EntityFolder extends EntityOrder implements Serializable {
this.sync_days = parent.sync_days;
this.keep_days = parent.keep_days;
this.notify = parent.notify;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean auto_folder_nav = prefs.getBoolean("auto_folder_nav", false);
if (auto_folder_nav)
this.navigation = true;
}
static boolean shouldPoll(String type) {

View File

@@ -554,7 +554,7 @@ public class FragmentDialogSelectFolder extends FragmentDialogBase {
folder.type = EntityFolder.USER;
folder.parent = (parent == null ? null : parent.id);
folder.setProperties();
folder.inheritFrom(parent);
folder.inheritFrom(parent, context);
folder.id = db.folder().insertFolder(folder);
}

View File

@@ -253,6 +253,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swAdjacentLandscape;
private SwitchCompat swDeleteConfirmation;
private SwitchCompat swDeleteNotification;
private SwitchCompat swAutoFolderNav;
private SwitchCompat swDmarcViewer;
private EditText etKeywords;
private SwitchCompat swTestIab;
@@ -318,7 +319,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"easy_correct", "paste_plain", "paste_quote", "favicon_uri", "infra", "email_junk", "tld_flags", "json_ld", "dup_msgids", "thread_byref", "save_user_flags", "mdn",
"app_chooser", "app_chooser_share", "share_task",
"adjacent_links", "adjacent_documents", "adjacent_portrait", "adjacent_landscape",
"delete_confirmation", "delete_notification", "global_keywords", "test_iab"
"delete_confirmation", "delete_notification", "auto_folder_nav", "global_keywords", "test_iab"
));
private final static String[] RESET_QUESTIONS = new String[]{
@@ -526,6 +527,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAdjacentLandscape = view.findViewById(R.id.swAdjacentLandscape);
swDeleteConfirmation = view.findViewById(R.id.swDeleteConfirmation);
swDeleteNotification = view.findViewById(R.id.swDeleteNotification);
swAutoFolderNav = view.findViewById(R.id.swAutoFolderNav);
swDmarcViewer = view.findViewById(R.id.swDmarcViewer);
etKeywords = view.findViewById(R.id.etKeywords);
swTestIab = view.findViewById(R.id.swTestIab);
@@ -1887,6 +1889,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swAutoFolderNav.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("auto_folder_nav", checked).apply();
}
});
swDmarcViewer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -2676,6 +2685,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAdjacentLandscape.setChecked(prefs.getBoolean("adjacent_landscape", false));
swDeleteConfirmation.setChecked(prefs.getBoolean("delete_confirmation", true));
swDeleteNotification.setChecked(prefs.getBoolean("delete_notification", false));
swAutoFolderNav.setChecked(prefs.getBoolean("auto_folder_nav", false));
swDmarcViewer.setChecked(Helper.isComponentEnabled(getContext(), ActivityDMARC.class));
etKeywords.setText(prefs.getString("global_keywords", null));
swTestIab.setChecked(prefs.getBoolean("test_iab", false));