From eb3dd461ad340c169f5d31be81214df4f891f49c Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 14 Oct 2022 11:50:56 -0500 Subject: [PATCH] Fix crash when signing back into tasks.org --- .../org/tasks/preferences/fragments/TasksAccount.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/tasks/preferences/fragments/TasksAccount.kt b/app/src/main/java/org/tasks/preferences/fragments/TasksAccount.kt index 8d2a8c2a0..849e1b18d 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/TasksAccount.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/TasksAccount.kt @@ -21,6 +21,7 @@ import org.tasks.BuildConfig import org.tasks.LocalBroadcastManager import org.tasks.R import org.tasks.auth.SignInActivity +import org.tasks.auth.SignInActivity.Platform import org.tasks.billing.Inventory import org.tasks.billing.Purchase import org.tasks.data.CaldavAccount @@ -149,7 +150,7 @@ class TasksAccount : BaseAccountPreference() { localBroadcastManager.unregisterReceiver(refreshReceiver) } - private val isGitHubAccount: Boolean + private val isGithub: Boolean get() = caldavAccount.username?.startsWith("github") == true private fun refreshUi(account: CaldavAccount) { @@ -162,9 +163,10 @@ class TasksAccount : BaseAccountPreference() { when { account.isPaymentRequired() -> { val subscription = inventory.subscription.value - if (isGitHubAccount) { + if (isGithub) { title = null setSummary(R.string.insufficient_sponsorship) + @Suppress("KotlinConstantConditions") if (BuildConfig.FLAVOR == "googleplay") { onPreferenceClickListener = null } else { @@ -185,7 +187,7 @@ class TasksAccount : BaseAccountPreference() { } } account.isLoggedOut() -> { - setTitle(if (isGitHubAccount) { + setTitle(if (isGithub) { R.string.sign_in_with_github } else { R.string.sign_in_with_google @@ -195,8 +197,8 @@ class TasksAccount : BaseAccountPreference() { activity?.startActivityForResult( Intent(activity, SignInActivity::class.java) .putExtra( - SignInActivity.EXTRA_SELECT_SERVICE, - if (isGitHubAccount) 1 else 0 + SignInActivity.EXTRA_SELECT_SERVICE, + if (isGithub) Platform.GITHUB else Platform.GOOGLE ), REQUEST_TASKS_ORG) false