diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt index 4f4ef9c6e..c4e0cc9cc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -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() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt index 0418c8f2f..d285b36d7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt @@ -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) { 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 562cbdcc6..fdce4e850 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -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 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 c7bc03626..fdef5e616 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_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 } + // get deprecated Google Sync events + fun getGoogleSyncEvents(): ArrayList { + val selection = "$MAIN_TABLE_NAME.$COL_SOURCE = $SOURCE_GOOGLE_CALENDAR" + return getEvents(selection) as ArrayList + } + fun getEventsAtReboot(): List { 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())