Added option to permanently delete from notifications

This commit is contained in:
M66B
2024-02-26 19:48:58 +01:00
parent 334783cd3a
commit eecc43e89e
4 changed files with 44 additions and 9 deletions

View File

@@ -231,6 +231,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swAdjacentPortrait;
private SwitchCompat swAdjacentLandscape;
private SwitchCompat swDeleteConfirmation;
private SwitchCompat swDeleteNotification;
private SwitchCompat swDmarcViewer;
private EditText etKeywords;
private SwitchCompat swTestIab;
@@ -291,7 +292,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"webp", "animate_images",
"easy_correct", "paste_plain", "infra", "tld_flags", "json_ld", "dup_msgids", "thread_byref", "save_user_flags", "mdn",
"app_chooser", "app_chooser_share", "adjacent_links", "adjacent_documents", "adjacent_portrait", "adjacent_landscape",
"delete_confirmation", "global_keywords", "test_iab"
"delete_confirmation", "delete_notification", "global_keywords", "test_iab"
));
private final static String[] RESET_QUESTIONS = new String[]{
@@ -472,6 +473,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAdjacentPortrait = view.findViewById(R.id.swAdjacentPortrait);
swAdjacentLandscape = view.findViewById(R.id.swAdjacentLandscape);
swDeleteConfirmation = view.findViewById(R.id.swDeleteConfirmation);
swDeleteNotification = view.findViewById(R.id.swDeleteNotification);
swDmarcViewer = view.findViewById(R.id.swDmarcViewer);
etKeywords = view.findViewById(R.id.etKeywords);
swTestIab = view.findViewById(R.id.swTestIab);
@@ -1644,6 +1646,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swDeleteNotification.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("delete_notification", checked).apply();
}
});
swDmarcViewer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -2393,6 +2402,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAdjacentPortrait.setChecked(prefs.getBoolean("adjacent_portrait", false));
swAdjacentLandscape.setChecked(prefs.getBoolean("adjacent_landscape", false));
swDeleteConfirmation.setChecked(prefs.getBoolean("delete_confirmation", true));
swDeleteNotification.setChecked(prefs.getBoolean("delete_notification", false));
swDmarcViewer.setChecked(Helper.isComponentEnabled(getContext(), ActivityDMARC.class));
etKeywords.setText(prefs.getString("global_keywords", null));
swTestIab.setChecked(prefs.getBoolean("test_iab", false));

View File

@@ -703,8 +703,7 @@ class NotificationHelper {
String sound = prefs.getString("sound", null);
boolean alert_once = prefs.getBoolean("alert_once", true);
boolean perform_expunge = prefs.getBoolean("perform_expunge", true);
boolean delete_confirmation = prefs.getBoolean("delete_confirmation", true);
boolean delete_notification = prefs.getBoolean("delete_notification", false);
// Get contact info
Map<Long, Address[]> messageFrom = new HashMap<>();
@@ -1073,8 +1072,8 @@ class NotificationHelper {
List<NotificationCompat.Action> wactions = new ArrayList<>();
if (notify_trash &&
perform_expunge &&
message.accountProtocol == EntityAccount.TYPE_IMAP) {
!delete_notification &&
message.accountProtocol == EntityAccount.TYPE_IMAP && perform_expunge) {
EntityFolder folder = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
if (folder != null && !folder.id.equals(message.folder)) {
Intent trash = new Intent(context, ServiceUI.class)
@@ -1094,7 +1093,7 @@ class NotificationHelper {
wactions.add(actionTrash.build());
}
} else if (notify_trash &&
(!delete_confirmation ||
(delete_notification ||
(message.accountProtocol == EntityAccount.TYPE_POP && message.accountLeaveDeleted) ||
(message.accountProtocol == EntityAccount.TYPE_IMAP && !perform_expunge))) {
Intent delete = new Intent(context, ServiceUI.class)
@@ -1104,7 +1103,7 @@ class NotificationHelper {
context, ServiceUI.PI_DELETE, delete, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action.Builder actionDelete = new NotificationCompat.Action.Builder(
R.drawable.twotone_delete_forever_24,
context.getString(R.string.title_advanced_notify_action_delete),
context.getString(R.string.title_delete_permanently),
piDelete)
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_DELETE)
.setShowsUserInterface(false)