@@ -150,43 +150,41 @@ class IcsExporter(private val context: Context) {
150150 out .writeContentLine(END_EVENT )
151151 }
152152
153- private fun writeTask (outputStream : OutputStream , task : Event ) {
153+ private fun writeTask (out : OutputStream , task : Event ) {
154154 val calendarColors = context.eventsHelper.getCalendarColors()
155- with (outputStream) {
156- writeContentLine(BEGIN_TASK )
157- task.title.let { if (it.isNotEmpty()) writeTextProperty(SUMMARY , it) }
158- task.importId.let { if (it.isNotEmpty()) writeContentLine(" $UID$it " ) }
159- writeContentLine(" $CATEGORY_COLOR${context.calendarsDB.getCalendarWithId(task.calendarId)?.color} " )
160- if (task.color != 0 && task.color != calendarColors[task.calendarId]) {
161- val color = CssColors .findClosestCssColor(task.color)
162- if (color != null ) {
163- writeContentLine(" $COLOR${color} " )
164- }
165- writeContentLine(" $FOSSIFY_COLOR${task.color} " )
155+ out .writeContentLine(BEGIN_TASK )
156+ if (task.title.isNotEmpty()) out .writeTextProperty(SUMMARY , task.title)
157+ if (task.importId.isNotEmpty()) out .writeContentLine(" $UID${task.importId} " )
158+ out .writeContentLine(" $CATEGORY_COLOR${context.calendarsDB.getCalendarWithId(task.calendarId)?.color} " )
159+ if (task.color != 0 && task.color != calendarColors[task.calendarId]) {
160+ val color = CssColors .findClosestCssColor(task.color)
161+ if (color != null ) {
162+ out .writeContentLine(" $COLOR${color} " )
166163 }
167- writeTextProperty(" CATEGORIES" , context.calendarsDB.getCalendarWithId(task.calendarId)?.title ? : " " )
168- writeContentLine(" $LAST_MODIFIED :${Formatter .getExportedTime(task.lastUpdated)} " )
169- task.location.let { if (it.isNotEmpty()) writeTextProperty(LOCATION , it) }
164+ out .writeContentLine(" $FOSSIFY_COLOR${task.color} " )
165+ }
166+ out .writeTextProperty(" CATEGORIES" , context.calendarsDB.getCalendarWithId(task.calendarId)?.title ? : " " )
167+ out .writeContentLine(" $LAST_MODIFIED :${Formatter .getExportedTime(task.lastUpdated)} " )
168+ if (task.location.isNotEmpty()) out .writeTextProperty(LOCATION , task.location)
170169
171- if (task.getIsAllDay()) {
172- writeContentLine(" $DTSTART ;$VALUE =$DATE :${Formatter .getDayCodeFromTS(task.startTS)} " )
173- } else {
174- writeContentLine(" $DTSTART :${Formatter .getExportedTime(task.startTS * 1000L )} " )
175- }
170+ if (task.getIsAllDay()) {
171+ out . writeContentLine(" $DTSTART ;$VALUE =$DATE :${Formatter .getDayCodeFromTS(task.startTS)} " )
172+ } else {
173+ out . writeContentLine(" $DTSTART :${Formatter .getExportedTime(task.startTS * 1000L )} " )
174+ }
176175
177- writeContentLine(" $DTSTAMP$exportTime " )
178- if (task.isTaskCompleted()) {
179- writeContentLine(" $STATUS$COMPLETED " )
180- }
181- Parser ().getRepeatCode(task).let { if (it.isNotEmpty()) writeContentLine(" $RRULE$it " ) }
176+ out . writeContentLine(" $DTSTAMP$exportTime " )
177+ if (task.isTaskCompleted()) {
178+ out . writeContentLine(" $STATUS$COMPLETED " )
179+ }
180+ Parser ().getRepeatCode(task).let { if (it.isNotEmpty()) out . writeContentLine(" $RRULE$it " ) }
182181
183- writeTextProperty(DESCRIPTION , task.description)
184- fillReminders(task, outputStream , reminderLabel)
185- fillIgnoredOccurrences(task, outputStream )
182+ out . writeTextProperty(DESCRIPTION , task.description)
183+ fillReminders(task, out , reminderLabel)
184+ fillIgnoredOccurrences(task, out )
186185
187- eventsExported++
188- writeContentLine(END_TASK )
189- }
186+ eventsExported++
187+ out .writeContentLine(END_TASK )
190188 }
191189
192190 private val contentLineWriter = ContentLineWriter ()
0 commit comments