diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index c4b8c7aab2..fc8a86fb81 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1652,6 +1652,7 @@ class Core { keep_days++; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean sync_nodate = prefs.getBoolean("sync_nodate", false); boolean sync_unseen = prefs.getBoolean("sync_unseen", false); boolean sync_flagged = prefs.getBoolean("sync_flagged", false); boolean sync_kept = prefs.getBoolean("sync_kept", true); @@ -1726,6 +1727,8 @@ class Core { // Reduce list of local uids Flags flags = ifolder.getPermanentFlags(); SearchTerm searchTerm = new ReceivedDateTerm(ComparisonTerm.GE, new Date(sync_time)); + if (sync_nodate) + searchTerm = new OrTerm(searchTerm, new ReceivedDateTerm(ComparisonTerm.LT, new Date(365 * 24 * 3600 * 1000L))); if (sync_unseen && flags.contains(Flags.Flag.SEEN)) searchTerm = new OrTerm(searchTerm, new FlagTerm(new Flags(Flags.Flag.SEEN), false)); if (sync_flagged && flags.contains(Flags.Flag.FLAGGED)) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java index 73cbab5c7c..358a3ded47 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java @@ -68,6 +68,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr private TextView tvScheduleStart; private TextView tvScheduleEnd; private CheckBox[] cbDay; + private SwitchCompat swNodate; private SwitchCompat swUnseen; private SwitchCompat swFlagged; private SwitchCompat swDeleteUnseen; @@ -83,7 +84,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr private final static String[] RESET_OPTIONS = new String[]{ "enabled", "poll_interval", "schedule", "schedule_start", "schedule_end", - "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "sync_folders", "subscriptions", + "sync_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "sync_folders", "subscriptions", "check_mx", "check_reply" }; @@ -113,6 +114,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr view.findViewById(R.id.cbDay5), view.findViewById(R.id.cbDay6) }; + swNodate = view.findViewById(R.id.swNodate); swUnseen = view.findViewById(R.id.swUnseen); swFlagged = view.findViewById(R.id.swFlagged); swDeleteUnseen = view.findViewById(R.id.swDeleteUnseen); @@ -214,6 +216,14 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr }); } + swNodate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("sync_nodate", checked).apply(); + ServiceSynchronize.reload(getContext(), null, false, "sync_nodate=" + checked); + } + }); + swUnseen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -353,6 +363,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr for (int i = 0; i < 7; i++) cbDay[i].setChecked(prefs.getBoolean("schedule_day" + i, true)); + swNodate.setChecked(prefs.getBoolean("sync_nodate", false)); swUnseen.setChecked(prefs.getBoolean("sync_unseen", false)); swFlagged.setChecked(prefs.getBoolean("sync_flagged", false)); swDeleteUnseen.setChecked(prefs.getBoolean("delete_unseen", false)); diff --git a/app/src/main/res/layout/fragment_options_synchronize.xml b/app/src/main/res/layout/fragment_options_synchronize.xml index 6705e3e889..1a7c3aeff4 100644 --- a/app/src/main/res/layout/fragment_options_synchronize.xml +++ b/app/src/main/res/layout/fragment_options_synchronize.xml @@ -257,6 +257,29 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cbDay6" /> + + + + Always synchronize these accounts Schedule Advanced + Messages without date All unread messages All starred messages Delete old unread messages @@ -455,6 +456,7 @@ Tap on a time to set a time Check sender email addresses on synchronizing messages Check reply email addresses on synchronizing messages + Some providers store messages with an unknown, invalid or future date as messages without date Some providers don\'t support this properly, which may cause synchronizing none or all messages When disabled, unread messages are kept on the device forever This will transfer extra data and consume extra battery power, especially if a lot of messages are stored on the device