mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
removing the ignoredEventOccurrences field of Event
This commit is contained in:
@@ -221,7 +221,6 @@ class CalDAVHandler(val context: Context) {
|
|||||||
existingEvent.apply {
|
existingEvent.apply {
|
||||||
this.id = null
|
this.id = null
|
||||||
color = 0
|
color = 0
|
||||||
ignoreEventOccurrences = ArrayList()
|
|
||||||
lastUpdated = 0L
|
lastUpdated = 0L
|
||||||
offset = ""
|
offset = ""
|
||||||
}
|
}
|
||||||
|
@@ -607,12 +607,15 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
events = events
|
events = events
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.distinct()
|
.distinct()
|
||||||
.filterNot { it.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(it.startTS).toInt()) }
|
.filterNot { getIgnoredOccurrences(it).contains(Formatter.getDayCodeFromTS(it.startTS).toInt()) }
|
||||||
.toMutableList() as ArrayList<Event>
|
.toMutableList() as ArrayList<Event>
|
||||||
callback(events)
|
callback(events)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRepeatableEventsFor(fromTS: Int, toTS: Int, eventId: Long = -1L, applyTypeFilter: Boolean = false): List<Event> {
|
fun getRepeatableEventsFor(fromTS: Int, toTS: Int, eventId: Long = -1L, applyTypeFilter: Boolean = false): List<Event> {
|
||||||
|
if (isOnMainThread()) {
|
||||||
|
Log.e("DEBUG", "dbhelper getRepeatableEventsFor")
|
||||||
|
}
|
||||||
val newEvents = ArrayList<Event>()
|
val newEvents = ArrayList<Event>()
|
||||||
|
|
||||||
var selection = "$COL_REPEAT_INTERVAL != 0 AND $COL_START_TS <= $toTS AND $COL_START_TS != 0"
|
var selection = "$COL_REPEAT_INTERVAL != 0 AND $COL_START_TS <= $toTS AND $COL_START_TS != 0"
|
||||||
@@ -857,19 +860,13 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
val color = eventTypeColors.get(eventType)!!
|
val color = eventTypeColors.get(eventType)!!
|
||||||
val isPastEvent = false
|
val isPastEvent = false
|
||||||
|
|
||||||
val ignoreEventOccurrences = if (repeatInterval != 0) {
|
|
||||||
getIgnoredOccurrences(id)
|
|
||||||
} else {
|
|
||||||
ArrayList()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (repeatInterval > 0 && repeatRule == 0 && (repeatInterval % MONTH == 0 || repeatInterval % YEAR == 0)) {
|
if (repeatInterval > 0 && repeatRule == 0 && (repeatInterval % MONTH == 0 || repeatInterval % YEAR == 0)) {
|
||||||
repeatRule = REPEAT_SAME_DAY
|
repeatRule = REPEAT_SAME_DAY
|
||||||
}
|
}
|
||||||
|
|
||||||
val event = Event(id, startTS, endTS, title, description, reminder1Minutes, reminder2Minutes, reminder3Minutes,
|
val event = Event(id, startTS, endTS, title, description, reminder1Minutes, reminder2Minutes, reminder3Minutes,
|
||||||
repeatInterval, importId, flags, repeatLimit, repeatRule, eventType, ignoreEventOccurrences, offset, isDstIncluded,
|
repeatInterval, importId, flags, repeatLimit, repeatRule, eventType, offset, isDstIncluded, 0, lastUpdated,
|
||||||
0, lastUpdated, source, color, location, isPastEvent)
|
source, color, location, isPastEvent)
|
||||||
event.isPastEvent = getIsPastEvent(event)
|
event.isPastEvent = getIsPastEvent(event)
|
||||||
|
|
||||||
events.add(event)
|
events.add(event)
|
||||||
@@ -928,10 +925,14 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getIgnoredOccurrences(eventId: Long): ArrayList<Int> {
|
fun getIgnoredOccurrences(event: Event): ArrayList<Int> {
|
||||||
|
if (event.repeatInterval == 0) {
|
||||||
|
return ArrayList()
|
||||||
|
}
|
||||||
|
|
||||||
val projection = arrayOf(COL_OCCURRENCE_DAYCODE)
|
val projection = arrayOf(COL_OCCURRENCE_DAYCODE)
|
||||||
val selection = "$COL_PARENT_EVENT_ID = ?"
|
val selection = "$COL_PARENT_EVENT_ID = ?"
|
||||||
val selectionArgs = arrayOf(eventId.toString())
|
val selectionArgs = arrayOf(event.id.toString())
|
||||||
val daycodes = ArrayList<Int>()
|
val daycodes = ArrayList<Int>()
|
||||||
|
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
|
@@ -58,7 +58,7 @@ class IcsExporter {
|
|||||||
Parser().getRepeatCode(event).let { if (it.isNotEmpty()) out.writeLn("$RRULE$it") }
|
Parser().getRepeatCode(event).let { if (it.isNotEmpty()) out.writeLn("$RRULE$it") }
|
||||||
|
|
||||||
fillReminders(event, out)
|
fillReminders(event, out)
|
||||||
fillIgnoredOccurrences(event, out)
|
fillIgnoredOccurrences(activity, event, out)
|
||||||
|
|
||||||
eventsExported++
|
eventsExported++
|
||||||
out.writeLn(END_EVENT)
|
out.writeLn(END_EVENT)
|
||||||
@@ -91,9 +91,9 @@ class IcsExporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fillIgnoredOccurrences(event: Event, out: BufferedWriter) {
|
private fun fillIgnoredOccurrences(activity: BaseSimpleActivity, event: Event, out: BufferedWriter) {
|
||||||
event.ignoreEventOccurrences.forEach {
|
activity.dbHelper.getIgnoredOccurrences(event).forEach {
|
||||||
out.writeLn("$EXDATE:$it}")
|
out.writeLn("$EXDATE:$it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,17 +2,14 @@ package com.simplemobiletools.calendar.pro.models
|
|||||||
|
|
||||||
import com.simplemobiletools.calendar.pro.extensions.seconds
|
import com.simplemobiletools.calendar.pro.extensions.seconds
|
||||||
import com.simplemobiletools.calendar.pro.helpers.*
|
import com.simplemobiletools.calendar.pro.helpers.*
|
||||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
data class Event(var id: Long?, var startTS: Int = 0, var endTS: Int = 0, var title: String = "", var description: String = "",
|
data class Event(var id: Long?, var startTS: Int = 0, var endTS: Int = 0, var title: String = "", var description: String = "",
|
||||||
var reminder1Minutes: Int = -1, var reminder2Minutes: Int = -1, var reminder3Minutes: Int = -1, var repeatInterval: Int = 0,
|
var reminder1Minutes: Int = -1, var reminder2Minutes: Int = -1, var reminder3Minutes: Int = -1, var repeatInterval: Int = 0,
|
||||||
var importId: String = "", var flags: Int = 0, var repeatLimit: Int = 0, var repeatRule: Int = 0,
|
var importId: String = "", var flags: Int = 0, var repeatLimit: Int = 0, var repeatRule: Int = 0,
|
||||||
var eventType: Long = DBHelper.REGULAR_EVENT_TYPE_ID, var ignoreEventOccurrences: ArrayList<Int> = ArrayList(),
|
var eventType: Long = DBHelper.REGULAR_EVENT_TYPE_ID, var offset: String = "", var isDstIncluded: Boolean = false, var parentId: Long = 0,
|
||||||
var offset: String = "", var isDstIncluded: Boolean = false, var parentId: Long = 0, var lastUpdated: Long = 0L,
|
var lastUpdated: Long = 0L, var source: String = SOURCE_SIMPLE_CALENDAR, var color: Int = 0, var location: String = "", var isPastEvent: Boolean = false)
|
||||||
var source: String = SOURCE_SIMPLE_CALENDAR, var color: Int = 0, var location: String = "", var isPastEvent: Boolean = false)
|
|
||||||
: Serializable {
|
: Serializable {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@@ -34,7 +34,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(event.startTS).toInt())) {
|
if (!context.dbHelper.getIgnoredOccurrences(event).contains(Formatter.getDayCodeFromTS(event.startTS).toInt())) {
|
||||||
context.notifyEvent(event)
|
context.notifyEvent(event)
|
||||||
}
|
}
|
||||||
context.scheduleNextEventReminder(event, context.dbHelper)
|
context.scheduleNextEventReminder(event, context.dbHelper)
|
||||||
|
Reference in New Issue
Block a user