Added option to sync all folders

pull/213/head
M66B 1 year ago
parent e0d456a39b
commit af3fee7e85

@ -471,12 +471,26 @@ public class FragmentAccounts extends FragmentBase {
boolean outbox = false; boolean outbox = false;
boolean force = args.getBoolean("force"); boolean force = args.getBoolean("force");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean pull_all = prefs.getBoolean("pull_all", false);
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
// Unified inbox // 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) if (folders.size() > 0)
Collections.sort(folders, folders.get(0).getComparator(context)); Collections.sort(folders, folders.get(0).getComparator(context));

@ -552,6 +552,9 @@ public class FragmentFolders extends FragmentBase {
boolean outbox = false; boolean outbox = false;
boolean force = args.getBoolean("force"); boolean force = args.getBoolean("force");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean pull_all = prefs.getBoolean("pull_all", false);
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
@ -565,8 +568,12 @@ public class FragmentFolders extends FragmentBase {
List<EntityFolder> folders; List<EntityFolder> folders;
if (aid < 0) if (aid < 0)
folders = db.folder().getFoldersUnified(null, true); folders = db.folder().getFoldersUnified(null, true);
else {
if (pull_all)
folders = db.folder().getFolders(aid, false, true);
else else
folders = db.folder().getSynchronizingFolders(aid); folders = db.folder().getSynchronizingFolders(aid);
}
if (folders.size() > 0) if (folders.size() > 0)
Collections.sort(folders, folders.get(0).getComparator(context)); Collections.sort(folders, folders.get(0).getComparator(context));

@ -63,6 +63,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swLanguageDetection; private SwitchCompat swLanguageDetection;
private EditText etDefaultSnooze; private EditText etDefaultSnooze;
private SwitchCompat swPull; private SwitchCompat swPull;
private SwitchCompat swPullAll;
private SwitchCompat swAutoScroll; private SwitchCompat swAutoScroll;
private SwitchCompat swQuickFilter; private SwitchCompat swQuickFilter;
private SwitchCompat swQuickScroll; private SwitchCompat swQuickScroll;
@ -114,7 +115,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"restore_on_launch", "sync_on_launch", "double_back", "conversation_actions", "conversation_actions_replies", "language_detection", "restore_on_launch", "sync_on_launch", "double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
"photo_picker", "default_snooze", "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", "doubletap", "swipenav", "volumenav", "reversed", "swipe_close", "swipe_move",
"autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple", "autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple",
"autoclose", "onclose", "autoclose_unseen", "autoclose_send", "collapse_marked", "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); swLanguageDetection = view.findViewById(R.id.swLanguageDetection);
etDefaultSnooze = view.findViewById(R.id.etDefaultSnooze); etDefaultSnooze = view.findViewById(R.id.etDefaultSnooze);
swPull = view.findViewById(R.id.swPull); swPull = view.findViewById(R.id.swPull);
swPullAll = view.findViewById(R.id.swPullAll);
swAutoScroll = view.findViewById(R.id.swAutoScroll); swAutoScroll = view.findViewById(R.id.swAutoScroll);
swQuickFilter = view.findViewById(R.id.swQuickFilter); swQuickFilter = view.findViewById(R.id.swQuickFilter);
swQuickScroll = view.findViewById(R.id.swQuickScroll); swQuickScroll = view.findViewById(R.id.swQuickScroll);
@ -274,6 +276,14 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("pull", checked).apply(); 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"); etDefaultSnooze.setHint("1");
swPull.setChecked(prefs.getBoolean("pull", true)); swPull.setChecked(prefs.getBoolean("pull", true));
swPullAll.setChecked(prefs.getBoolean("pull_all", false));
swPullAll.setEnabled(swPull.isChecked());
swAutoScroll.setChecked(prefs.getBoolean("autoscroll", false)); swAutoScroll.setChecked(prefs.getBoolean("autoscroll", false));
swQuickFilter.setChecked(prefs.getBoolean("quick_filter", false)); swQuickFilter.setChecked(prefs.getBoolean("quick_filter", false));
swQuickScroll.setChecked(prefs.getBoolean("quick_scroll", true)); swQuickScroll.setChecked(prefs.getBoolean("quick_scroll", true));

@ -249,6 +249,32 @@
app:layout_constraintTop_toBottomOf="@id/tvCaptionList" app:layout_constraintTop_toBottomOf="@id/tvCaptionList"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPullAll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_pull_all"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPull"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvPullAllHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_pull_all_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPullAll" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoScroll" android:id="@+id/swAutoScroll"
android:layout_width="0dp" android:layout_width="0dp"
@ -258,7 +284,7 @@
android:text="@string/title_advanced_autoscroll" android:text="@string/title_advanced_autoscroll"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPull" app:layout_constraintTop_toBottomOf="@id/tvPullAllHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

@ -647,6 +647,7 @@
<string name="title_advanced_language_detection">Detect message text language</string> <string name="title_advanced_language_detection">Detect message text language</string>
<string name="title_advanced_photo_picker">Use the Android photo picker</string> <string name="title_advanced_photo_picker">Use the Android photo picker</string>
<string name="title_advanced_pull_refresh">Pull down to refresh</string> <string name="title_advanced_pull_refresh">Pull down to refresh</string>
<string name="title_advanced_pull_all">Synchronize all folders</string>
<string name="title_advanced_autoscroll">Scroll to top on receiving new messages</string> <string name="title_advanced_autoscroll">Scroll to top on receiving new messages</string>
<string name="title_advanced_double_tap">Double tap to mark message read/unread</string> <string name="title_advanced_double_tap">Double tap to mark message read/unread</string>
<string name="title_advanced_swipenav">Swipe left/right to go to next/previous conversation</string> <string name="title_advanced_swipenav">Swipe left/right to go to next/previous conversation</string>
@ -932,6 +933,7 @@
<string name="title_advanced_lookup_mx_hint">This will check if DNS MX records exist</string> <string name="title_advanced_lookup_mx_hint">This will check if DNS MX records exist</string>
<string name="title_advanced_sync_delay_hint">This will slow down synchronizing messages</string> <string name="title_advanced_sync_delay_hint">This will slow down synchronizing messages</string>
<string name="title_advanced_folder_nav_hint">This will always return to the folder list of the related account from a message list</string> <string name="title_advanced_folder_nav_hint">This will always return to the folder list of the related account from a message list</string>
<string name="title_advanced_pull_all_hint">When pulling down the folder or account list</string>
<string name="title_advanced_suggest_names_hint">If disabled, only email addresses will be used when selecting contacts</string> <string name="title_advanced_suggest_names_hint">If disabled, only email addresses will be used when selecting contacts</string>
<string name="title_advanced_suggest_local_hint">In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled.</string> <string name="title_advanced_suggest_local_hint">In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled.</string>

Loading…
Cancel
Save