properly clean up old Google Sync events at new CalDAV system
This commit is contained in:
parent
6fd1066b9a
commit
49ec9a59f5
|
@ -95,6 +95,12 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||
}
|
||||
|
||||
recheckCalDAVCalendars {}
|
||||
|
||||
if (config.googleSync) {
|
||||
val ids = dbHelper.getGoogleSyncEvents().map { it.id.toString() }.toTypedArray()
|
||||
dbHelper.deleteEvents(ids, false)
|
||||
config.googleSync = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
@ -71,6 +71,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getInt(FONT_SIZE, FONT_SIZE_MEDIUM)
|
||||
set(size) = prefs.edit().putInt(FONT_SIZE, size).apply()
|
||||
|
||||
var googleSync: Boolean
|
||||
get() = prefs.getBoolean(GOOGLE_SYNC, false)
|
||||
set(googleSync) = prefs.edit().putBoolean(GOOGLE_SYNC, googleSync).apply()
|
||||
|
||||
var caldavSync: Boolean
|
||||
get() = prefs.getBoolean(CALDAV_SYNC, false)
|
||||
set(caldavSync) {
|
||||
|
|
|
@ -47,6 +47,7 @@ val CALDAV_SYNCED_CALENDAR_IDS = "caldav_synced_calendar_ids"
|
|||
val LAST_USED_CALDAV_CALENDAR = "last_used_caldav_calendar"
|
||||
val SNOOZE_DELAY = "snooze_delay"
|
||||
val DISPLAY_PAST_EVENTS = "display_past_events"
|
||||
val GOOGLE_SYNC = "google_sync" // deprecated
|
||||
|
||||
val letterIDs = intArrayOf(R.string.sunday_letter, R.string.monday_letter, R.string.tuesday_letter, R.string.wednesday_letter,
|
||||
R.string.thursday_letter, R.string.friday_letter, R.string.saturday_letter)
|
||||
|
@ -121,3 +122,6 @@ val FONT_SIZE_LARGE = 2
|
|||
|
||||
val SOURCE_SIMPLE_CALENDAR = "simple-calendar"
|
||||
val SOURCE_IMPORTED_ICS = "imported-ics"
|
||||
|
||||
// deprecated
|
||||
val SOURCE_GOOGLE_CALENDAR = 1
|
||||
|
|
|
@ -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_SOURCE = "source" // deprecated
|
||||
|
||||
private val META_TABLE_NAME = "events_meta"
|
||||
private val COL_EVENT_ID = "event_id"
|
||||
|
@ -697,6 +698,12 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
return getEvents(selection) as ArrayList<Event>
|
||||
}
|
||||
|
||||
// get deprecated Google Sync events
|
||||
fun getGoogleSyncEvents(): ArrayList<Event> {
|
||||
val selection = "$MAIN_TABLE_NAME.$COL_SOURCE = $SOURCE_GOOGLE_CALENDAR"
|
||||
return getEvents(selection) as ArrayList<Event>
|
||||
}
|
||||
|
||||
fun getEventsAtReboot(): List<Event> {
|
||||
val selection = "$COL_REMINDER_MINUTES != -1 AND ($COL_START_TS > ? OR $COL_REPEAT_INTERVAL != 0) AND $COL_START_TS != 0"
|
||||
val selectionArgs = arrayOf(DateTime.now().seconds().toString())
|
||||
|
|
Loading…
Reference in New Issue