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 2dc798663..49136f8ae 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -159,17 +159,15 @@ fun Context.notifyEvent(event: Event) { val startTime = Formatter.getTimeFromTS(applicationContext, event.startTS) val endTime = Formatter.getTimeFromTS(applicationContext, event.endTS) val startDate = Formatter.getDateFromTS(event.startTS) - val displayedStartDate: String - if (startDate == LocalDate.now()) { - displayedStartDate = "" - } else if (startDate == LocalDate.now().plusDays(1)) { - displayedStartDate = getString(R.string.tomorrow) - } else /* At least 2 days in the future */ { - displayedStartDate = Formatter.getDayAndMonth(startDate) + val displayedStartDate = when (startDate) { + LocalDate.now() -> "" + LocalDate.now().plusDays(1) -> getString(R.string.tomorrow) + else -> Formatter.getDayAndMonth(startDate) } + val timeRange = if (event.getIsAllDay()) getString(R.string.all_day) else getFormattedEventTime(startTime, endTime) val descriptionOrLocation = if (config.replaceDescription) event.location else event.description - val content = arrayOf(displayedStartDate, timeRange, descriptionOrLocation).joinToString(" ") + val content = "$displayedStartDate $timeRange $descriptionOrLocation".trim() val notification = getNotification(applicationContext, pendingIntent, event, content) val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager notificationManager.notify(event.id, notification) @@ -221,7 +219,7 @@ private fun getNotification(context: Context, pendingIntent: PendingIntent, even return builder.build() } -private fun getFormattedEventTime(startTime: String, endTime: String) = if (startTime == endTime) startTime else "$startTime\u2013$endTime" +private fun getFormattedEventTime(startTime: String, endTime: String) = if (startTime == endTime) startTime else "$startTime \u2013 $endTime" private fun getPendingIntent(context: Context, event: Event): PendingIntent { val intent = Intent(context, EventActivity::class.java)