untoggle Google sync switch when no account was chosen

This commit is contained in:
tibbi 2017-07-11 20:04:04 +02:00
parent 3cebca160b
commit 0f295c1c16
1 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.activities
import android.Manifest import android.Manifest
import android.accounts.AccountManager import android.accounts.AccountManager
import android.app.Activity
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.res.Resources import android.content.res.Resources
@ -283,23 +284,26 @@ class SettingsActivity : SimpleActivity() {
else -> R.string.large 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 (resultCode == RESULT_OK) {
if (requestCode == GET_RINGTONE_URI) { if (requestCode == GET_RINGTONE_URI) {
val uri = resultData?.getParcelableExtra<Parcelable>(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) val uri = data?.getParcelableExtra<Parcelable>(RingtoneManager.EXTRA_RINGTONE_PICKED_URI)
if (uri == null) { if (uri == null) {
config.reminderSound = "" config.reminderSound = ""
} else { } else {
settings_reminder_sound.text = RingtoneManager.getRingtone(this, uri as Uri)?.getTitle(this) settings_reminder_sound.text = RingtoneManager.getRingtone(this, uri as Uri)?.getTitle(this)
config.reminderSound = uri.toString() config.reminderSound = uri.toString()
} }
} else if (requestCode == REQUEST_ACCOUNT_NAME && resultData?.extras != null) { } else if (requestCode == REQUEST_ACCOUNT_NAME && data?.extras != null) {
val accountName = resultData.getStringExtra(AccountManager.KEY_ACCOUNT_NAME) val accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME)
config.syncAccountName = accountName config.syncAccountName = accountName
tryEnablingSync() tryEnablingSync()
} else if (requestCode == REQUEST_AUTHORIZATION) { } else if (requestCode == REQUEST_AUTHORIZATION) {
tryEnablingSync() tryEnablingSync()
} }
} else if (resultCode == Activity.RESULT_CANCELED && requestCode == REQUEST_ACCOUNT_NAME) {
settings_google_sync.toggle()
config.googleSync = false
} }
} }