Added option to move complete thread

pull/213/head
M66B 2 years ago
parent 9fc6183e3b
commit d7fe9dbbbe

@ -720,6 +720,11 @@ public class ApplicationEx extends Application
if (!prefs.contains("filter_" + type + "_" + name)) if (!prefs.contains("filter_" + type + "_" + name))
editor.putBoolean("filter_" + type + "_" + name, prefs.getBoolean("filter_" + name, false)); editor.putBoolean("filter_" + type + "_" + name, prefs.getBoolean("filter_" + name, false));
} }
} else if (version < 2084) {
boolean thread_sent_trash = prefs.getBoolean("thread_sent_trash", false);
if (thread_sent_trash)
editor.putBoolean("move_thread_sent", true);
editor.remove("thread_sent_trash");
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG)

@ -336,7 +336,8 @@ public class FragmentMessages extends FragmentBase
private boolean threading; private boolean threading;
private boolean swipenav; private boolean swipenav;
private boolean seekbar; private boolean seekbar;
private boolean thread_sent_trash; private boolean move_thread_all;
private boolean move_thread_sent;
private boolean actionbar; private boolean actionbar;
private int actionbar_delete_id; private int actionbar_delete_id;
private int actionbar_archive_id; private int actionbar_archive_id;
@ -488,8 +489,8 @@ public class FragmentMessages extends FragmentBase
args.getBoolean("force_threading")); args.getBoolean("force_threading"));
swipenav = prefs.getBoolean("swipenav", true); swipenav = prefs.getBoolean("swipenav", true);
seekbar = prefs.getBoolean("seekbar", false); seekbar = prefs.getBoolean("seekbar", false);
thread_sent_trash = (prefs.getBoolean("thread_sent_trash", true) || move_thread_all = prefs.getBoolean("move_thread_all", false);
EntityFolder.SENT.equals(type)); move_thread_sent = (move_thread_all || prefs.getBoolean("move_thread_sent", false));
actionbar = prefs.getBoolean("actionbar", true); actionbar = prefs.getBoolean("actionbar", true);
boolean actionbar_swap = prefs.getBoolean("actionbar_swap", false); boolean actionbar_swap = prefs.getBoolean("actionbar_swap", false);
actionbar_delete_id = (actionbar_swap ? R.id.action_archive : R.id.action_delete); actionbar_delete_id = (actionbar_swap ? R.id.action_archive : R.id.action_delete);
@ -1378,7 +1379,7 @@ public class FragmentMessages extends FragmentBase
args.putString("thread", thread); args.putString("thread", thread);
args.putLong("id", id); args.putLong("id", id);
args.putString("type", folderType); args.putString("type", folderType);
args.putBoolean("thread_sent_trash", thread_sent_trash); args.putBoolean("move_thread_sent", move_thread_sent);
args.putBoolean("filter_archive", filter_archive); args.putBoolean("filter_archive", filter_archive);
new SimpleTask<ArrayList<MessageTarget>>() { new SimpleTask<ArrayList<MessageTarget>>() {
@ -1388,7 +1389,7 @@ public class FragmentMessages extends FragmentBase
String thread = args.getString("thread"); String thread = args.getString("thread");
long id = args.getLong("id"); long id = args.getLong("id");
String type = args.getString("type"); String type = args.getString("type");
boolean thread_sent_trash = args.getBoolean("thread_sent_trash"); boolean move_thread_sent = args.getBoolean("move_thread_sent");
boolean filter_archive = args.getBoolean("filter_archive"); boolean filter_archive = args.getBoolean("filter_archive");
ArrayList<MessageTarget> result = new ArrayList<>(); ArrayList<MessageTarget> result = new ArrayList<>();
@ -1415,7 +1416,7 @@ public class FragmentMessages extends FragmentBase
!EntityFolder.DRAFTS.equals(sourceFolder.type) && !EntityFolder.OUTBOX.equals(sourceFolder.type) && !EntityFolder.DRAFTS.equals(sourceFolder.type) && !EntityFolder.OUTBOX.equals(sourceFolder.type) &&
!(EntityFolder.SENT.equals(sourceFolder.type) && EntityFolder.ARCHIVE.equals(targetFolder.type)) && !(EntityFolder.SENT.equals(sourceFolder.type) && EntityFolder.ARCHIVE.equals(targetFolder.type)) &&
!(EntityFolder.SENT.equals(sourceFolder.type) && EntityFolder.JUNK.equals(targetFolder.type)) && !(EntityFolder.SENT.equals(sourceFolder.type) && EntityFolder.JUNK.equals(targetFolder.type)) &&
(!EntityFolder.SENT.equals(sourceFolder.type) || !EntityFolder.TRASH.equals(targetFolder.type) || thread_sent_trash) && (!EntityFolder.SENT.equals(sourceFolder.type) || !EntityFolder.TRASH.equals(targetFolder.type) || move_thread_sent) &&
!EntityFolder.TRASH.equals(sourceFolder.type) && !EntityFolder.JUNK.equals(sourceFolder.type)) !EntityFolder.TRASH.equals(sourceFolder.type) && !EntityFolder.JUNK.equals(sourceFolder.type))
result.add(new MessageTarget(context, threaded, account, sourceFolder, account, targetFolder)); result.add(new MessageTarget(context, threaded, account, sourceFolder, account, targetFolder));
} }
@ -2139,6 +2140,7 @@ public class FragmentMessages extends FragmentBase
args.putLong("account", account); args.putLong("account", account);
args.putString("thread", thread); args.putString("thread", thread);
args.putLong("id", id); args.putLong("id", id);
args.putBoolean("move_thread_sent", move_thread_sent);
args.putBoolean("filter_archive", filter_archive); args.putBoolean("filter_archive", filter_archive);
args.putLongArray("disabled", new long[]{folder}); args.putLongArray("disabled", new long[]{folder});
@ -4543,7 +4545,8 @@ public class FragmentMessages extends FragmentBase
args.putString("type", type); args.putString("type", type);
args.putBoolean("block", block); args.putBoolean("block", block);
args.putLongArray("ids", getSelection()); args.putLongArray("ids", getSelection());
args.putBoolean("thread_sent_trash", thread_sent_trash); args.putBoolean("move_thread_all", move_thread_all);
args.putBoolean("move_thread_sent", move_thread_sent);
args.putBoolean("filter_archive", filter_archive); args.putBoolean("filter_archive", filter_archive);
new SimpleTask<ArrayList<MessageTarget>>() { new SimpleTask<ArrayList<MessageTarget>>() {
@ -4552,7 +4555,8 @@ public class FragmentMessages extends FragmentBase
String type = args.getString("type"); String type = args.getString("type");
boolean block = args.getBoolean("block"); boolean block = args.getBoolean("block");
long[] ids = args.getLongArray("ids"); long[] ids = args.getLongArray("ids");
boolean thread_sent_trash = args.getBoolean("thread_sent_trash"); boolean move_thread_all = args.getBoolean("move_thread_all");
boolean move_thread_sent = args.getBoolean("move_thread_sent");
boolean filter_archive = args.getBoolean("filter_archive"); boolean filter_archive = args.getBoolean("filter_archive");
ArrayList<MessageTarget> result = new ArrayList<>(); ArrayList<MessageTarget> result = new ArrayList<>();
@ -4577,16 +4581,20 @@ public class FragmentMessages extends FragmentBase
List<EntityMessage> messages = db.message().getMessagesByThread( List<EntityMessage> messages = db.message().getMessagesByThread(
message.account, message.thread, message.account, message.thread,
threading ? null : id, threading ? null : id,
EntityFolder.TRASH.equals(targetFolder.type) ? null : message.folder); move_thread_all || move_thread_sent ? null : message.folder);
for (EntityMessage threaded : messages) { for (EntityMessage threaded : messages) {
EntityFolder sourceFolder = db.folder().getFolder(threaded.folder); EntityFolder sourceFolder = db.folder().getFolder(threaded.folder);
if (sourceFolder == null || if (sourceFolder == null ||
sourceFolder.read_only || sourceFolder.read_only ||
sourceFolder.id.equals(targetFolder.id)) sourceFolder.id.equals(targetFolder.id))
continue; continue;
if (!threaded.folder.equals(message.folder) &&
!(move_thread_all ||
(move_thread_sent && EntityFolder.SENT.equals(sourceFolder.type))))
continue;
if (EntityFolder.TRASH.equals(targetFolder.type)) { if (EntityFolder.TRASH.equals(targetFolder.type)) {
if (EntityFolder.SENT.equals(sourceFolder.type) && !thread_sent_trash)
continue;
if (EntityFolder.ARCHIVE.equals(sourceFolder.type) && filter_archive) if (EntityFolder.ARCHIVE.equals(sourceFolder.type) && filter_archive)
continue; continue;
if (EntityFolder.JUNK.equals(sourceFolder.type) && !threaded.folder.equals(message.folder)) if (EntityFolder.JUNK.equals(sourceFolder.type) && !threaded.folder.equals(message.folder))
@ -4630,6 +4638,9 @@ public class FragmentMessages extends FragmentBase
args.putBoolean("cancopy", true); args.putBoolean("cancopy", true);
args.putLongArray("disabled", Helper.toLongArray(disabled)); args.putLongArray("disabled", Helper.toLongArray(disabled));
args.putLongArray("messages", getSelection()); args.putLongArray("messages", getSelection());
args.putBoolean("move_thread_all", move_thread_all);
args.putBoolean("move_thread_sent", move_thread_sent);
args.putBoolean("filter_archive", filter_archive);
FragmentDialogSelectFolder fragment = new FragmentDialogSelectFolder(); FragmentDialogSelectFolder fragment = new FragmentDialogSelectFolder();
fragment.setArguments(args); fragment.setArguments(args);
@ -4646,6 +4657,9 @@ public class FragmentMessages extends FragmentBase
long[] ids = args.getLongArray("ids"); long[] ids = args.getLongArray("ids");
long tid = args.getLong("folder"); long tid = args.getLong("folder");
boolean copy = args.getBoolean("copy"); boolean copy = args.getBoolean("copy");
boolean move_thread_all = args.getBoolean("move_thread_all");
boolean move_thread_sent = args.getBoolean("move_thread_sent");
boolean filter_archive = args.getBoolean("filter_archive");
ArrayList<MessageTarget> result = new ArrayList<>(); ArrayList<MessageTarget> result = new ArrayList<>();
@ -4671,7 +4685,8 @@ public class FragmentMessages extends FragmentBase
continue; continue;
List<EntityMessage> messages = db.message().getMessagesByThread( List<EntityMessage> messages = db.message().getMessagesByThread(
message.account, message.thread, threading ? null : id, message.folder); message.account, message.thread, threading ? null : id,
move_thread_all || move_thread_sent ? null : message.folder);
for (EntityMessage threaded : messages) { for (EntityMessage threaded : messages) {
EntityFolder sourceFolder = db.folder().getFolder(threaded.folder); EntityFolder sourceFolder = db.folder().getFolder(threaded.folder);
if (sourceFolder == null || if (sourceFolder == null ||
@ -4679,6 +4694,18 @@ public class FragmentMessages extends FragmentBase
sourceFolder.id.equals(targetFolder.id)) sourceFolder.id.equals(targetFolder.id))
continue; continue;
if (!threaded.folder.equals(message.folder) &&
!(move_thread_all ||
(move_thread_sent && EntityFolder.SENT.equals(sourceFolder.type))))
continue;
if (EntityFolder.TRASH.equals(targetFolder.type)) {
if (EntityFolder.ARCHIVE.equals(sourceFolder.type) && filter_archive)
continue;
if (EntityFolder.JUNK.equals(sourceFolder.type) && !threaded.folder.equals(message.folder))
continue;
}
result.add(new MessageTarget(context, threaded, sourceAccount, sourceFolder, targetAccount, targetFolder).setCopy(copy)); result.add(new MessageTarget(context, threaded, sourceAccount, sourceFolder, targetAccount, targetFolder).setCopy(copy));
} }
} }
@ -4715,12 +4742,10 @@ public class FragmentMessages extends FragmentBase
long aid = args.getLong("account"); long aid = args.getLong("account");
String thread = args.getString("thread"); String thread = args.getString("thread");
long id = args.getLong("id"); long id = args.getLong("id");
boolean move_thread_sent = args.getBoolean("move_thread_sent");
boolean filter_archive = args.getBoolean("filter_archive"); boolean filter_archive = args.getBoolean("filter_archive");
long tid = args.getLong("folder"); long tid = args.getLong("folder");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean move_thread_sent = prefs.getBoolean("move_thread_sent", false);
ArrayList<MessageTarget> result = new ArrayList<>(); ArrayList<MessageTarget> result = new ArrayList<>();
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
@ -7171,7 +7196,7 @@ public class FragmentMessages extends FragmentBase
args.putLong("account", account); args.putLong("account", account);
args.putString("thread", thread); args.putString("thread", thread);
args.putLong("id", id); args.putLong("id", id);
args.putBoolean("thread_sent_trash", thread_sent_trash); args.putBoolean("move_thread_sent", move_thread_sent);
args.putBoolean("filter_archive", filter_archive); args.putBoolean("filter_archive", filter_archive);
new SimpleTask<ActionData>() { new SimpleTask<ActionData>() {
@ -7180,7 +7205,7 @@ public class FragmentMessages extends FragmentBase
long aid = args.getLong("account"); long aid = args.getLong("account");
String thread = args.getString("thread"); String thread = args.getString("thread");
long id = args.getLong("id"); long id = args.getLong("id");
boolean thread_sent_trash = args.getBoolean("thread_sent_trash"); boolean move_thread_sent = args.getBoolean("move_thread_sent");
boolean filter_archive = args.getBoolean("filter_archive"); boolean filter_archive = args.getBoolean("filter_archive");
EntityAccount account; EntityAccount account;
@ -7217,7 +7242,7 @@ public class FragmentMessages extends FragmentBase
if (!folder.read_only && if (!folder.read_only &&
!EntityFolder.DRAFTS.equals(folder.type) && !EntityFolder.DRAFTS.equals(folder.type) &&
!EntityFolder.OUTBOX.equals(folder.type) && !EntityFolder.OUTBOX.equals(folder.type) &&
(!EntityFolder.SENT.equals(folder.type) || thread_sent_trash) && (!EntityFolder.SENT.equals(folder.type) || move_thread_sent) &&
!EntityFolder.TRASH.equals(folder.type) && !EntityFolder.TRASH.equals(folder.type) &&
!EntityFolder.JUNK.equals(folder.type)) !EntityFolder.JUNK.equals(folder.type))
trashable = true; trashable = true;

@ -152,7 +152,8 @@ public class FragmentOptions extends FragmentBase {
"collapse_quotes", "image_placeholders", "inline_images", "collapse_quotes", "image_placeholders", "inline_images",
"seekbar", "actionbar", "actionbar_swap", "actionbar_color", "group_category", "seekbar", "actionbar", "actionbar_swap", "actionbar_color", "group_category",
"autoscroll", "swipenav", "reversed", "swipe_close", "swipe_move", "autoexpand", "autoclose", "onclose", "autoscroll", "swipenav", "reversed", "swipe_close", "swipe_move", "autoexpand", "autoclose", "onclose",
"thread_sent_trash", "auto_hide_answer", "swipe_reply", "auto_hide_answer", "swipe_reply",
"move_thread_all", "move_thread_sent",
"language_detection", "language_detection",
"quick_filter", "quick_scroll", "quick_actions", "quick_filter", "quick_scroll", "quick_actions",
"experiments", "debug", "log_level", "test1", "test2", "test3", "test4", "test5", "experiments", "debug", "log_level", "test1", "test2", "test3", "test4", "test5",

@ -100,8 +100,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swAutoBlockSender; private SwitchCompat swAutoBlockSender;
private SwitchCompat swAutoHideAnswer; private SwitchCompat swAutoHideAnswer;
private SwitchCompat swSwipeReply; private SwitchCompat swSwipeReply;
private SwitchCompat swMoveThreadAll;
private SwitchCompat swMoveThreadSent; private SwitchCompat swMoveThreadSent;
private SwitchCompat swThreadSentTrash;
private Button btnDefaultFolder; private Button btnDefaultFolder;
private TextView tvDefaultFolder; private TextView tvDefaultFolder;
@ -122,7 +122,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
"undo_timeout", "undo_timeout",
"autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance", "autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance",
"reset_snooze", "auto_block_sender", "auto_hide_answer", "swipe_reply", "reset_snooze", "auto_block_sender", "auto_hide_answer", "swipe_reply",
"move_thread_sent", "thread_sent_trash", "move_thread_all", "move_thread_sent",
"default_folder" "default_folder"
}; };
@ -183,8 +183,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoBlockSender = view.findViewById(R.id.swAutoBlockSender); swAutoBlockSender = view.findViewById(R.id.swAutoBlockSender);
swAutoHideAnswer = view.findViewById(R.id.swAutoHideAnswer); swAutoHideAnswer = view.findViewById(R.id.swAutoHideAnswer);
swSwipeReply = view.findViewById(R.id.swSwipeReply); swSwipeReply = view.findViewById(R.id.swSwipeReply);
swMoveThreadAll = view.findViewById(R.id.swMoveThreadAll);
swMoveThreadSent = view.findViewById(R.id.swMoveThreadSent); swMoveThreadSent = view.findViewById(R.id.swMoveThreadSent);
swThreadSentTrash = view.findViewById(R.id.swThreadSentTrash);
btnDefaultFolder = view.findViewById(R.id.btnDefaultFolder); btnDefaultFolder = view.findViewById(R.id.btnDefaultFolder);
tvDefaultFolder = view.findViewById(R.id.tvDefaultFolder); tvDefaultFolder = view.findViewById(R.id.tvDefaultFolder);
@ -569,17 +569,18 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
} }
}); });
swMoveThreadSent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swMoveThreadAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("move_thread_sent", checked).apply(); prefs.edit().putBoolean("move_thread_all", checked).apply();
swMoveThreadSent.setEnabled(!checked);
} }
}); });
swThreadSentTrash.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swMoveThreadSent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("thread_sent_trash", checked).apply(); prefs.edit().putBoolean("move_thread_sent", checked).apply();
} }
}); });
@ -734,8 +735,9 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoHideAnswer.setChecked(prefs.getBoolean("auto_hide_answer", !accessibility)); swAutoHideAnswer.setChecked(prefs.getBoolean("auto_hide_answer", !accessibility));
swSwipeReply.setChecked(prefs.getBoolean("swipe_reply", false)); swSwipeReply.setChecked(prefs.getBoolean("swipe_reply", false));
swMoveThreadAll.setChecked(prefs.getBoolean("move_thread_all", false));
swMoveThreadSent.setChecked(prefs.getBoolean("move_thread_sent", false)); swMoveThreadSent.setChecked(prefs.getBoolean("move_thread_sent", false));
swThreadSentTrash.setChecked(prefs.getBoolean("thread_sent_trash", true)); swMoveThreadSent.setEnabled(!swMoveThreadAll.isChecked());
tvDefaultFolder.setText(prefs.getString("default_folder", null)); tvDefaultFolder.setText(prefs.getString("default_folder", null));
} catch (Throwable ex) { } catch (Throwable ex) {

@ -834,25 +834,26 @@
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swMoveThreadSent" android:id="@+id/swMoveThreadAll"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_move_thread_sent" android:text="@string/title_advanced_move_thread_all"
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/swSwipeReply" app:layout_constraintTop_toBottomOf="@id/swSwipeReply"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swThreadSentTrash" android:id="@+id/swMoveThreadSent"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_thread_sent_trash" android:text="@string/title_advanced_move_thread_sent"
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/swMoveThreadSent" app:layout_constraintTop_toBottomOf="@id/swMoveThreadAll"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<Button <Button
@ -866,7 +867,7 @@
android:tag="disable" android:tag="disable"
android:text="@string/title_advanced_default_folder" android:text="@string/title_advanced_default_folder"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swThreadSentTrash" /> app:layout_constraintTop_toBottomOf="@id/swMoveThreadSent" />
<TextView <TextView
android:id="@+id/tvDefaultFolderHint" android:id="@+id/tvDefaultFolderHint"

@ -686,8 +686,8 @@
<string name="title_advanced_auto_block_sender">Automatically block the sender when reporting spam</string> <string name="title_advanced_auto_block_sender">Automatically block the sender when reporting spam</string>
<string name="title_advanced_auto_hide_answer">Automatically hide the answer button when scrolling</string> <string name="title_advanced_auto_hide_answer">Automatically hide the answer button when scrolling</string>
<string name="title_advanced_swipe_reply">Swipe expanded messages to the right to reply</string> <string name="title_advanced_swipe_reply">Swipe expanded messages to the right to reply</string>
<string name="title_advanced_move_thread_all">When moving a conversation, move all messages</string>
<string name="title_advanced_move_thread_sent">When moving a conversation, also move sent messages</string> <string name="title_advanced_move_thread_sent">When moving a conversation, also move sent messages</string>
<string name="title_advanced_thread_sent_trash">When trashing a conversation, also trash sent messages</string>
<string name="title_advanced_default_snooze">Default snooze/delay time</string> <string name="title_advanced_default_snooze">Default snooze/delay time</string>
<string name="title_advanced_default_folder">Select default folder</string> <string name="title_advanced_default_folder">Select default folder</string>

Loading…
Cancel
Save