From f77f645479766736f75e3bc56b0da7d25476c83f Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 14 Apr 2017 14:57:16 +0200 Subject: [PATCH] adding repeatDay to events --- .../calendar/helpers/Constants.kt | 8 ++++++++ .../calendar/helpers/DBHelper.kt | 17 ++++------------- .../simplemobiletools/calendar/models/Event.kt | 6 +++--- 3 files changed, 15 insertions(+), 16 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 eba1f8c7d..af301102e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -47,6 +47,14 @@ val SYNC_ACCOUNT_NAME = "sync_account_name" val letterIDs = intArrayOf(R.string.sunday_letter, R.string.monday_letter, R.string.tuesday_letter, R.string.wednesday_letter, R.string.thursday_letter, R.string.friday_letter, R.string.saturday_letter) +val MONDAY = 1 +val TUESDAY = 2 +val WEDNESDAY = 4 +val THURSDAY = 8 +val FRIDAY = 16 +val SATURDAY = 32 +val SUNDAY = 64 + // special event flags val FLAG_ALL_DAY = 1 diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index 3afbe13b0..fd34f0f1b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -197,22 +197,12 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } private fun fillMetaValues(event: Event): ContentValues { - val repeatInterval = event.repeatInterval - val dateTime = Formatter.getDateTimeFromTS(event.startTS) - return ContentValues().apply { put(COL_EVENT_ID, event.id) put(COL_REPEAT_START, event.startTS) - put(COL_REPEAT_INTERVAL, repeatInterval) + put(COL_REPEAT_INTERVAL, event.repeatInterval) put(COL_REPEAT_LIMIT, event.repeatLimit) - - if (repeatInterval == MONTH || repeatInterval == YEAR) { - put(COL_REPEAT_DAY, dateTime.dayOfMonth) - } - - if (repeatInterval == YEAR) { - put(COL_REPEAT_MONTH, dateTime.monthOfYear) - } + put(COL_REPEAT_DAY, event.repeatDay) } } @@ -492,6 +482,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont val reminder2Minutes = cursor.getIntValue(COL_REMINDER_MINUTES_2) val reminder3Minutes = cursor.getIntValue(COL_REMINDER_MINUTES_3) val repeatInterval = cursor.getIntValue(COL_REPEAT_INTERVAL) + val repeatDay = cursor.getIntValue(COL_REPEAT_DAY) val title = cursor.getStringValue(COL_TITLE) val description = cursor.getStringValue(COL_DESCRIPTION) val importId = cursor.getStringValue(COL_IMPORT_ID) @@ -508,7 +499,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } val event = Event(id, startTS, endTS, title, description, reminder1Minutes, reminder2Minutes, reminder3Minutes, - repeatInterval, importId, flags, repeatLimit, eventType, ignoreEventOccurrences) + repeatInterval, importId, flags, repeatLimit, repeatDay, eventType, ignoreEventOccurrences) events.add(event) } while (cursor.moveToNext()) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt index a988c04a4..5e85e387b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt @@ -9,11 +9,11 @@ import java.util.* data class Event(var id: Int = 0, 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 importId: String? = "", var flags: Int = 0, var repeatLimit: Int = 0, var eventType: Int = DBHelper.REGULAR_EVENT_TYPE_ID, - var ignoreEventOccurrences: ArrayList = ArrayList()) : Serializable { + var importId: String? = "", var flags: Int = 0, var repeatLimit: Int = 0, var repeatDay: Int = 0, + var eventType: Int = DBHelper.REGULAR_EVENT_TYPE_ID, var ignoreEventOccurrences: ArrayList = ArrayList()) : Serializable { companion object { - private val serialVersionUID = -32456795132344616L + private val serialVersionUID = -32456795132345616L } fun addIntervalTime() {