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

Commit ea75ede8 authored by tobias's avatar tobias
Browse files

- added start notification complete action undo

parent 470ff395
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -173,6 +173,7 @@
    <string name="notification_action_completed">erledigt</string>
    <string name="notification_action_delay_1h">+1 Stunde</string>
    <string name="notification_action_delay_1d">+1 Tag</string>
    <string name="notification_action_delay_toast">Fälligkeitsdatum aktualisiert</string>
    <string name="notification_undo">Rückgänging</string>

    <!-- Strings for time UI widgets -->
+1 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@
    <string name="notification_action_completed">Completed</string>
    <string name="notification_action_delay_1h">+1 hour</string>
    <string name="notification_action_delay_1d">+1 day</string>
    <string name="notification_action_delay_toast">Due date updated</string>
    <string name="notification_undo">Undo</string>
    
    
+13 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import java.util.ArrayList;

import org.dmfs.provider.tasks.TaskContract.Tasks;
import org.dmfs.provider.tasks.broadcast.DueAlarmBroadcastHandler;
import org.dmfs.provider.tasks.broadcast.StartAlarmBroadcastHandler;
import org.dmfs.tasks.R;
import org.dmfs.tasks.notification.NotificationActionUtils.NotificationAction;

@@ -120,6 +121,7 @@ public class NotificationActionIntentService extends IntentService
					time.normalize(true);
					delayTask(taskId, time.toMillis(true), tz);
				}

			}

		}
@@ -185,10 +187,17 @@ public class NotificationActionIntentService extends IntentService
	{
		if (ACTION_COMPLETE.equals(notificationAction.getActionType()))
		{
			Intent intent = new Intent(DueAlarmBroadcastHandler.BROADCAST_DUE_ALARM);
			// intent.setPackage(getApplicationContext().getPackageName());
			intent.putExtra(DueAlarmBroadcastHandler.EXTRA_TASK_DUE_TIME, notificationAction.getWhen());
			sendBroadcast(intent);
			// Due broadcast
			Intent dueIntent = new Intent(DueAlarmBroadcastHandler.BROADCAST_DUE_ALARM);
			dueIntent.setPackage(getApplicationContext().getPackageName());
			dueIntent.putExtra(DueAlarmBroadcastHandler.EXTRA_TASK_DUE_TIME, notificationAction.getWhen());
			sendBroadcast(dueIntent);

			// Start broadcast
			Intent startIntent = new Intent(StartAlarmBroadcastHandler.BROADCAST_START_ALARM);
			startIntent.setPackage(getApplicationContext().getPackageName());
			startIntent.putExtra(StartAlarmBroadcastHandler.EXTRA_TASK_START_TIME, notificationAction.getWhen());
			sendBroadcast(startIntent);
		}
	}

+5 −1
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ public class NotificationActionUtils
			NotificationActionUtils.getNotificationActionPendingIntent(context, completeAction)));
		mBuilder.setWhen(dueDate);
		mBuilder.setContentIntent(resultPendingIntent);

		notificationManager.notify(notificationId, mBuilder.build());
	}

@@ -153,7 +154,10 @@ public class NotificationActionUtils
		mBuilder.setWhen(startDate);

		// add actions
		mBuilder.addAction(NotificationActionIntentService.getCompleteAction(context, notificationId, taskId));
		NotificationAction completeAction = new NotificationAction(NotificationActionIntentService.ACTION_COMPLETE,
			context.getString(R.string.notification_action_completed), R.string.notification_action_completed, notificationId, taskId, startDate);
		mBuilder.addAction(NotificationActionIntentService.getCompleteAction(context,
			NotificationActionUtils.getNotificationActionPendingIntent(context, completeAction)));

		// Creates an explicit intent for an Activity in your app
		Intent resultIntent = new Intent(Intent.ACTION_VIEW);