Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit a0974130 authored by Marten Gajda's avatar Marten Gajda Committed by GitHub
Browse files

Update notifications, implements #400 (#809)

When a task is modified we compare the current notification state to the new one and update the notification if necessary.

In certain cases we remove the notification now:

* the task was unpinned (by the sync adapter)
* the start of a task has been postponed
* the due date of a task has been postponed
* a task has been completed
parent eee9b4c1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
def jems_version = '1.22'
def jems_version = '1.23'
def contentpal_version = '0.5'
def androidx_test_runner_version = '1.1.1'

+1 −1
Original line number Diff line number Diff line
@@ -460,7 +460,7 @@ public final class TaskContract
     *
     * @author Marten Gajda <marten@dmfs.org>
     */
    public interface TaskColumns
    public interface TaskColumns extends BaseColumns
    {

        /**
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ import org.dmfs.tasks.model.ContentSet;
import org.dmfs.tasks.utils.BaseActivity;
import org.dmfs.tasks.utils.ExpandableGroupDescriptor;
import org.dmfs.tasks.utils.SearchHistoryHelper;
import org.dmfs.tasks.utils.Unchecked;
import org.dmfs.jems.single.adapters.Unchecked;
import org.dmfs.tasks.utils.colors.DarkenedForStatusBar;


+6 −2
Original line number Diff line number Diff line
@@ -23,10 +23,10 @@ import android.net.Uri;
import android.os.RemoteException;

import org.dmfs.android.contentpal.RowDataSnapshot;
import org.dmfs.opentaskspal.readdata.TaskPin;
import org.dmfs.opentaskspal.readdata.TaskVersion;
import org.dmfs.tasks.actions.utils.NotificationPrefs;
import org.dmfs.tasks.contract.TaskContract;
import org.dmfs.tasks.notification.state.RowStateInfo;
import org.json.JSONException;
import org.json.JSONObject;

@@ -43,13 +43,17 @@ public final class PersistNotificationAction implements TaskAction
    {
        try
        {
            RowStateInfo rsi = new RowStateInfo(data);
            new NotificationPrefs(context).next()
                    .edit()
                    .putString(
                            taskUri.toString(),
                            new JSONObject()
                                    .put("version", new TaskVersion(data).value())
                                    .put("ongoing", new TaskPin(data).value()).toString())
                                    .put("started", rsi.started())
                                    .put("due", rsi.due())
                                    .put("done", rsi.done())
                                    .put("ongoing", rsi.pinned()).toString())
                    .apply();
        }
        catch (JSONException e)
+2 −3
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ public final class ActionService extends JobIntentService
            for (RowSnapshot<TaskContract.Tasks> snapshot : new QueryRowSet<>(
                    new TasksView(taskUri.getAuthority(), contentProviderClient),
                    new org.dmfs.android.contentpal.projections.Composite<>(
                            (Projection<TaskContract.Tasks>) Id.PROJECTION,
                            Id.PROJECTION,
                            EffectiveDueDate.PROJECTION,
                            TaskStart.PROJECTION,
                            TaskPin.PROJECTION,
@@ -148,8 +148,7 @@ public final class ActionService extends JobIntentService
                        // create undo notification
                        new PostUndoAction(),
                        // create delayed action to finish the completion
                        new DelayedAction(ACTION_FINISH_COMPLETE, UNDO_TIMEOUT_MILLIS)
                );
                        new DelayedAction(ACTION_FINISH_COMPLETE, UNDO_TIMEOUT_MILLIS));

            case ACTION_PIN_TASK:
                // just pin, let TaskNotificationService do the rest
Loading