add a helper function for checking if google sync is active
This commit is contained in:
parent
c6f716206f
commit
d95152d53c
|
@ -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()
|
||||
|
|
|
@ -90,7 +90,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||
config.googleSync = false
|
||||
}
|
||||
|
||||
if (config.googleSync && config.syncAccountName.isNotEmpty()) {
|
||||
if (isGoogleSyncActive()) {
|
||||
FetchGoogleEventsTask(this, googleSyncListener).execute()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue