Allow swiping summary notification away

This commit is contained in:
M66B 2018-10-17 06:20:24 +00:00
parent 4b457dadad
commit 0d147e1b35
2 changed files with 23 additions and 5 deletions

View File

@ -211,6 +211,11 @@ public interface DaoMessage {
@Query("UPDATE message SET headers = :headers WHERE id = :id")
int setMessageHeaders(long id, String headers);
@Query("UPDATE message SET ui_ignored = 1" +
" WHERE NOT ui_ignored" +
" AND folder IN (SELECT id FROM folder WHERE type = '" + EntityFolder.INBOX + "')")
int ignoreAll();
@Query("DELETE FROM message WHERE id = :id")
int deleteMessage(long id);

View File

@ -136,9 +136,10 @@ public class ServiceSynchronize extends LifecycleService {
private static final int ATTACHMENT_AUTO_DOWNLOAD_SIZE = 32 * 1024; // bytes
private static final long RECONNECT_BACKOFF = 90 * 1000L; // milliseconds
static final int PI_SEEN = 1;
static final int PI_TRASH = 2;
static final int PI_IGNORED = 3;
static final int PI_CLEAR = 1;
static final int PI_SEEN = 2;
static final int PI_TRASH = 3;
static final int PI_IGNORED = 4;
static final String ACTION_SYNCHRONIZE_FOLDER = BuildConfig.APPLICATION_ID + ".SYNCHRONIZE_FOLDER";
static final String ACTION_PROCESS_OPERATIONS = BuildConfig.APPLICATION_ID + ".PROCESS_OPERATIONS";
@ -238,7 +239,15 @@ public class ServiceSynchronize extends LifecycleService {
serviceManager.queue_stop();
else if ("reload".equals(action))
serviceManager.queue_reload();
else if (action.startsWith("seen:") || action.startsWith("trash:") || action.startsWith("ignored:")) {
else if ("clear".equals(action)) {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) throws Throwable {
DB.getInstance(context).message().ignoreAll();
return null;
}
}.load(this, new Bundle());
} else if (action.startsWith("seen:") || action.startsWith("trash:") || action.startsWith("ignored:")) {
Bundle args = new Bundle();
args.putLong("id", Long.parseLong(action.split(":")[1]));
args.putString("action", action.split(":")[0]);
@ -341,6 +350,10 @@ public class ServiceSynchronize extends LifecycleService {
PendingIntent piView = PendingIntent.getActivity(
this, ActivityView.REQUEST_UNIFIED, view, PendingIntent.FLAG_UPDATE_CURRENT);
Intent clear = new Intent(this, ServiceSynchronize.class);
clear.setAction("clear");
PendingIntent piClear = PendingIntent.getService(this, PI_CLEAR, clear, PendingIntent.FLAG_UPDATE_CURRENT);
// Build notification
Notification.Builder builder;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
@ -355,7 +368,7 @@ public class ServiceSynchronize extends LifecycleService {
.setContentIntent(piView)
.setNumber(messages.size())
.setShowWhen(false)
.setOngoing(true)
.setDeleteIntent(piClear)
.setPriority(Notification.PRIORITY_DEFAULT)
.setCategory(Notification.CATEGORY_STATUS)
.setVisibility(Notification.VISIBILITY_PRIVATE)