Added option to disable swiping all messages to trash

This commit is contained in:
M66B 2024-04-29 18:56:44 +02:00
parent 13ff382ba4
commit 563f2a1951
4 changed files with 30 additions and 3 deletions

View File

@ -342,6 +342,7 @@ public class FragmentMessages extends FragmentBase
private boolean seekbar;
private boolean move_thread_all;
private boolean move_thread_sent;
private boolean swipe_trash_all;
private boolean actionbar;
private int actionbar_delete_id;
private int actionbar_archive_id;
@ -496,6 +497,7 @@ public class FragmentMessages extends FragmentBase
seekbar = prefs.getBoolean("seekbar", false);
move_thread_all = prefs.getBoolean("move_thread_all", false);
move_thread_sent = (move_thread_all || prefs.getBoolean("move_thread_sent", false));
swipe_trash_all = prefs.getBoolean("swipe_trash_all", 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);
@ -3657,6 +3659,7 @@ public class FragmentMessages extends FragmentBase
args.putBoolean("thread", viewType != AdapterMessage.ViewType.THREAD);
args.putLong("target", target);
args.putBoolean("filter_archive", filter_archive);
args.putBoolean("swipe_trash_all", swipe_trash_all);
new SimpleTask<ArrayList<MessageTarget>>() {
@Override
@ -3665,6 +3668,7 @@ public class FragmentMessages extends FragmentBase
boolean thread = args.getBoolean("thread");
long tid = args.getLong("target");
boolean filter_archive = args.getBoolean("filter_archive");
boolean swipe_trash_all = args.getBoolean("swipe_trash_all");
ArrayList<MessageTarget> result = new ArrayList<>();
@ -3695,7 +3699,8 @@ public class FragmentMessages extends FragmentBase
List<EntityMessage> messages = db.message().getMessagesByThread(
message.account, message.thread,
threading && thread ? null : id,
!EntityFolder.DRAFTS.equals(baseFolder.type) &&
swipe_trash_all &&
!EntityFolder.DRAFTS.equals(baseFolder.type) &&
EntityFolder.TRASH.equals(targetFolder.type) ? null : message.folder);
for (EntityMessage threaded : messages) {
EntityFolder sourceFolder = db.folder().getFolder(threaded.folder);

View File

@ -108,6 +108,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swSwipeReply;
private SwitchCompat swMoveThreadAll;
private SwitchCompat swMoveThreadSent;
private SwitchCompat swSwipeTrashAll;
private Button btnDefaultFolder;
private TextView tvDefaultFolder;
@ -129,7 +130,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
"undo_timeout",
"autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance",
"reset_snooze", "auto_block_sender", "auto_hide_answer", "swipe_reply",
"move_thread_all", "move_thread_sent",
"move_thread_all", "move_thread_sent", "swipe_trash_all",
"default_folder"
));
@ -194,6 +195,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swSwipeReply = view.findViewById(R.id.swSwipeReply);
swMoveThreadAll = view.findViewById(R.id.swMoveThreadAll);
swMoveThreadSent = view.findViewById(R.id.swMoveThreadSent);
swSwipeTrashAll = view.findViewById(R.id.swSwipeTrashAll);
btnDefaultFolder = view.findViewById(R.id.btnDefaultFolder);
tvDefaultFolder = view.findViewById(R.id.tvDefaultFolder);
@ -613,6 +615,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
swSwipeTrashAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("swipe_trash_all", checked).apply();
}
});
Intent tree = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
Helper.openAdvanced(getContext(), tree);
PackageManager pm = getContext().getPackageManager();
@ -787,6 +796,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swMoveThreadAll.setChecked(prefs.getBoolean("move_thread_all", false));
swMoveThreadSent.setChecked(prefs.getBoolean("move_thread_sent", false));
swMoveThreadSent.setEnabled(!swMoveThreadAll.isChecked());
swSwipeTrashAll.setChecked(prefs.getBoolean("swipe_trash_all", true));
tvDefaultFolder.setText(prefs.getString("default_folder", null));
} catch (Throwable ex) {

View File

@ -890,6 +890,17 @@
app:layout_constraintTop_toBottomOf="@id/swMoveThreadAll"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSwipeTrashAll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_swipe_trash_all"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swMoveThreadSent"
app:switchPadding="12dp" />
<Button
android:id="@+id/btnDefaultFolder"
style="?android:attr/buttonStyleSmall"
@ -901,7 +912,7 @@
android:tag="disable"
android:text="@string/title_advanced_default_folder"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swMoveThreadSent" />
app:layout_constraintTop_toBottomOf="@id/swSwipeTrashAll" />
<TextView
android:id="@+id/tvDefaultFolderHint"

View File

@ -733,6 +733,7 @@
<string name="title_advanced_swipe_reply">Swipe expanded messages to the right to reply</string>
<string name="title_advanced_move_thread_all">When moving selected conversations, move all messages</string>
<string name="title_advanced_move_thread_sent">When moving a conversation, also move sent messages</string>
<string name="title_advanced_swipe_trash_all">When swiping a conversation to the trash, trash all messages</string>
<string name="title_advanced_default_snooze">Default snooze/delay time</string>
<string name="title_advanced_default_folder">Select default folder</string>