diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 484f2e470b..29bb347728 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -5012,6 +5012,26 @@ class Core { wactions.add(actionTrash.build()); } + if (notify_trash && + message.accountProtocol == EntityAccount.TYPE_POP && + message.accountLeaveDeleted) { + Intent delete = new Intent(context, ServiceUI.class) + .setAction("delete:" + message.id) + .putExtra("group", group); + PendingIntent piDelete = PendingIntentCompat.getService( + 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), + piDelete) + .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_DELETE) + .setShowsUserInterface(false) + .setAllowGeneratedReplies(false); + mbuilder.addAction(actionDelete.build()); + + wactions.add(actionDelete.build()); + } + if (notify_junk && message.accountProtocol == EntityAccount.TYPE_IMAP && db.folder().getFolderByType(message.account, EntityFolder.JUNK) != null) { diff --git a/app/src/main/java/eu/faircode/email/ServiceUI.java b/app/src/main/java/eu/faircode/email/ServiceUI.java index 1ce517367f..4316d1acd3 100644 --- a/app/src/main/java/eu/faircode/email/ServiceUI.java +++ b/app/src/main/java/eu/faircode/email/ServiceUI.java @@ -57,6 +57,7 @@ public class ServiceUI extends IntentService { static final int PI_HIDE = 9; static final int PI_SNOOZE = 10; static final int PI_IGNORED = 11; + static final int PI_DELETE = 12; public ServiceUI() { this(ServiceUI.class.getName()); @@ -108,6 +109,11 @@ public class ServiceUI extends IntentService { onMove(id, EntityFolder.TRASH); break; + case "delete": + cancel(group, id); + onDelete(id); + break; + case "junk": cancel(group, id); onJunk(id); @@ -249,6 +255,23 @@ public class ServiceUI extends IntentService { } } + private void onDelete(long id) { + DB db = DB.getInstance(this); + try { + db.beginTransaction(); + + EntityMessage message = db.message().getMessage(id); + if (message == null) + return; + + EntityOperation.queue(this, message, EntityOperation.DELETE); + + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + } + private void onJunk(long id) throws JSONException { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean block_sender = prefs.getBoolean("notify_block_sender", false); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ee891b78e9..0c790c2747 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -564,6 +564,7 @@ Transliterate Notification actions Trash + Delete Spam Archive Move