Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix permanent notification, fixes #800 #801

Merged
merged 1 commit into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions opentasks/src/main/java/org/dmfs/tasks/actions/NotifyAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import android.net.Uri;
import android.os.Build;
import android.os.RemoteException;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import android.text.format.DateUtils;

import org.dmfs.android.bolts.color.colors.ResourceColor;
Expand All @@ -52,6 +50,9 @@
import org.dmfs.tasks.notification.signals.Conditional;
import org.dmfs.tasks.utils.DateFormatter;

import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;


/**
* Post a notification.
Expand Down Expand Up @@ -128,6 +129,11 @@ public void execute(Context context, ContentProviderClient contentProviderClient
.setData(taskUri),
PendingIntent.FLAG_UPDATE_CURRENT));

// make sure we un-persist the notification when its cancelled
builder.setDeleteIntent(PendingIntent.getBroadcast(context, notificationId,
new Intent(context, ActionReceiver.class).setAction(ActionService.ACTION_REMOVE_NOTIFICATION).setData(taskUri),
PendingIntent.FLAG_UPDATE_CURRENT));

if (!new TaskIsClosed(data).value())
{
builder.addAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import android.content.OperationApplicationException;
import android.net.Uri;
import android.os.RemoteException;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import android.util.Log;

import org.dmfs.android.contentpal.Projection;
Expand Down Expand Up @@ -54,10 +52,14 @@
import org.dmfs.tasks.actions.OpenAction;
import org.dmfs.tasks.actions.PinAction;
import org.dmfs.tasks.actions.PostUndoAction;
import org.dmfs.tasks.actions.RemoveNotificationAction;
import org.dmfs.tasks.actions.TaskAction;
import org.dmfs.tasks.actions.WipeNotificationAction;
import org.dmfs.tasks.contract.TaskContract;

import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;


/**
* A {@link JobIntentService} which handles notification actions.
Expand All @@ -76,6 +78,7 @@ public final class ActionService extends JobIntentService
public static final String ACTION_UNPIN = "org.dmfs.tasks.intent.UNPIN";
public static final String ACTION_OPEN_TASK = "org.dmfs.tasks.intent.OPEN_TASK";
public static final String ACTION_OPEN_TASK_CANCEL_NOTIFICATION = "org.dmfs.tasks.intent.OPEN_CANCEL_TASK";
public static final String ACTION_REMOVE_NOTIFICATION = "org.dmfs.tasks.intent.CANCEL_NOTIFICATION";
public static final String ACTION_NEXT_DAY = "org.dmfs.tasks.intent.ACTION_DAY_CHANGED";
public static final String ACTION_RENOTIFY = "org.dmfs.tasks.intent.NOTIFY";
public static final String ACTION_DEFER_1D = "org.dmfs.tasks.action.notification.DELAY_1D";
Expand Down Expand Up @@ -164,6 +167,10 @@ private TaskAction resolveAction(String action)
// just open the task and cancel the notification
return new Composite(new OpenAction(), new WipeNotificationAction());

case ACTION_REMOVE_NOTIFICATION:
// remove the notification
return new RemoveNotificationAction();

case ACTION_DEFER_1D:
// defer the due date and remove notification if not pinned and due date is in the future
return new Composite(
Expand Down