From 984769a438a3be6e6f40a16759745353a4105b0a Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 10 Sep 2018 12:12:59 +0200 Subject: [PATCH] fix #596, make sure the proper event date is shown at all-day events --- .../simplemobiletools/calendar/extensions/Context.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 } }