diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 62dff428dc..ad6c404d6a 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -964,9 +964,11 @@ class Core { boolean sync_unseen = prefs.getBoolean("sync_unseen", false); boolean sync_flagged = prefs.getBoolean("sync_flagged", true); boolean sync_kept = prefs.getBoolean("sync_kept", true); + boolean delete_unseen = prefs.getBoolean("delete_unseen", false); Log.i(folder.name + " start sync after=" + sync_days + "/" + keep_days + - " sync unseen=" + sync_unseen + " flagged=" + sync_flagged + " kept=" + sync_kept); + " sync unseen=" + sync_unseen + " flagged=" + sync_flagged + + " delete unseen=" + delete_unseen + " kept=" + sync_kept); db.folder().setFolderSyncState(folder.id, "syncing"); @@ -997,7 +999,7 @@ class Core { // Delete old local messages if (auto_delete && EntityFolder.TRASH.equals(folder.type)) { - List tbds = db.message().getMessagesBefore(folder.id, keep_time, false); + List tbds = db.message().getMessagesBefore(folder.id, keep_time, delete_unseen); Log.i(folder.name + " local tbd=" + tbds.size()); for (Long tbd : tbds) { EntityMessage message = db.message().getMessage(tbd); @@ -1005,7 +1007,7 @@ class Core { EntityOperation.queue(context, message, EntityOperation.DELETE); } } else { - int old = db.message().deleteMessagesBefore(folder.id, keep_time, false); + int old = db.message().deleteMessagesBefore(folder.id, keep_time, delete_unseen); Log.i(folder.name + " local old=" + old); } diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java index 39c4fb9668..7c5d4ed860 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java @@ -55,11 +55,13 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr private TextView tvSchedulePro; private SwitchCompat swUnseen; private SwitchCompat swFlagged; + private SwitchCompat swDeleteUnseen; private SwitchCompat swSyncKept; private SwitchCompat swSyncFolders; private final static String[] RESET_OPTIONS = new String[]{ - "enabled", "poll_interval", "schedule", "schedule_start", "schedule_end", "sync_unseen", "sync_flagged", "sync_kept", "sync_folders" + "enabled", "poll_interval", "schedule", "schedule_start", "schedule_end", + "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "sync_folders" }; @Override @@ -80,6 +82,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr tvSchedulePro = view.findViewById(R.id.tvSchedulePro); swUnseen = view.findViewById(R.id.swUnseen); swFlagged = view.findViewById(R.id.swFlagged); + swDeleteUnseen = view.findViewById(R.id.swDeleteUnseen); swSyncKept = view.findViewById(R.id.swSyncKept); swSyncFolders = view.findViewById(R.id.swSyncFolders); @@ -172,6 +175,14 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr } }); + swDeleteUnseen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("delete_unseen", checked).apply(); + ServiceSynchronize.reload(getContext(), false, "delete_unseen=" + checked); + } + }); + swSyncKept.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -251,6 +262,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr swUnseen.setChecked(prefs.getBoolean("sync_unseen", false)); swFlagged.setChecked(prefs.getBoolean("sync_flagged", true)); + swDeleteUnseen.setChecked(prefs.getBoolean("delete_unseen", false)); swSyncKept.setChecked(prefs.getBoolean("sync_kept", true)); swSyncFolders.setChecked(prefs.getBoolean("sync_folders", true)); } diff --git a/app/src/main/res/layout/fragment_options_synchronize.xml b/app/src/main/res/layout/fragment_options_synchronize.xml index f8367b6e1c..33839aff90 100644 --- a/app/src/main/res/layout/fragment_options_synchronize.xml +++ b/app/src/main/res/layout/fragment_options_synchronize.xml @@ -175,6 +175,17 @@ app:layout_constraintTop_toBottomOf="@id/swUnseen" app:switchPadding="12dp" /> + + Schedule All unread messages All starred messages + Delete old unread messages Check if old messages were removed from the server Synchronize folder list