diff --git a/app/src/main/java/org/tasks/notifications/NotificationClearedReceiver.kt b/app/src/main/java/org/tasks/notifications/NotificationClearedReceiver.kt
index e56ab0757..85539a6cd 100644
--- a/app/src/main/java/org/tasks/notifications/NotificationClearedReceiver.kt
+++ b/app/src/main/java/org/tasks/notifications/NotificationClearedReceiver.kt
@@ -3,10 +3,12 @@ package org.tasks.notifications
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
+import com.todoroo.astrid.alarms.AlarmService
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.tasks.injection.ApplicationScope
+import org.tasks.preferences.Preferences
import timber.log.Timber
import javax.inject.Inject
@@ -14,12 +16,23 @@ import javax.inject.Inject
class NotificationClearedReceiver : BroadcastReceiver() {
@Inject lateinit var notificationManager: NotificationManager
@Inject @ApplicationScope lateinit var scope: CoroutineScope
+ @Inject lateinit var preferences: Preferences
+ @Inject lateinit var alarmService: AlarmService
override fun onReceive(context: Context, intent: Intent) {
val notificationId = intent.getLongExtra(NotificationManager.EXTRA_NOTIFICATION_ID, -1L)
Timber.d("cleared $notificationId")
+ if (notificationId <= 0L) return
scope.launch {
- notificationManager.cancel(notificationId)
+ if (preferences.useSwipeToSnooze()) {
+ var snoozeTime = preferences.swipeToSnoozeIntervalMS()
+ // snoozing for 0ms will cause the alarm service to miss this notification
+ // so sleep for 1s instead
+ if (snoozeTime == 0L) snoozeTime = 1000L
+ alarmService.snooze(snoozeTime, listOf(notificationId))
+ } else {
+ notificationManager.cancel(notificationId)
+ }
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/org/tasks/preferences/Preferences.kt b/app/src/main/java/org/tasks/preferences/Preferences.kt
index 416855712..d62dd8cfe 100644
--- a/app/src/main/java/org/tasks/preferences/Preferences.kt
+++ b/app/src/main/java/org/tasks/preferences/Preferences.kt
@@ -468,7 +468,13 @@ class Preferences @JvmOverloads constructor(
fun bundleNotifications(): Boolean = getBoolean(R.string.p_bundle_notifications, true)
fun usePersistentReminders(): Boolean =
- AndroidUtilities.preUpsideDownCake() && getBoolean(R.string.p_rmd_persistent, true)
+ AndroidUtilities.preUpsideDownCake() && getBoolean(R.string.p_rmd_persistent, true)
+
+ fun useSwipeToSnooze(): Boolean =
+ getBoolean(R.string.p_rmd_swipe_to_snooze_enabled, false)
+
+ fun swipeToSnoozeIntervalMS(): Long =
+ getIntegerFromString(R.string.p_rmd_swipe_to_snooze_time_minutes, 0).toLong()
var isSyncOngoing: Boolean
get() = syncFlags.any { getBoolean(it, false) }
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index e27ac97f6..3649f10cf 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -16,6 +16,14 @@
- @string/none
+
+ - @string/swipe_to_snooze_time_immediately
+ - @string/swipe_to_snooze_time_15_minutes
+ - @string/swipe_to_snooze_time_30_minutes
+ - @string/swipe_to_snooze_time_1_hour
+ - @string/swipe_to_snooze_time_24_hours
+
+
- @string/ring_once
- @string/ring_five_times
diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml
index 4dbb2a317..f3e1fe542 100644
--- a/app/src/main/res/values/keys.xml
+++ b/app/src/main/res/values/keys.xml
@@ -75,6 +75,17 @@
notif_annoy
+ notif_swipe_to_snooze_enabled
+ notif_swipe_to_snooze_time_minutes
+
+
+ - 0
+ - 15
+ - 30
+ - 60
+ - 1440
+
+
notif_vibrate
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c908d4e72..c0992ff0d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -150,6 +150,14 @@ File %1$s contained %2$s.\n\n
Notifications for tasks without due times will appear at %s
Persistent notifications
Persistent notifications cannot be cleared
+ Swipe to snooze
+ Snooze time
+ A cleared notification will be snoozed and recreated %s
+ immediately
+ after 15 minutes
+ after 30 minutes
+ after 1 hour
+ after 24 hours
Random reminders
Disabled
Hourly
diff --git a/app/src/main/res/xml/preferences_notifications.xml b/app/src/main/res/xml/preferences_notifications.xml
index 3c285a030..9c73c2824 100644
--- a/app/src/main/res/xml/preferences_notifications.xml
+++ b/app/src/main/res/xml/preferences_notifications.xml
@@ -71,6 +71,23 @@
android:summary="@string/more_notification_settings_summary"
app:icon="@drawable/ic_open_in_new_24px" />
+
+
+
+
+
+
+