From 0f295c1c1694beb2902122ecd4eaadfaa6bfada7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 11 Jul 2017 20:04:04 +0200 Subject: [PATCH] untoggle Google sync switch when no account was chosen --- .../calendar/activities/SettingsActivity.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 c2934da92..703413d6f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt @@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.activities import android.Manifest import android.accounts.AccountManager +import android.app.Activity import android.content.Intent import android.content.pm.PackageManager import android.content.res.Resources @@ -283,23 +284,26 @@ class SettingsActivity : SimpleActivity() { else -> R.string.large }) - override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { if (resultCode == RESULT_OK) { if (requestCode == GET_RINGTONE_URI) { - val uri = resultData?.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) + val uri = data?.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) if (uri == null) { config.reminderSound = "" } else { settings_reminder_sound.text = RingtoneManager.getRingtone(this, uri as Uri)?.getTitle(this) config.reminderSound = uri.toString() } - } else if (requestCode == REQUEST_ACCOUNT_NAME && resultData?.extras != null) { - val accountName = resultData.getStringExtra(AccountManager.KEY_ACCOUNT_NAME) + } else if (requestCode == REQUEST_ACCOUNT_NAME && data?.extras != null) { + val accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME) config.syncAccountName = accountName tryEnablingSync() } else if (requestCode == REQUEST_AUTHORIZATION) { tryEnablingSync() } + } else if (resultCode == Activity.RESULT_CANCELED && requestCode == REQUEST_ACCOUNT_NAME) { + settings_google_sync.toggle() + config.googleSync = false } }