mirror of
https://github.com/etesync/android
synced 2025-01-11 00:01:12 +00:00
Events: automatically transform EMAIL event reminders to DISPLAY ones.
iCal support EMAIL event reminders which EteSync doesn't and can't support due to end-to-end encryption. This commit therefore modifies the event reminders DISPLAY so reminders are actually shown on the phone. Fixes #63
This commit is contained in:
parent
175fa5dd0c
commit
6031bd2699
@ -18,6 +18,8 @@ import at.bitfire.ical4android.*
|
||||
import at.bitfire.ical4android.Constants.ical4jVersion
|
||||
import com.etesync.syncadapter.Constants
|
||||
import com.etesync.syncadapter.log.Logger
|
||||
import net.fortuna.ical4j.model.component.VAlarm
|
||||
import net.fortuna.ical4j.model.property.Action
|
||||
import net.fortuna.ical4j.model.property.ProdId
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.util.*
|
||||
@ -99,6 +101,24 @@ class LocalEvent : AndroidEvent, LocalResource<Event> {
|
||||
.withValue(COLUMN_ETAG, eTag)
|
||||
}
|
||||
|
||||
override fun insertReminder(batch: BatchOperation, idxEvent: Int, alarm: VAlarm) {
|
||||
// We only support DISPLAY and AUDIO alarms so modify when inserting
|
||||
val action = alarm.action
|
||||
val modifiedAlarm = when (action?.value) {
|
||||
Action.DISPLAY.value,
|
||||
Action.AUDIO.value -> alarm
|
||||
Action.EMAIL.value -> {
|
||||
val tmp = VAlarm(alarm.trigger?.duration)
|
||||
tmp.properties += Action.DISPLAY
|
||||
tmp.properties += alarm.description
|
||||
tmp
|
||||
}
|
||||
else -> alarm
|
||||
}
|
||||
|
||||
super.insertReminder(batch, idxEvent, modifiedAlarm)
|
||||
}
|
||||
|
||||
@Throws(CalendarStorageException::class)
|
||||
fun addAsDirty(): Uri {
|
||||
saveAsDirty = true
|
||||
|
Loading…
Reference in New Issue
Block a user