From ca727b254e4746ddf6abd72410058932f5ddf320 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 28 Jan 2023 11:04:40 +0100 Subject: [PATCH] Added option to disable trashing sent messages / conversation --- .../java/eu/faircode/email/FragmentMessages.java | 8 ++++++-- .../java/eu/faircode/email/FragmentOptions.java | 2 +- .../faircode/email/FragmentOptionsBehavior.java | 15 +++++++++++++-- .../main/res/layout/fragment_options_behavior.xml | 11 +++++++++++ app/src/main/res/values/strings.xml | 1 + 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 39c67d16cc..85666af7cd 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -351,6 +351,7 @@ public class FragmentMessages extends FragmentBase private boolean threading; private boolean swipenav; private boolean seekbar; + private boolean thread_sent_trash; private boolean actionbar; private int actionbar_delete_id; private int actionbar_archive_id; @@ -498,6 +499,7 @@ public class FragmentMessages extends FragmentBase args.getBoolean("force_threading")); swipenav = prefs.getBoolean("swipenav", true); seekbar = prefs.getBoolean("seekbar", false); + thread_sent_trash = prefs.getBoolean("thread_sent_trash", true); actionbar = prefs.getBoolean("actionbar", true); boolean actionbar_swap = prefs.getBoolean("actionbar_swap", false); actionbar_delete_id = (actionbar_swap ? R.id.action_archive : R.id.action_delete); @@ -1385,7 +1387,7 @@ public class FragmentMessages extends FragmentBase !targetFolder.id.equals(threaded.folder) && (!filter_archive || !EntityFolder.ARCHIVE.equals(sourceFolder.type)) && !EntityFolder.DRAFTS.equals(sourceFolder.type) && !EntityFolder.OUTBOX.equals(sourceFolder.type) && - (!EntityFolder.SENT.equals(sourceFolder.type) || EntityFolder.TRASH.equals(targetFolder.type)) && + (!EntityFolder.SENT.equals(sourceFolder.type) || !EntityFolder.TRASH.equals(targetFolder.type) || thread_sent_trash) && !EntityFolder.TRASH.equals(sourceFolder.type) && !EntityFolder.JUNK.equals(sourceFolder.type)) result.add(new MessageTarget(context, threaded, account, sourceFolder, account, targetFolder)); } @@ -6887,6 +6889,7 @@ public class FragmentMessages extends FragmentBase args.putLong("account", account); args.putString("thread", thread); args.putLong("id", id); + args.putBoolean("thread_sent_trash", thread_sent_trash); args.putBoolean("filter_archive", filter_archive); new SimpleTask() { @@ -6895,6 +6898,7 @@ public class FragmentMessages extends FragmentBase long aid = args.getLong("account"); String thread = args.getString("thread"); long id = args.getLong("id"); + boolean thread_sent_trash = args.getBoolean("thread_sent_trash"); boolean filter_archive = args.getBoolean("filter_archive"); EntityAccount account; @@ -6931,7 +6935,7 @@ public class FragmentMessages extends FragmentBase if (!folder.read_only && !EntityFolder.DRAFTS.equals(folder.type) && !EntityFolder.OUTBOX.equals(folder.type) && - // allow sent + (!EntityFolder.SENT.equals(folder.type) || thread_sent_trash) && !EntityFolder.TRASH.equals(folder.type) && !EntityFolder.JUNK.equals(folder.type)) trashable = true; diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index 959ec1e4fa..4aa0311ede 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -151,7 +151,7 @@ public class FragmentOptions extends FragmentBase { "collapse_quotes", "image_placeholders", "inline_images", "seekbar", "actionbar", "actionbar_swap", "actionbar_color", "group_category", "autoscroll", "swipenav", "reversed", "swipe_close", "swipe_move", "autoexpand", "autoclose", "onclose", - "swipe_reply", + "thread_sent_trash", "swipe_reply", "language_detection", "quick_filter", "quick_scroll", "quick_actions", "experiments", "debug", "log_level", "test1", "test2", "test3", "test4", "test5", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java index 2dd4f506a4..79eb5a3c5e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java @@ -102,6 +102,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe private SwitchCompat swAutoRead; private SwitchCompat swAutoUnflag; private SwitchCompat swResetImportance; + private SwitchCompat swThreadSentTrash; private SwitchCompat swFlagSnoozed; private SwitchCompat swAutoImportant; private SwitchCompat swResetSnooze; @@ -123,8 +124,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe "autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple", "autoclose", "onclose", "autoclose_unseen", "autoclose_send", "collapse_marked", "undo_timeout", - "autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance", "reset_snooze", "auto_block_sender", - "swipe_reply", "default_folder" + "autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance", "thread_sent_trash", + "reset_snooze", "auto_block_sender", "swipe_reply", "default_folder" }; @Override @@ -177,6 +178,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe swAutoRead = view.findViewById(R.id.swAutoRead); swAutoUnflag = view.findViewById(R.id.swAutoUnflag); swResetImportance = view.findViewById(R.id.swResetImportance); + swThreadSentTrash = view.findViewById(R.id.swThreadSentTrash); swFlagSnoozed = view.findViewById(R.id.swFlagSnoozed); swAutoImportant = view.findViewById(R.id.swAutoImportant); swResetSnooze = view.findViewById(R.id.swResetSnooze); @@ -514,6 +516,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe } }); + swThreadSentTrash.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("thread_sent_trash", checked).apply(); + } + }); + swFlagSnoozed.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -690,6 +699,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe swAutoRead.setChecked(prefs.getBoolean("autoread", false)); swAutoUnflag.setChecked(prefs.getBoolean("autounflag", false)); swResetImportance.setChecked(prefs.getBoolean("reset_importance", false)); + swThreadSentTrash.setChecked(prefs.getBoolean("thread_sent_trash", true)); + swFlagSnoozed.setChecked(prefs.getBoolean("flag_snoozed", false)); swAutoImportant.setChecked(prefs.getBoolean("auto_important", false)); swResetSnooze.setChecked(prefs.getBoolean("reset_snooze", true)); diff --git a/app/src/main/res/layout/fragment_options_behavior.xml b/app/src/main/res/layout/fragment_options_behavior.xml index a9a5910487..c786b426a3 100644 --- a/app/src/main/res/layout/fragment_options_behavior.xml +++ b/app/src/main/res/layout/fragment_options_behavior.xml @@ -701,6 +701,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swAutoUnflag" app:switchPadding="12dp" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5416e999af..2dba771de7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -652,6 +652,7 @@ Automatically mark messages read on moving messages Automatically remove stars from messages on moving messages Reset importance on moving messages + When trashing a conversation, also trash sent messages Automatically add star on snoozing messages Automatically make starred messages important Cancel snooze on moving messages