From 802db5f29a8eb887cd51a202e50c3476f81c9116 Mon Sep 17 00:00:00 2001 From: Naveen Date: Fri, 25 Nov 2022 00:14:16 +0530 Subject: [PATCH 1/2] Always show single day all-day events at the top ignoring the user preference `showMidnightSpanningEventsAtTop` --- .../calendar/pro/fragments/WeekFragment.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt index 814938448..def91dd6e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt @@ -454,7 +454,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { val endDayCode = Formatter.getDayCodeFromDateTime(endDateTime) val isAllDay = event.getIsAllDay() - if ((isAllDay || (startDayCode != endDayCode)) && config.showMidnightSpanningEventsAtTop) { + if (shouldAddEventOnTopBar(isAllDay, startDayCode, endDayCode)) { continue } @@ -543,7 +543,8 @@ class WeekFragment : Fragment(), WeeklyCalendar { val startDayCode = Formatter.getDayCodeFromDateTime(startDateTime) val endDateTime = Formatter.getDateTimeFromTS(event.endTS) val endDayCode = Formatter.getDayCodeFromDateTime(endDateTime) - if ((event.getIsAllDay() || (startDayCode != endDayCode)) && config.showMidnightSpanningEventsAtTop) { + + if (shouldAddEventOnTopBar(event.getIsAllDay(), startDayCode, endDayCode)) { addAllDayEvent(event) } else { var currentDateTime = startDateTime @@ -696,6 +697,12 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } + private fun shouldAddEventOnTopBar(isAllDay: Boolean, startDayCode: String, endDayCode: String): Boolean { + val spansMultipleDays = startDayCode != endDayCode + val isSingleDayAllDayEvent = isAllDay && !spansMultipleDays + return isSingleDayAllDayEvent || spansMultipleDays && config.showMidnightSpanningEventsAtTop + } + @SuppressLint("NewApi") private fun addAllDayEvent(event: Event) { (inflater.inflate(R.layout.week_all_day_event_marker, null, false) as ConstraintLayout).apply { From e48bff79536c18bc3f9893ed85757a2c347876c6 Mon Sep 17 00:00:00 2001 From: Naveen Date: Fri, 25 Nov 2022 03:14:04 +0530 Subject: [PATCH 2/2] Minor readability improvement --- .../simplemobiletools/calendar/pro/fragments/WeekFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt index def91dd6e..66e2f97d9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt @@ -700,7 +700,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { private fun shouldAddEventOnTopBar(isAllDay: Boolean, startDayCode: String, endDayCode: String): Boolean { val spansMultipleDays = startDayCode != endDayCode val isSingleDayAllDayEvent = isAllDay && !spansMultipleDays - return isSingleDayAllDayEvent || spansMultipleDays && config.showMidnightSpanningEventsAtTop + return isSingleDayAllDayEvent || (spansMultipleDays && config.showMidnightSpanningEventsAtTop) } @SuppressLint("NewApi")