1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-29 11:15:51 +00:00

Added setting to delete old, unseen messages

This commit is contained in:
M66B 2019-07-06 18:13:38 +02:00
parent 6a6be9f9c3
commit 338523ac0c
4 changed files with 31 additions and 5 deletions

View file

@ -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<Long> tbds = db.message().getMessagesBefore(folder.id, keep_time, false);
List<Long> 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);
}

View file

@ -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));
}

View file

@ -175,6 +175,17 @@
app:layout_constraintTop_toBottomOf="@id/swUnseen"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDeleteUnseen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="false"
android:text="@string/title_advanced_delete_unseen"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swFlagged"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSyncKept"
android:layout_width="match_parent"
@ -183,7 +194,7 @@
android:checked="false"
android:text="@string/title_advanced_kept_removed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swFlagged"
app:layout_constraintTop_toBottomOf="@id/swDeleteUnseen"
app:switchPadding="12dp" />
<TextView

View file

@ -170,6 +170,7 @@
<string name="title_advanced_schedule">Schedule</string>
<string name="title_advanced_unseen">All unread messages</string>
<string name="title_advanced_flagged">All starred messages</string>
<string name="title_advanced_delete_unseen">Delete old unread messages</string>
<string name="title_advanced_kept_removed">Check if old messages were removed from the server</string>
<string name="title_advanced_sync_folders">Synchronize folder list</string>