mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-02 23:26:12 +02:00
Added option to sync all folders
This commit is contained in:
@@ -471,12 +471,26 @@ public class FragmentAccounts extends FragmentBase {
|
||||
boolean outbox = false;
|
||||
boolean force = args.getBoolean("force");
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean pull_all = prefs.getBoolean("pull_all", false);
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
||||
// Unified inbox
|
||||
List<EntityFolder> folders = db.folder().getFoldersUnified(null, true);
|
||||
List<EntityFolder> folders;
|
||||
if (pull_all) {
|
||||
folders = new ArrayList<>();
|
||||
List<EntityAccount> accounts = db.account().getSynchronizingAccounts(null);
|
||||
if (accounts != null)
|
||||
for (EntityAccount account : accounts) {
|
||||
List<EntityFolder> f = db.folder().getFolders(account.id, false, true);
|
||||
if (f != null)
|
||||
folders.addAll(f);
|
||||
}
|
||||
} else
|
||||
folders = db.folder().getFoldersUnified(null, true);
|
||||
|
||||
if (folders.size() > 0)
|
||||
Collections.sort(folders, folders.get(0).getComparator(context));
|
||||
|
||||
@@ -552,6 +552,9 @@ public class FragmentFolders extends FragmentBase {
|
||||
boolean outbox = false;
|
||||
boolean force = args.getBoolean("force");
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean pull_all = prefs.getBoolean("pull_all", false);
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
@@ -565,8 +568,12 @@ public class FragmentFolders extends FragmentBase {
|
||||
List<EntityFolder> folders;
|
||||
if (aid < 0)
|
||||
folders = db.folder().getFoldersUnified(null, true);
|
||||
else
|
||||
folders = db.folder().getSynchronizingFolders(aid);
|
||||
else {
|
||||
if (pull_all)
|
||||
folders = db.folder().getFolders(aid, false, true);
|
||||
else
|
||||
folders = db.folder().getSynchronizingFolders(aid);
|
||||
}
|
||||
|
||||
if (folders.size() > 0)
|
||||
Collections.sort(folders, folders.get(0).getComparator(context));
|
||||
|
||||
@@ -63,6 +63,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||
private SwitchCompat swLanguageDetection;
|
||||
private EditText etDefaultSnooze;
|
||||
private SwitchCompat swPull;
|
||||
private SwitchCompat swPullAll;
|
||||
private SwitchCompat swAutoScroll;
|
||||
private SwitchCompat swQuickFilter;
|
||||
private SwitchCompat swQuickScroll;
|
||||
@@ -114,7 +115,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"restore_on_launch", "sync_on_launch", "double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
|
||||
"photo_picker", "default_snooze",
|
||||
"pull", "autoscroll", "quick_filter", "quick_scroll", "quick_actions", "swipe_sensitivity", "foldernav",
|
||||
"pull", "pull_all", "autoscroll", "quick_filter", "quick_scroll", "quick_actions", "swipe_sensitivity", "foldernav",
|
||||
"doubletap", "swipenav", "volumenav", "reversed", "swipe_close", "swipe_move",
|
||||
"autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple",
|
||||
"autoclose", "onclose", "autoclose_unseen", "autoclose_send", "collapse_marked",
|
||||
@@ -143,6 +144,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||
swLanguageDetection = view.findViewById(R.id.swLanguageDetection);
|
||||
etDefaultSnooze = view.findViewById(R.id.etDefaultSnooze);
|
||||
swPull = view.findViewById(R.id.swPull);
|
||||
swPullAll = view.findViewById(R.id.swPullAll);
|
||||
swAutoScroll = view.findViewById(R.id.swAutoScroll);
|
||||
swQuickFilter = view.findViewById(R.id.swQuickFilter);
|
||||
swQuickScroll = view.findViewById(R.id.swQuickScroll);
|
||||
@@ -274,6 +276,14 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("pull", checked).apply();
|
||||
swPullAll.setEnabled(checked);
|
||||
}
|
||||
});
|
||||
|
||||
swPullAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("pull_all", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -658,6 +668,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||
etDefaultSnooze.setHint("1");
|
||||
|
||||
swPull.setChecked(prefs.getBoolean("pull", true));
|
||||
swPullAll.setChecked(prefs.getBoolean("pull_all", false));
|
||||
swPullAll.setEnabled(swPull.isChecked());
|
||||
swAutoScroll.setChecked(prefs.getBoolean("autoscroll", false));
|
||||
swQuickFilter.setChecked(prefs.getBoolean("quick_filter", false));
|
||||
swQuickScroll.setChecked(prefs.getBoolean("quick_scroll", true));
|
||||
|
||||
Reference in New Issue
Block a user