Always show single day all-day events at the top

ignoring the user preference `showMidnightSpanningEventsAtTop`
This commit is contained in:
Naveen 2022-11-25 00:14:16 +05:30
parent 839bbd1fa9
commit 802db5f29a
1 changed files with 9 additions and 2 deletions

View File

@ -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 {