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 0bf39c7a8..7d8b6c17d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -70,8 +70,9 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { mReminder2Minutes = -1 mReminder3Minutes = -1 val startTS = intent.getIntExtra(NEW_EVENT_START_TS, 0) - if (startTS == 0) + if (startTS == 0) { return + } setupNewEvent(Formatter.getDateTimeFromTS(startTS)) } @@ -82,6 +83,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { updateEndTexts() updateEventType() updateCalDAVCalendar() + updateLocation() event_start_date.setOnClickListener { setupStartDate() } event_start_time.setOnClickListener { setupStartTime() } @@ -115,6 +117,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { mEventStartDateTime = Formatter.getDateTimeFromTS(realStart) mEventEndDateTime = Formatter.getDateTimeFromTS(realStart + duration) event_title.setText(mEvent.title) + event_location.setText(mEvent.location) event_description.setText(mEvent.description) event_description.movementMethod = LinkMovementMethod.getInstance() @@ -201,16 +204,20 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } private fun checkRepetitionLimitText() { - event_repetition_limit.text = if (mRepeatLimit == 0) { - event_repetition_limit_label.text = getString(R.string.repeat) - resources.getString(R.string.forever) - } else if (mRepeatLimit > 0) { - event_repetition_limit_label.text = getString(R.string.repeat_till) - val repeatLimitDateTime = Formatter.getDateTimeFromTS(mRepeatLimit) - Formatter.getFullDate(applicationContext, repeatLimitDateTime) - } else { - event_repetition_limit_label.text = getString(R.string.repeat) - "${-mRepeatLimit} ${getString(R.string.times)}" + event_repetition_limit.text = when { + mRepeatLimit == 0 -> { + event_repetition_limit_label.text = getString(R.string.repeat) + resources.getString(R.string.forever) + } + mRepeatLimit > 0 -> { + event_repetition_limit_label.text = getString(R.string.repeat_till) + val repeatLimitDateTime = Formatter.getDateTimeFromTS(mRepeatLimit) + Formatter.getFullDate(applicationContext, repeatLimitDateTime) + } + else -> { + event_repetition_limit_label.text = getString(R.string.repeat) + "${-mRepeatLimit} ${getString(R.string.times)}" + } } } @@ -446,6 +453,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } } + private fun updateLocation() { + event_location.setText(mEvent.location) + } + private fun toggleAllDay(isChecked: Boolean) { hideKeyboard() event_start_time.beGoneIf(isChecked) @@ -519,12 +530,11 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } val reminders = sortedSetOf(mReminder1Minutes, mReminder2Minutes, mReminder3Minutes).filter { it != REMINDER_OFF } - val newDescription = event_description.value mEvent.apply { startTS = newStartTS endTS = newEndTS title = newTitle - description = newDescription + description = event_description.value reminder1Minutes = reminders.elementAtOrElse(0) { REMINDER_OFF } reminder2Minutes = reminders.elementAtOrElse(1) { REMINDER_OFF } reminder3Minutes = reminders.elementAtOrElse(2) { REMINDER_OFF } @@ -538,6 +548,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { isDstIncluded = TimeZone.getDefault().inDaylightTime(Date()) lastUpdated = System.currentTimeMillis() source = newSource + location = event_location.value } // recreate the event if it was moved in a different CalDAV calendar diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt index ca8fda07c..0d3315bcd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt @@ -209,7 +209,8 @@ class CalDAVHandler(val context: Context) { CalendarContract.Events.DTEND, CalendarContract.Events.DURATION, CalendarContract.Events.ALL_DAY, - CalendarContract.Events.RRULE) + CalendarContract.Events.RRULE, + CalendarContract.Events.EVENT_LOCATION) val selection = "${CalendarContract.Events.CALENDAR_ID} = $calendarId" var cursor: Cursor? = null @@ -224,6 +225,7 @@ class CalDAVHandler(val context: Context) { var endTS = (cursor.getLongValue(CalendarContract.Events.DTEND) / 1000).toInt() val allDay = cursor.getIntValue(CalendarContract.Events.ALL_DAY) val rrule = cursor.getStringValue(CalendarContract.Events.RRULE) ?: "" + val location = cursor.getStringValue(CalendarContract.Events.EVENT_LOCATION) ?: "" val reminders = getCalDAVEventReminders(id) if (endTS == 0) { @@ -235,7 +237,8 @@ class CalDAVHandler(val context: Context) { val repeatRule = Parser().parseRepeatInterval(rrule, startTS) val event = Event(0, startTS, endTS, title, description, reminders.getOrElse(0, { -1 }), reminders.getOrElse(1, { -1 }), reminders.getOrElse(2, { -1 }), repeatRule.repeatInterval, - importId, allDay, repeatRule.repeatLimit, repeatRule.repeatRule, eventTypeId, source = "$CALDAV-$calendarId") + importId, allDay, repeatRule.repeatLimit, repeatRule.repeatRule, eventTypeId, source = "$CALDAV-$calendarId", + location = location) if (event.getIsAllDay() && endTS > startTS) { event.endTS -= DAY @@ -330,6 +333,7 @@ class CalDAVHandler(val context: Context) { put(CalendarContract.Events.ALL_DAY, if (event.getIsAllDay()) 1 else 0) put(CalendarContract.Events.RRULE, Parser().getRepeatCode(event)) put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone.getDefault().toString()) + put(CalendarContract.Events.EVENT_LOCATION, event.location) if (event.getIsAllDay() && event.endTS > event.startTS) event.endTS += DAY 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 52f8e9271..d1dc1bd89 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -92,6 +92,7 @@ val STATUS = "STATUS:" val EXDATE = "EXDATE" val BYDAY = "BYDAY" val BYMONTHDAY = "BYMONTHDAY" +val LOCATION = "LOCATION:" val DISPLAY = "DISPLAY" val FREQ = "FREQ" 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 df308d8d8..cf5fe4546 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -37,6 +37,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont private val COL_IS_DST_INCLUDED = "is_dst_included" private val COL_LAST_UPDATED = "last_updated" private val COL_EVENT_SOURCE = "event_source" + private val COL_LOCATION = "location" private val COL_SOURCE = "source" // deprecated private val META_TABLE_NAME = "events_meta" @@ -64,7 +65,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont private val mDb: SQLiteDatabase = writableDatabase companion object { - private val DB_VERSION = 18 + private val DB_VERSION = 19 val DB_NAME = "events.db" val REGULAR_EVENT_TYPE_ID = 1 var dbInstance: DBHelper? = null @@ -84,7 +85,8 @@ 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, " + "$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_PARENT_EVENT_ID INTEGER, $COL_OFFSET TEXT, $COL_IS_DST_INCLUDED INTEGER, $COL_LAST_UPDATED INTEGER, $COL_EVENT_SOURCE TEXT)") + "$COL_PARENT_EVENT_ID INTEGER, $COL_OFFSET TEXT, $COL_IS_DST_INCLUDED INTEGER, $COL_LAST_UPDATED INTEGER, $COL_EVENT_SOURCE TEXT, " + + "$COL_LOCATION TEXT)") createMetaTable(db) createTypesTable(db) @@ -170,6 +172,10 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont if (oldVersion < 18) { updateOldMonthlyEvents(db) } + + if (oldVersion < 19) { + db.execSQL("ALTER TABLE $MAIN_TABLE_NAME ADD COLUMN $COL_LOCATION TEXT DEFAULT ''") + } } private fun createMetaTable(db: SQLiteDatabase) { @@ -258,6 +264,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont put(COL_IS_DST_INCLUDED, if (event.isDstIncluded) 1 else 0) put(COL_LAST_UPDATED, event.lastUpdated) put(COL_EVENT_SOURCE, event.source) + put(COL_LOCATION, event.location) } } @@ -767,7 +774,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_RULE, COL_IMPORT_ID, COL_FLAGS, COL_REPEAT_LIMIT, COL_EVENT_TYPE, COL_OFFSET, - COL_IS_DST_INCLUDED, COL_LAST_UPDATED, COL_EVENT_SOURCE) + COL_IS_DST_INCLUDED, COL_LAST_UPDATED, COL_EVENT_SOURCE, COL_LOCATION) private fun fillEvents(cursor: Cursor?): List { val eventTypeColors = SparseIntArray() @@ -776,7 +783,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } val events = ArrayList() - try { + cursor.use { cursor -> if (cursor != null && cursor.moveToFirst()) { do { val id = cursor.getIntValue(COL_ID) @@ -797,6 +804,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont val isDstIncluded = cursor.getIntValue(COL_IS_DST_INCLUDED) == 1 val lastUpdated = cursor.getLongValue(COL_LAST_UPDATED) val source = cursor.getStringValue(COL_EVENT_SOURCE) + val location = cursor.getStringValue(COL_LOCATION) val color = eventTypeColors[eventType] val ignoreEventOccurrences = if (repeatInterval != 0) { @@ -811,12 +819,10 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont val event = Event(id, startTS, endTS, title, description, reminder1Minutes, reminder2Minutes, reminder3Minutes, repeatInterval, importId, flags, repeatLimit, repeatRule, eventType, ignoreEventOccurrences, offset, isDstIncluded, - 0, lastUpdated, source, color) + 0, lastUpdated, source, color, location) events.add(event) } while (cursor.moveToNext()) } - } finally { - cursor?.close() } return events } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt index 903b282bb..268029e4a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt @@ -33,6 +33,7 @@ class IcsExporter { event.importId.let { if (it.isNotEmpty()) out.writeLn("$UID$it") } event.eventType.let { out.writeLn("$CATEGORIES${activity.dbHelper.getEventType(it)?.title}") } event.lastUpdated.let { out.writeLn("$LAST_MODIFIED:${Formatter.getExportedTime(it)}") } + event.location.let { if (it.isNotEmpty()) out.writeLn("$LOCATION$it") } if (event.getIsAllDay()) { out.writeLn("$DTSTART;$VALUE=$DATE:${Formatter.getDayCodeFromTS(event.startTS)}") diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt index d403b5aeb..2214b7a28 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt @@ -29,6 +29,7 @@ class IcsImporter { private var curRepeatRule = 0 private var curEventType = DBHelper.REGULAR_EVENT_TYPE_ID private var curLastModified = 0L + private var curLocation = "" private var isNotificationDescription = false private var lastReminderAction = "" @@ -92,6 +93,8 @@ class IcsImporter { curLastModified = getTimestamp(line.substring(LAST_MODIFIED.length)) * 1000L } else if (line.startsWith(EXDATE)) { curRepeatExceptions.add(getTimestamp(line.substring(EXDATE.length))) + } else if (line.startsWith(LOCATION)) { + curLocation = line.substring(LOCATION.length) } else if (line == END_EVENT) { if (curStart != -1 && curEnd == -1) curEnd = curStart @@ -107,7 +110,7 @@ class IcsImporter { val event = Event(0, curStart, curEnd, curTitle, curDescription, curReminderMinutes.getOrElse(0, { -1 }), curReminderMinutes.getOrElse(1, { -1 }), curReminderMinutes.getOrElse(2, { -1 }), curRepeatInterval, curImportId, curFlags, curRepeatLimit, curRepeatRule, curEventType, lastUpdated = curLastModified, - source = SOURCE_IMPORTED_ICS) + source = SOURCE_IMPORTED_ICS, location = curLocation) if (event.getIsAllDay() && curEnd > curStart) { event.endTS -= DAY @@ -197,6 +200,7 @@ class IcsImporter { curRepeatRule = 0 curEventType = DBHelper.REGULAR_EVENT_TYPE_ID curLastModified = 0L + curLocation = "" isNotificationDescription = false lastReminderAction = "" } 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 3beaa5109..6c5a0b6de 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt @@ -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 eventType: Int = DBHelper.REGULAR_EVENT_TYPE_ID, var ignoreEventOccurrences: ArrayList = ArrayList(), var offset: String = "", var isDstIncluded: Boolean = false, var parentId: Int = 0, var lastUpdated: Long = 0L, - var source: String = SOURCE_SIMPLE_CALENDAR, var color: Int = 0) : Serializable { + var source: String = SOURCE_SIMPLE_CALENDAR, var color: Int = 0, var location: String = "") : Serializable { companion object { private val serialVersionUID = -32456795132345616L diff --git a/app/src/main/res/layout/activity_event.xml b/app/src/main/res/layout/activity_event.xml index f7f0e6638..c9676c145 100644 --- a/app/src/main/res/layout/activity_event.xml +++ b/app/src/main/res/layout/activity_event.xml @@ -28,13 +28,29 @@ android:textSize="@dimen/day_text_size"/> + + Událost úspěšně změněna Filtrovat Filtrovat události podle typu + Location Opakovaná událost diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 87ed3000c..358da0beb 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -28,6 +28,7 @@ Termin erfolgreich aktualisiert Sortieren Sortiere Termine nach Typ + Location Wiederholung diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index f479a2a99..da85a4643 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -28,6 +28,7 @@ El evento se ha actualizado con éxito Filtrar Filtrar eventos según tipo + Location Repetición diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 5588df877..5fd08a0ac 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -28,6 +28,7 @@ Evénement ajouté avec succès Filtrer Filtrer les evénements par type + Location Répétition diff --git a/app/src/main/res/values-hi-rIN/strings.xml b/app/src/main/res/values-hi-rIN/strings.xml index 0443fa6b7..47cc5f15b 100644 --- a/app/src/main/res/values-hi-rIN/strings.xml +++ b/app/src/main/res/values-hi-rIN/strings.xml @@ -28,6 +28,7 @@ इवेंट सफलतापूर्वक अपडेट किया गया Filter Filter events by type + Location दुहराव diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 43018929e..e049eedce 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -28,6 +28,7 @@ Bejegyzés frissítve Filter Filter events by type + Location Ismétlés diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index bdc838480..99e8cd2a6 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -28,6 +28,7 @@ Evento aggiornato correttamente Filtro Filtra eventi per tipologia + Location Ripeti diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index 548625205..6c2c44ab9 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -28,6 +28,7 @@ האירוע עודכן בהצלחה Filter Filter events by type + Location Repetition diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index acabe4a1a..aa53c6ed9 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -28,6 +28,7 @@ イベントを正常に更新しました Filter Filter events by type + Location 繰り返し diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 2cb05c191..155796eb1 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -28,6 +28,7 @@ 이벤트를 수정했습니다 필터 유형별 이벤트 + Location 반복 diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 1c07dc770..f09f9075d 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -28,6 +28,7 @@ Wydarzenie zostało zaktualizowane Filtr Filtruj wydarzenia według typu + Location Powtórzenie diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 11007fa07..35d18820a 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -28,6 +28,7 @@ Evento atualizado com sucesso Filtrar Filtrar eventos por tipo + Location Repetição diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index e97db8dc6..5a4bed895 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -28,6 +28,7 @@ Evento atualizado com sucesso Filtrar Filtrar eventos por tipo + Location Repetição diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 8b3059da7..ec058ae58 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -28,6 +28,7 @@ Событие успешно обновлено Фильтрация Фильтровать события по типу + Location Повторять diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index cc624b92e..3fb93370a 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -28,6 +28,7 @@ Udalosť bola úspešne upravená Filtrovať Filtrovať udalosti podľa typu + Miesto Opakovanie diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index ba65b1ad3..2f874c829 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -28,6 +28,7 @@ Händelsen uppdaterad Filtrera Filtrera händelser efter typ + Location Upprepning diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index edbdda902..f961ed675 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -28,6 +28,7 @@ Etkinlik başarıyla güncellendi Filtre Etkinlikleri türe göre filtreleyin + Location Tekrarla diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8f93b760f..8c94c90d3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,6 +28,7 @@ Event updated successfully Filter Filter events by type + Location Repetition