add an All-day flag to all-day events
This commit is contained in:
parent
dd65a0f10b
commit
50e621d71b
|
@ -70,6 +70,9 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
event_reminder.setOnClickListener { showReminderDialog() }
|
event_reminder.setOnClickListener { showReminderDialog() }
|
||||||
event_repetition.setOnClickListener { showRepeatIntervalDialog() }
|
event_repetition.setOnClickListener { showRepeatIntervalDialog() }
|
||||||
|
|
||||||
|
if (mEvent.flags and FLAG_ALL_DAY != 0)
|
||||||
|
event_all_day.toggle()
|
||||||
|
|
||||||
updateTextColors(event_scrollview)
|
updateTextColors(event_scrollview)
|
||||||
updateIconColors()
|
updateIconColors()
|
||||||
}
|
}
|
||||||
|
@ -178,6 +181,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
description = newDescription
|
description = newDescription
|
||||||
reminderMinutes = mReminderMinutes
|
reminderMinutes = mReminderMinutes
|
||||||
repeatInterval = mRepeatInterval
|
repeatInterval = mRepeatInterval
|
||||||
|
flags = if (event_all_day.isChecked) (mEvent.flags or FLAG_ALL_DAY) else (mEvent.flags xor FLAG_ALL_DAY)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mEvent.id == 0) {
|
if (mEvent.id == 0) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_V
|
||||||
private val COL_DESCRIPTION = "description"
|
private val COL_DESCRIPTION = "description"
|
||||||
private val COL_REMINDER_MINUTES = "reminder_minutes"
|
private val COL_REMINDER_MINUTES = "reminder_minutes"
|
||||||
private val COL_IMPORT_ID = "import_id"
|
private val COL_IMPORT_ID = "import_id"
|
||||||
|
private val COL_FLAGS = "flags"
|
||||||
|
|
||||||
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"
|
||||||
|
@ -52,7 +53,7 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_V
|
||||||
|
|
||||||
override fun onCreate(db: SQLiteDatabase) {
|
override fun onCreate(db: SQLiteDatabase) {
|
||||||
db.execSQL("CREATE TABLE $MAIN_TABLE_NAME ($COL_ID INTEGER PRIMARY KEY, $COL_START_TS INTEGER, $COL_END_TS INTEGER, $COL_TITLE TEXT, " +
|
db.execSQL("CREATE TABLE $MAIN_TABLE_NAME ($COL_ID INTEGER PRIMARY KEY, $COL_START_TS INTEGER, $COL_END_TS INTEGER, $COL_TITLE TEXT, " +
|
||||||
"$COL_DESCRIPTION TEXT, $COL_REMINDER_MINUTES INTEGER, $COL_IMPORT_ID TEXT)")
|
"$COL_DESCRIPTION TEXT, $COL_REMINDER_MINUTES INTEGER, $COL_IMPORT_ID TEXT, $COL_FLAGS INTEGER)")
|
||||||
|
|
||||||
createMetaTable(db)
|
createMetaTable(db)
|
||||||
}
|
}
|
||||||
|
@ -68,6 +69,7 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_V
|
||||||
|
|
||||||
if (oldVersion < 4) {
|
if (oldVersion < 4) {
|
||||||
db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_IMPORT_ID TEXT")
|
db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_IMPORT_ID TEXT")
|
||||||
|
db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_FLAGS INTEGER")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +85,7 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_V
|
||||||
val eventValues = fillContentValues(event)
|
val eventValues = fillContentValues(event)
|
||||||
val id = mDb.insert(MAIN_TABLE_NAME, null, eventValues)
|
val id = mDb.insert(MAIN_TABLE_NAME, null, eventValues)
|
||||||
event.id = id.toInt()
|
event.id = id.toInt()
|
||||||
|
|
||||||
if (event.repeatInterval != 0) {
|
if (event.repeatInterval != 0) {
|
||||||
val metaValues = fillMetaValues(event)
|
val metaValues = fillMetaValues(event)
|
||||||
mDb.insert(META_TABLE_NAME, null, metaValues)
|
mDb.insert(META_TABLE_NAME, null, metaValues)
|
||||||
|
@ -119,6 +122,7 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_V
|
||||||
put(COL_DESCRIPTION, event.description)
|
put(COL_DESCRIPTION, event.description)
|
||||||
put(COL_REMINDER_MINUTES, event.reminderMinutes)
|
put(COL_REMINDER_MINUTES, event.reminderMinutes)
|
||||||
put(COL_IMPORT_ID, event.importId)
|
put(COL_IMPORT_ID, event.importId)
|
||||||
|
put(COL_FLAGS, event.flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +214,7 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_V
|
||||||
for (e in events) {
|
for (e in events) {
|
||||||
while (e.startTS < toTS) {
|
while (e.startTS < toTS) {
|
||||||
if (e.startTS > fromTS) {
|
if (e.startTS > fromTS) {
|
||||||
val newEvent = Event(e.id, e.startTS, e.endTS, e.title, e.description, e.reminderMinutes, e.repeatInterval)
|
val newEvent = Event(e.id, e.startTS, e.endTS, e.title, e.description, e.reminderMinutes, e.repeatInterval, e.importId, e.flags)
|
||||||
newEvents.add(newEvent)
|
newEvents.add(newEvent)
|
||||||
}
|
}
|
||||||
e.addIntervalTime()
|
e.addIntervalTime()
|
||||||
|
@ -251,7 +255,8 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_V
|
||||||
}
|
}
|
||||||
|
|
||||||
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_REPEAT_INTERVAL, COL_REPEAT_MONTH, COL_REPEAT_DAY)
|
get() = arrayOf("$MAIN_TABLE_NAME.$COL_ID", COL_START_TS, COL_END_TS, COL_TITLE, COL_DESCRIPTION, COL_REMINDER_MINUTES, COL_REPEAT_INTERVAL,
|
||||||
|
COL_REPEAT_MONTH, COL_REPEAT_DAY, COL_IMPORT_ID, COL_FLAGS)
|
||||||
|
|
||||||
private fun fillEvents(cursor: Cursor?): List<Event> {
|
private fun fillEvents(cursor: Cursor?): List<Event> {
|
||||||
val events = ArrayList<Event>()
|
val events = ArrayList<Event>()
|
||||||
|
@ -265,7 +270,9 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_V
|
||||||
val repeatInterval = cursor.getIntValue(COL_REPEAT_INTERVAL)
|
val repeatInterval = cursor.getIntValue(COL_REPEAT_INTERVAL)
|
||||||
val title = cursor.getStringValue(COL_TITLE)
|
val title = cursor.getStringValue(COL_TITLE)
|
||||||
val description = cursor.getStringValue(COL_DESCRIPTION)
|
val description = cursor.getStringValue(COL_DESCRIPTION)
|
||||||
events.add(Event(id, startTS, endTS, title, description, reminderMinutes, repeatInterval))
|
val importId = cursor.getStringValue(COL_IMPORT_ID)
|
||||||
|
val flags = cursor.getIntValue(COL_FLAGS)
|
||||||
|
events.add(Event(id, startTS, endTS, title, description, reminderMinutes, repeatInterval, importId, flags))
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.joda.time.DateTime
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var title: String = "", var description: String = "",
|
data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var title: String = "", var description: String = "",
|
||||||
var reminderMinutes: Int = 0, var repeatInterval: Int = 0, var importId: String = "", var flag: Int = 0) : Serializable {
|
var reminderMinutes: Int = 0, var repeatInterval: Int = 0, var importId: String = "", var flags: Int = 0) : Serializable {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val serialVersionUID = -32456795132344616L
|
private val serialVersionUID = -32456795132344616L
|
||||||
|
|
Loading…
Reference in New Issue