mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-04 06:20:26 +00:00
Enable notification/delete when leave on server is enabled
This commit is contained in:
parent
10d957e7a9
commit
50b19ce0b0
3 changed files with 44 additions and 0 deletions
|
@ -5012,6 +5012,26 @@ class Core {
|
||||||
wactions.add(actionTrash.build());
|
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 &&
|
if (notify_junk &&
|
||||||
message.accountProtocol == EntityAccount.TYPE_IMAP &&
|
message.accountProtocol == EntityAccount.TYPE_IMAP &&
|
||||||
db.folder().getFolderByType(message.account, EntityFolder.JUNK) != null) {
|
db.folder().getFolderByType(message.account, EntityFolder.JUNK) != null) {
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class ServiceUI extends IntentService {
|
||||||
static final int PI_HIDE = 9;
|
static final int PI_HIDE = 9;
|
||||||
static final int PI_SNOOZE = 10;
|
static final int PI_SNOOZE = 10;
|
||||||
static final int PI_IGNORED = 11;
|
static final int PI_IGNORED = 11;
|
||||||
|
static final int PI_DELETE = 12;
|
||||||
|
|
||||||
public ServiceUI() {
|
public ServiceUI() {
|
||||||
this(ServiceUI.class.getName());
|
this(ServiceUI.class.getName());
|
||||||
|
@ -108,6 +109,11 @@ public class ServiceUI extends IntentService {
|
||||||
onMove(id, EntityFolder.TRASH);
|
onMove(id, EntityFolder.TRASH);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "delete":
|
||||||
|
cancel(group, id);
|
||||||
|
onDelete(id);
|
||||||
|
break;
|
||||||
|
|
||||||
case "junk":
|
case "junk":
|
||||||
cancel(group, id);
|
cancel(group, id);
|
||||||
onJunk(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 {
|
private void onJunk(long id) throws JSONException {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
boolean block_sender = prefs.getBoolean("notify_block_sender", false);
|
boolean block_sender = prefs.getBoolean("notify_block_sender", false);
|
||||||
|
|
|
@ -564,6 +564,7 @@
|
||||||
<string name="title_advanced_notify_transliterate" translatable="false">Transliterate</string>
|
<string name="title_advanced_notify_transliterate" translatable="false">Transliterate</string>
|
||||||
<string name="title_advanced_notify_actions">Notification actions</string>
|
<string name="title_advanced_notify_actions">Notification actions</string>
|
||||||
<string name="title_advanced_notify_action_trash">Trash</string>
|
<string name="title_advanced_notify_action_trash">Trash</string>
|
||||||
|
<string name="title_advanced_notify_action_delete">Delete</string>
|
||||||
<string name="title_advanced_notify_action_junk">Spam</string>
|
<string name="title_advanced_notify_action_junk">Spam</string>
|
||||||
<string name="title_advanced_notify_action_archive">Archive</string>
|
<string name="title_advanced_notify_action_archive">Archive</string>
|
||||||
<string name="title_advanced_notify_action_move">Move</string>
|
<string name="title_advanced_notify_action_move">Move</string>
|
||||||
|
|
Loading…
Reference in a new issue