From 0b041f9643f13cb279417f909a566f4478a72e3d Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Sun, 16 Oct 2022 13:08:37 +1300 Subject: [PATCH] Stop timer if notification is dismissed Closes #86 --- android/app/src/main/java/com/massive/TimerService.kt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/android/app/src/main/java/com/massive/TimerService.kt b/android/app/src/main/java/com/massive/TimerService.kt index 1258386..edd829b 100644 --- a/android/app/src/main/java/com/massive/TimerService.kt +++ b/android/app/src/main/java/com/massive/TimerService.kt @@ -73,14 +73,6 @@ class TimerService : Service() { finishIntent, PendingIntent.FLAG_IMMUTABLE ) - val stopIntent = Intent(applicationContext, StopTimer::class.java) - val pendingStop = - PendingIntent.getService( - applicationContext, - 0, - stopIntent, - PendingIntent.FLAG_IMMUTABLE - ) builder.setContentText("Timer finished.") .setProgress(0, 0, false) .setAutoCancel(true) @@ -89,7 +81,6 @@ class TimerService : Service() { .setFullScreenIntent(finishPending, true) .setChannelId(CHANNEL_ID_DONE) .setCategory(NotificationCompat.CATEGORY_ALARM) - .setDeleteIntent(pendingStop) .priority = NotificationCompat.PRIORITY_HIGH val manager = getManager() manager.notify(NOTIFICATION_ID_DONE, builder.build()) @@ -141,6 +132,7 @@ class TimerService : Service() { .setContentIntent(pendingContent) .addAction(R.drawable.ic_baseline_stop_24, "Stop", pendingStop) .addAction(R.drawable.ic_baseline_stop_24, "Add 1 min", pendingAdd) + .setDeleteIntent(pendingStop) } @RequiresApi(Build.VERSION_CODES.O)