store event sources as strings
This commit is contained in:
parent
ad9ad142ed
commit
484554d373
|
@ -12,6 +12,7 @@ val EVENT_OCCURRENCE_TS = "event_occurrence_ts"
|
||||||
val NEW_EVENT_START_TS = "new_event_start_ts"
|
val NEW_EVENT_START_TS = "new_event_start_ts"
|
||||||
val WEEK_START_TIMESTAMP = "week_start_timestamp"
|
val WEEK_START_TIMESTAMP = "week_start_timestamp"
|
||||||
val NEW_EVENT_SET_HOUR_DURATION = "new_event_set_hour_duration"
|
val NEW_EVENT_SET_HOUR_DURATION = "new_event_set_hour_duration"
|
||||||
|
val CALDAV = "Caldav"
|
||||||
|
|
||||||
val MONTHLY_VIEW = 1
|
val MONTHLY_VIEW = 1
|
||||||
val YEARLY_VIEW = 2
|
val YEARLY_VIEW = 2
|
||||||
|
@ -119,5 +120,5 @@ val FONT_SIZE_SMALL = 0
|
||||||
val FONT_SIZE_MEDIUM = 1
|
val FONT_SIZE_MEDIUM = 1
|
||||||
val FONT_SIZE_LARGE = 2
|
val FONT_SIZE_LARGE = 2
|
||||||
|
|
||||||
val SOURCE_SIMPLE_CALENDAR = 0
|
val SOURCE_SIMPLE_CALENDAR = "simple-calendar"
|
||||||
val SOURCE_IMPORTED_ICS = 2
|
val SOURCE_IMPORTED_ICS = "imported-ics"
|
||||||
|
|
|
@ -35,7 +35,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
private val COL_OFFSET = "offset"
|
private val COL_OFFSET = "offset"
|
||||||
private val COL_IS_DST_INCLUDED = "is_dst_included"
|
private val COL_IS_DST_INCLUDED = "is_dst_included"
|
||||||
private val COL_LAST_UPDATED = "last_updated"
|
private val COL_LAST_UPDATED = "last_updated"
|
||||||
private val COL_SOURCE = "source"
|
private val COL_EVENT_SOURCE = "event_source"
|
||||||
|
|
||||||
private val META_TABLE_NAME = "events_meta"
|
private val META_TABLE_NAME = "events_meta"
|
||||||
private val COL_EVENT_ID = "event_id"
|
private val COL_EVENT_ID = "event_id"
|
||||||
|
@ -59,7 +59,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
private val mDb: SQLiteDatabase = writableDatabase
|
private val mDb: SQLiteDatabase = writableDatabase
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val DB_VERSION = 14
|
private val DB_VERSION = 15
|
||||||
val DB_NAME = "events.db"
|
val DB_NAME = "events.db"
|
||||||
val REGULAR_EVENT_TYPE_ID = 1
|
val REGULAR_EVENT_TYPE_ID = 1
|
||||||
var dbInstance: DBHelper? = null
|
var dbInstance: DBHelper? = null
|
||||||
|
@ -79,7 +79,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
db.execSQL("CREATE TABLE $MAIN_TABLE_NAME ($COL_ID INTEGER PRIMARY KEY AUTOINCREMENT, $COL_START_TS INTEGER, $COL_END_TS INTEGER, " +
|
db.execSQL("CREATE TABLE $MAIN_TABLE_NAME ($COL_ID INTEGER PRIMARY KEY AUTOINCREMENT, $COL_START_TS INTEGER, $COL_END_TS INTEGER, " +
|
||||||
"$COL_TITLE TEXT, $COL_DESCRIPTION TEXT, $COL_REMINDER_MINUTES INTEGER, $COL_REMINDER_MINUTES_2 INTEGER, $COL_REMINDER_MINUTES_3 INTEGER, " +
|
"$COL_TITLE TEXT, $COL_DESCRIPTION TEXT, $COL_REMINDER_MINUTES INTEGER, $COL_REMINDER_MINUTES_2 INTEGER, $COL_REMINDER_MINUTES_3 INTEGER, " +
|
||||||
"$COL_IMPORT_ID TEXT, $COL_FLAGS INTEGER, $COL_EVENT_TYPE INTEGER NOT NULL DEFAULT $REGULAR_EVENT_TYPE_ID, " +
|
"$COL_IMPORT_ID TEXT, $COL_FLAGS INTEGER, $COL_EVENT_TYPE INTEGER NOT NULL DEFAULT $REGULAR_EVENT_TYPE_ID, " +
|
||||||
"$COL_PARENT_EVENT_ID INTEGER, $COL_OFFSET TEXT, $COL_IS_DST_INCLUDED INTEGER, $COL_LAST_UPDATED INTEGER, $COL_SOURCE INTEGER)")
|
"$COL_PARENT_EVENT_ID INTEGER, $COL_OFFSET TEXT, $COL_IS_DST_INCLUDED INTEGER, $COL_LAST_UPDATED INTEGER, $COL_EVENT_SOURCE TEXT)")
|
||||||
|
|
||||||
createMetaTable(db)
|
createMetaTable(db)
|
||||||
createTypesTable(db)
|
createTypesTable(db)
|
||||||
|
@ -147,7 +147,10 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
|
|
||||||
if (oldVersion < 14) {
|
if (oldVersion < 14) {
|
||||||
db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_LAST_UPDATED INTEGER NOT NULL DEFAULT 0")
|
db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_LAST_UPDATED INTEGER NOT NULL DEFAULT 0")
|
||||||
db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_SOURCE INTEGER NOT NULL DEFAULT $SOURCE_SIMPLE_CALENDAR")
|
}
|
||||||
|
|
||||||
|
if (oldVersion < 15) {
|
||||||
|
db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_EVENT_SOURCE TEXT DEFAULT ''")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +230,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
put(COL_OFFSET, event.offset)
|
put(COL_OFFSET, event.offset)
|
||||||
put(COL_IS_DST_INCLUDED, if (event.isDstIncluded) 1 else 0)
|
put(COL_IS_DST_INCLUDED, if (event.isDstIncluded) 1 else 0)
|
||||||
put(COL_LAST_UPDATED, event.lastUpdated)
|
put(COL_LAST_UPDATED, event.lastUpdated)
|
||||||
put(COL_SOURCE, event.source)
|
put(COL_EVENT_SOURCE, event.source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,7 +666,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
private val allColumns: Array<String>
|
private val allColumns: Array<String>
|
||||||
get() = arrayOf("$MAIN_TABLE_NAME.$COL_ID", COL_START_TS, COL_END_TS, COL_TITLE, COL_DESCRIPTION, COL_REMINDER_MINUTES, COL_REMINDER_MINUTES_2,
|
get() = arrayOf("$MAIN_TABLE_NAME.$COL_ID", COL_START_TS, COL_END_TS, COL_TITLE, COL_DESCRIPTION, COL_REMINDER_MINUTES, COL_REMINDER_MINUTES_2,
|
||||||
COL_REMINDER_MINUTES_3, COL_REPEAT_INTERVAL, COL_REPEAT_RULE, COL_IMPORT_ID, COL_FLAGS, COL_REPEAT_LIMIT, COL_EVENT_TYPE, COL_OFFSET,
|
COL_REMINDER_MINUTES_3, COL_REPEAT_INTERVAL, COL_REPEAT_RULE, COL_IMPORT_ID, COL_FLAGS, COL_REPEAT_LIMIT, COL_EVENT_TYPE, COL_OFFSET,
|
||||||
COL_IS_DST_INCLUDED, COL_LAST_UPDATED, COL_SOURCE)
|
COL_IS_DST_INCLUDED, COL_LAST_UPDATED, COL_EVENT_SOURCE)
|
||||||
|
|
||||||
private fun fillEvents(cursor: Cursor?): List<Event> {
|
private fun fillEvents(cursor: Cursor?): List<Event> {
|
||||||
val events = ArrayList<Event>()
|
val events = ArrayList<Event>()
|
||||||
|
@ -687,7 +690,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
val offset = cursor.getStringValue(COL_OFFSET)
|
val offset = cursor.getStringValue(COL_OFFSET)
|
||||||
val isDstIncluded = cursor.getIntValue(COL_IS_DST_INCLUDED) == 1
|
val isDstIncluded = cursor.getIntValue(COL_IS_DST_INCLUDED) == 1
|
||||||
val lastUpdated = cursor.getLongValue(COL_LAST_UPDATED)
|
val lastUpdated = cursor.getLongValue(COL_LAST_UPDATED)
|
||||||
val source = cursor.getIntValue(COL_SOURCE)
|
val source = cursor.getStringValue(COL_EVENT_SOURCE)
|
||||||
|
|
||||||
val ignoreEventOccurrences = if (repeatInterval != 0) {
|
val ignoreEventOccurrences = if (repeatInterval != 0) {
|
||||||
getIgnoredOccurrences(id)
|
getIgnoredOccurrences(id)
|
||||||
|
|
|
@ -12,7 +12,7 @@ data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var
|
||||||
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: Int = DBHelper.REGULAR_EVENT_TYPE_ID, var ignoreEventOccurrences: ArrayList<Int> = ArrayList(),
|
var eventType: Int = DBHelper.REGULAR_EVENT_TYPE_ID, var ignoreEventOccurrences: ArrayList<Int> = ArrayList(),
|
||||||
var offset: String = "", var isDstIncluded: Boolean = false, var parentId: Int = 0, var lastUpdated: Long = 0L,
|
var offset: String = "", var isDstIncluded: Boolean = false, var parentId: Int = 0, var lastUpdated: Long = 0L,
|
||||||
var source: Int = SOURCE_SIMPLE_CALENDAR) : Serializable {
|
var source: String = SOURCE_SIMPLE_CALENDAR) : Serializable {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val serialVersionUID = -32456795132345616L
|
private val serialVersionUID = -32456795132345616L
|
||||||
|
|
Loading…
Reference in New Issue