fix #243, allow deleting future occurrences of repeating events
This commit is contained in:
parent
41cf2f5744
commit
b83605bb4b
|
@ -565,9 +565,7 @@ class EventActivity : SimpleActivity() {
|
|||
DeleteEventDialog(this, arrayListOf(mEvent.id)) {
|
||||
when (it) {
|
||||
DELETE_SELECTED_OCCURRENCE -> dbHelper.addEventRepeatException(mEvent.id, mEventOccurrenceTS, true)
|
||||
DELETE_FUTURE_OCCURRENCES -> {
|
||||
|
||||
}
|
||||
DELETE_FUTURE_OCCURRENCES -> dbHelper.addEventRepeatLimit(mEvent.id, mEventOccurrenceTS)
|
||||
DELETE_ALL_OCCURRENCES -> dbHelper.deleteEvents(arrayOf(mEvent.id.toString()), true)
|
||||
}
|
||||
finish()
|
||||
|
|
|
@ -129,7 +129,9 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||
}
|
||||
}
|
||||
DELETE_FUTURE_OCCURRENCES -> {
|
||||
|
||||
eventIds.forEachIndexed { index, value ->
|
||||
activity.dbHelper.addEventRepeatLimit(value, timestamps[index])
|
||||
}
|
||||
}
|
||||
DELETE_ALL_OCCURRENCES -> {
|
||||
val eventIDs = Array(eventIds.size, { i -> (eventIds[i].toString()) })
|
||||
|
|
|
@ -225,7 +225,9 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
|
|||
}
|
||||
}
|
||||
DELETE_FUTURE_OCCURRENCES -> {
|
||||
|
||||
eventIds.forEachIndexed { index, value ->
|
||||
activity.dbHelper.addEventRepeatLimit(value, timestamps[index])
|
||||
}
|
||||
}
|
||||
DELETE_ALL_OCCURRENCES -> {
|
||||
val eventIDs = Array(eventIds.size, { i -> (eventIds[i].toString()) })
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.simplemobiletools.calendar.models.EventType
|
|||
import com.simplemobiletools.commons.extensions.getIntValue
|
||||
import com.simplemobiletools.commons.extensions.getLongValue
|
||||
import com.simplemobiletools.commons.extensions.getStringValue
|
||||
import com.simplemobiletools.commons.helpers.DAY_SECONDS
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
@ -552,6 +553,15 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
}
|
||||
}
|
||||
|
||||
fun addEventRepeatLimit(eventId: Int, limitTS: Int) {
|
||||
val values = ContentValues()
|
||||
values.put(COL_REPEAT_LIMIT, limitTS - DAY_SECONDS)
|
||||
|
||||
val selection = "$COL_EVENT_ID = ?"
|
||||
val selectionArgs = arrayOf(eventId.toString())
|
||||
mDb.update(META_TABLE_NAME, values, selection, selectionArgs)
|
||||
}
|
||||
|
||||
fun deleteEventTypes(eventTypes: ArrayList<EventType>, deleteEvents: Boolean, callback: (deletedCnt: Int) -> Unit) {
|
||||
var deleteIds = eventTypes.filter { it.caldavCalendarId == 0 }.map { it.id }
|
||||
deleteIds = deleteIds.filter { it != DBHelper.REGULAR_EVENT_TYPE_ID } as ArrayList<Int>
|
||||
|
|
Loading…
Reference in New Issue