store current time offset at inserting/updating event
This commit is contained in:
parent
2c2ba94f8d
commit
4ba7ab7d1a
|
@ -452,6 +452,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||
repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit
|
||||
repeatRule = mRepeatRule
|
||||
eventType = mEventTypeId
|
||||
offset = getCurrentOffset()
|
||||
}
|
||||
|
||||
if (mEvent.id == 0) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.support.v7.app.NotificationCompat
|
|||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.activities.EventActivity
|
||||
import com.simplemobiletools.calendar.helpers.*
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
import com.simplemobiletools.calendar.receivers.NotificationReceiver
|
||||
import com.simplemobiletools.calendar.services.SnoozeService
|
||||
|
@ -24,6 +25,8 @@ import com.simplemobiletools.commons.extensions.isKitkatPlus
|
|||
import com.simplemobiletools.commons.extensions.isLollipopPlus
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
fun Context.updateWidgets() {
|
||||
val widgetsCnt = AppWidgetManager.getInstance(this).getAppWidgetIds(ComponentName(this, MyWidgetMonthlyProvider::class.java))
|
||||
|
@ -220,6 +223,8 @@ fun Context.launchNewEventIntent(startNewTask: Boolean = false, today: Boolean =
|
|||
|
||||
fun Context.getNewEventTimestampFromCode(dayCode: String) = Formatter.getLocalDateTimeFromCode(dayCode).withTime(13, 0, 0, 0).seconds()
|
||||
|
||||
fun Context.getCurrentOffset() = SimpleDateFormat("Z", Locale.getDefault()).format(Date())
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(this)
|
||||
|
||||
val Context.dbHelper: DBHelper get() = DBHelper.newInstance(this)
|
||||
|
|
|
@ -204,6 +204,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
put(COL_FLAGS, event.flags)
|
||||
put(COL_EVENT_TYPE, event.eventType)
|
||||
put(COL_PARENT_EVENT_ID, 0)
|
||||
put(COL_OFFSET, event.offset)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,7 +538,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
|
||||
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,
|
||||
COL_REMINDER_MINUTES_3, COL_REPEAT_INTERVAL, COL_REPEAT_RULE, COL_IMPORT_ID, COL_FLAGS, COL_REPEAT_LIMIT, COL_EVENT_TYPE)
|
||||
COL_REMINDER_MINUTES_3, COL_REPEAT_INTERVAL, COL_REPEAT_RULE, COL_IMPORT_ID, COL_FLAGS, COL_REPEAT_LIMIT, COL_EVENT_TYPE, COL_OFFSET)
|
||||
|
||||
private fun fillEvents(cursor: Cursor?): List<Event> {
|
||||
val events = ArrayList<Event>()
|
||||
|
@ -558,6 +559,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
val flags = cursor.getIntValue(COL_FLAGS)
|
||||
val repeatLimit = cursor.getIntValue(COL_REPEAT_LIMIT)
|
||||
val eventType = cursor.getIntValue(COL_EVENT_TYPE)
|
||||
val offset = cursor.getStringValue(COL_OFFSET)
|
||||
|
||||
val ignoreEventOccurrences = if (repeatInterval != 0) {
|
||||
getIgnoredOccurrences(id)
|
||||
|
@ -570,7 +572,7 @@ 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)
|
||||
repeatInterval, importId, flags, repeatLimit, repeatRule, eventType, ignoreEventOccurrences, offset)
|
||||
events.add(event)
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.*
|
|||
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, var repeatRule: Int = 0,
|
||||
var eventType: Int = DBHelper.REGULAR_EVENT_TYPE_ID, var ignoreEventOccurrences: ArrayList<Int> = ArrayList()) : Serializable {
|
||||
var eventType: Int = DBHelper.REGULAR_EVENT_TYPE_ID, var ignoreEventOccurrences: ArrayList<Int> = ArrayList(), var offset: String = "") : Serializable {
|
||||
|
||||
companion object {
|
||||
private val serialVersionUID = -32456795132345616L
|
||||
|
|
Loading…
Reference in New Issue