add a helper function for checking if google sync is active
This commit is contained in:
parent
c6f716206f
commit
d95152d53c
4 changed files with 15 additions and 2 deletions
|
@ -470,6 +470,13 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.event_added)
|
toast(R.string.event_added)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isGoogleSyncActive()) {
|
||||||
|
if (isOnline()) {
|
||||||
|
createRemoteGoogleEvent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -493,6 +500,10 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun createRemoteGoogleEvent() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateStartTexts() {
|
private fun updateStartTexts() {
|
||||||
updateStartDateText()
|
updateStartDateText()
|
||||||
updateStartTimeText()
|
updateStartTimeText()
|
||||||
|
|
|
@ -90,7 +90,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
||||||
config.googleSync = false
|
config.googleSync = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.googleSync && config.syncAccountName.isNotEmpty()) {
|
if (isGoogleSyncActive()) {
|
||||||
FetchGoogleEventsTask(this, googleSyncListener).execute()
|
FetchGoogleEventsTask(this, googleSyncListener).execute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGoogleSync() {
|
private fun setupGoogleSync() {
|
||||||
settings_google_sync.isChecked = config.googleSync
|
settings_google_sync.isChecked = isGoogleSyncActive()
|
||||||
settings_google_sync_holder.setOnClickListener {
|
settings_google_sync_holder.setOnClickListener {
|
||||||
if (config.googleSync) {
|
if (config.googleSync) {
|
||||||
ConfirmationDialog(this, getString(R.string.google_sync_disabling), positive = R.string.ok, negative = R.string.cancel) {
|
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.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.config: Config get() = Config.newInstance(this)
|
||||||
|
|
||||||
val Context.dbHelper: DBHelper get() = DBHelper.newInstance(this)
|
val Context.dbHelper: DBHelper get() = DBHelper.newInstance(this)
|
||||||
|
|
Loading…
Reference in a new issue