diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index bf3d72609..117734552 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -65,6 +65,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { updateStartTime() updateEndDate() updateEndTime() + updateEventType() mWasEndDateSet = event != null mWasEndTimeSet = event != null @@ -82,6 +83,8 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { event_reminder_2.setOnClickListener { showReminder2Dialog() } event_reminder_3.setOnClickListener { showReminder3Dialog() } + event_type.setOnClickListener { } + if (mEvent.flags and FLAG_ALL_DAY != 0) event_all_day.toggle() @@ -219,6 +222,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { event_repetition.text = getRepetitionToString(mRepeatInterval) } + private fun updateEventType() { + + } + private fun getRepetitionToString(seconds: Int) = getString(when (seconds) { DAY -> R.string.daily WEEK -> R.string.weekly @@ -380,6 +387,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { event_time_image.setColorFilter(config.textColor, PorterDuff.Mode.SRC_IN) event_repetition_image.setColorFilter(config.textColor, PorterDuff.Mode.SRC_IN) event_reminder_image.setColorFilter(config.textColor, PorterDuff.Mode.SRC_IN) + event_type_image.setColorFilter(config.textColor, PorterDuff.Mode.SRC_IN) } override fun eventInserted(event: Event) { 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 47cba98f8..aaff06d10 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -31,7 +31,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont private val COL_REMINDER_MINUTES_3 = "reminder_minutes_3" private val COL_IMPORT_ID = "import_id" private val COL_FLAGS = "flags" - private val COL_TYPE = "type" + private val COL_EVENT_TYPE = "event_type" private val META_TABLE_NAME = "events_meta" private val COL_EVENT_ID = "event_id" @@ -64,7 +64,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont 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, " + "$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_TYPE INTEGER)") + "$COL_IMPORT_ID TEXT, $COL_FLAGS INTEGER, $COL_EVENT_TYPE INTEGER)") createMetaTable(db) createTypesTable(db) @@ -95,7 +95,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont if (oldVersion < 7) { createTypesTable(db) - db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_TYPE INTEGER NOT NULL DEFAULT 0") + db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_EVENT_TYPE INTEGER NOT NULL DEFAULT 0") } } @@ -308,7 +308,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont while (e.startTS < toTS && (e.repeatLimit == 0 || e.repeatLimit > e.endTS)) { if (e.startTS > fromTS) { val newEvent = Event(e.id, e.startTS, e.endTS, e.title, e.description, e.reminder1Minutes, e.reminder2Minutes, e.reminder3Minutes, - e.repeatInterval, e.importId, e.flags) + e.repeatInterval, e.importId, e.flags, e.eventType) newEvents.add(newEvent) } e.addIntervalTime() @@ -350,7 +350,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont private val allColumns: Array 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_MONTH, COL_REPEAT_DAY, COL_IMPORT_ID, COL_FLAGS, COL_REPEAT_LIMIT) + COL_REMINDER_MINUTES_3, COL_REPEAT_INTERVAL, COL_REPEAT_MONTH, COL_REPEAT_DAY, COL_IMPORT_ID, COL_FLAGS, COL_REPEAT_LIMIT, COL_EVENT_TYPE) private fun fillEvents(cursor: Cursor?): List { val events = ArrayList() @@ -369,8 +369,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont val importId = cursor.getStringValue(COL_IMPORT_ID) val flags = cursor.getIntValue(COL_FLAGS) val repeatLimit = cursor.getIntValue(COL_REPEAT_LIMIT) + val eventType = cursor.getIntValue(COL_EVENT_TYPE) events.add(Event(id, startTS, endTS, title, description, reminder1Minutes, reminder2Minutes, reminder3Minutes, - repeatInterval, importId, flags, repeatLimit)) + repeatInterval, importId, flags, repeatLimit, eventType)) } while (cursor.moveToNext()) } } finally { 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 22038715a..b64c57920 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt @@ -7,7 +7,7 @@ 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 = "", 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) : Serializable { + var importId: String? = "", var flags: Int = 0, var repeatLimit: Int = 0, var eventType: Int = DBHelper.REGULAR_EVENT_ID) : Serializable { companion object { private val serialVersionUID = -32456795132344616L @@ -31,7 +31,5 @@ data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var val isAllDay = flags and FLAG_ALL_DAY != 0 - fun getRemindersCount() = getReminders().count() - fun getReminders() = setOf(reminder1Minutes, reminder2Minutes, reminder3Minutes).filter { it != REMINDER_OFF } } diff --git a/app/src/main/res/layout/activity_event.xml b/app/src/main/res/layout/activity_event.xml index add983671..036f590c9 100644 --- a/app/src/main/res/layout/activity_event.xml +++ b/app/src/main/res/layout/activity_event.xml @@ -267,5 +267,41 @@ android:textSize="@dimen/day_text_size" android:visibility="gone"/> + + + + + +