Cancel notifiation on action

This commit is contained in:
M66B
2019-05-21 15:55:10 +02:00
parent bc42de39ed
commit 008520bbbf
2 changed files with 31 additions and 4 deletions

View File

@@ -20,6 +20,8 @@ package eu.faircode.email;
*/
import android.app.IntentService;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -78,21 +80,31 @@ public class ServiceUI extends IntentService {
case "clear":
onClear();
break;
case "trash":
cancel(intent.getStringExtra("group"), id);
onTrash(id);
break;
case "archive":
cancel(intent.getStringExtra("group"), id);
onArchive(id);
break;
case "flag":
cancel(intent.getStringExtra("group"), id);
onFlag(id);
break;
case "seen":
cancel(intent.getStringExtra("group"), id);
onSeen(id);
break;
case "ignore":
onIgnore(id);
break;
case "snooze":
// AlarmManager.RTC_WAKEUP
// When the alarm is dispatched, the app will also be added to the system's temporary whitelist
@@ -109,6 +121,13 @@ public class ServiceUI extends IntentService {
DB.getInstance(this).message().ignoreAll();
}
private void cancel(String group, long id) {
String tag = "unseen." + group + ":" + id;
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(tag, 1);
}
private void onTrash(long id) {
DB db = DB.getInstance(this);
try {