diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt index 6ae42cf2e..986475e30 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -32,8 +32,8 @@ import com.simplemobiletools.calendar.receivers.CalDAVSyncReceiver import com.simplemobiletools.calendar.receivers.NotificationReceiver import com.simplemobiletools.calendar.services.SnoozeService import com.simplemobiletools.commons.extensions.* -import com.simplemobiletools.commons.helpers.DAY_SECONDS import com.simplemobiletools.commons.helpers.SILENT +import com.simplemobiletools.commons.helpers.WEEK_SECONDS import com.simplemobiletools.commons.helpers.YEAR_SECONDS import com.simplemobiletools.commons.helpers.isOreoPlus import org.joda.time.DateTime @@ -161,13 +161,16 @@ fun Context.notifyEvent(originalEvent: Event) { var event = originalEvent.copy() val currentSeconds = getNowSeconds() + var eventStartTS = if (event.getIsAllDay()) Formatter.getDayStartTS(Formatter.getDayCodeFromTS(event.startTS)) else event.startTS // make sure refer to the proper repeatable event instance with "Tomorrow", or the specific date - if (event.repeatInterval != 0 && event.startTS - event.reminder1Minutes * 60 < currentSeconds) { - val events = dbHelper.getRepeatableEventsFor(currentSeconds - DAY_SECONDS, currentSeconds + YEAR_SECONDS, event.id) + if (event.repeatInterval != 0 && eventStartTS - event.reminder1Minutes * 60 < currentSeconds) { + val events = dbHelper.getRepeatableEventsFor(currentSeconds - WEEK_SECONDS, currentSeconds + YEAR_SECONDS, event.id) for (currEvent in events) { - if (currEvent.startTS - currEvent.reminder1Minutes * 60 > currentSeconds) { + eventStartTS = if (currEvent.getIsAllDay()) Formatter.getDayStartTS(Formatter.getDayCodeFromTS(currEvent.startTS)) else currEvent.startTS + if (eventStartTS - currEvent.reminder1Minutes * 60 > currentSeconds) { break } + event = currEvent } }