From 527ca0d39f7292a7355677114a1f77e5756902a2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 3 Apr 2017 22:35:28 +0200 Subject: [PATCH] add a couple more parameters to exported events --- .../simplemobiletools/calendar/helpers/Constants.kt | 4 ++++ .../calendar/helpers/IcsExporter.kt | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt index ac7b96fdc..e88611caa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -64,12 +64,16 @@ val ACTION = "ACTION:" val TRIGGER = "TRIGGER:" val RRULE = "RRULE:" val CATEGORIES = "CATEGORIES:" +val STATUS = "STATUS:" val DISPLAY = "DISPLAY" val FREQ = "FREQ" val UNTIL = "UNTIL" val COUNT = "COUNT" val INTERVAL = "INTERVAL" +val CONFIRMED = "CONFIRMED" +val VALUE = "VALUE" +val DATE = "DATE" val DAILY = "DAILY" val WEEKLY = "WEEKLY" diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt index fa5323bcb..a243a5f43 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.calendar.helpers import android.content.Context +import com.simplemobiletools.calendar.extensions.dbHelper import com.simplemobiletools.calendar.extensions.writeLn import com.simplemobiletools.calendar.helpers.IcsExporter.ExportResult.* import com.simplemobiletools.calendar.models.Event @@ -24,8 +25,15 @@ class IcsExporter { event.title.let { if (it.isNotEmpty()) out.writeLn("$SUMMARY$it") } event.description.let { if (it.isNotEmpty()) out.writeLn("$DESCRIPTION$it") } event.importId?.let { if (it.isNotEmpty()) out.writeLn("$UID$it") } - event.startTS.let { out.writeLn("$DTSTART:${Formatter.getExportedTime(it)}") } - event.endTS.let { out.writeLn("$DTEND:${Formatter.getExportedTime(it)}") } + event.eventType.let { out.writeLn("$CATEGORIES${context.dbHelper.getEventType(it)?.title}") } + + if (event.isAllDay) { + out.writeLn("$DTSTART;$VALUE=$DATE:${Formatter.getDayCodeFromTS(event.startTS)}") + } else { + event.startTS.let { out.writeLn("$DTSTART:${Formatter.getExportedTime(it)}") } + event.endTS.let { out.writeLn("$DTEND:${Formatter.getExportedTime(it)}") } + } + out.writeLn("$STATUS$CONFIRMED") out.writeLn(END_EVENT) }