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 db1d4edd5..c46667cf6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -470,6 +470,13 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } else { toast(R.string.event_added) } + + if (isGoogleSyncActive()) { + if (isOnline()) { + createRemoteGoogleEvent() + } + } + finish() } } else { @@ -493,6 +500,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } } + private fun createRemoteGoogleEvent() { + + } + private fun updateStartTexts() { updateStartDateText() updateStartTimeText() 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 cb07d3990..71209c37a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -90,7 +90,7 @@ class MainActivity : SimpleActivity(), NavigationListener { config.googleSync = false } - if (config.googleSync && config.syncAccountName.isNotEmpty()) { + if (isGoogleSyncActive()) { FetchGoogleEventsTask(this, googleSyncListener).execute() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt index 29efdb349..48f42b6af 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt @@ -109,7 +109,7 @@ class SettingsActivity : SimpleActivity() { } private fun setupGoogleSync() { - settings_google_sync.isChecked = config.googleSync + settings_google_sync.isChecked = isGoogleSyncActive() settings_google_sync_holder.setOnClickListener { if (config.googleSync) { ConfirmationDialog(this, getString(R.string.google_sync_disabling), positive = R.string.ok, negative = R.string.cancel) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt index eb367fef2..8102e0336 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -249,6 +249,8 @@ fun Context.getNewEventTimestampFromCode(dayCode: String) = Formatter.getLocalDa fun Context.getCurrentOffset() = SimpleDateFormat("Z", Locale.getDefault()).format(Date()) +fun Context.isGoogleSyncActive() = config.googleSync && config.syncAccountName.isNotEmpty() + val Context.config: Config get() = Config.newInstance(this) val Context.dbHelper: DBHelper get() = DBHelper.newInstance(this)