Fix authentication error buttons

pull/1248/head
Alex Baker 4 years ago
parent 3a117fb966
commit c212a56196

@ -30,6 +30,7 @@ import org.tasks.analytics.Firebase
import org.tasks.billing.Inventory
import org.tasks.caldav.iCalendar.Companion.fromVtodo
import org.tasks.data.CaldavAccount
import org.tasks.data.CaldavAccount.Companion.ERROR_UNAUTHORIZED
import org.tasks.data.CaldavCalendar
import org.tasks.data.CaldavDao
import org.tasks.data.CaldavTask
@ -69,11 +70,11 @@ class CaldavSynchronizer @Inject constructor(
return
}
if (isNullOrEmpty(account.password)) {
setError(account, context.getString(if (account.isTasksOrg) {
R.string.authentication_required
setError(account, if (account.isTasksOrg) {
ERROR_UNAUTHORIZED
} else {
R.string.password_required
}))
context.getString(R.string.password_required)
})
return
}
try {

@ -175,11 +175,9 @@ class CaldavAccount : Parcelable {
!isLoggedOut()
}
fun isLoggedOut(): Boolean =
error?.startsWith("HTTP ${HttpURLConnection.HTTP_UNAUTHORIZED}") == true
fun isLoggedOut() = error?.startsWith(ERROR_UNAUTHORIZED) == true
fun isPaymentRequired(): Boolean =
error?.startsWith("HTTP ${HttpURLConnection.HTTP_PAYMENT_REQUIRED}") == true
fun isPaymentRequired() = error?.startsWith(EROR_PAYMENT_REQUIRED) == true
companion object {
const val TYPE_CALDAV = 0
@ -189,6 +187,9 @@ class CaldavAccount : Parcelable {
const val TYPE_TASKS = 4
const val TYPE_ETEBASE = 5
const val ERROR_UNAUTHORIZED = "HTTP ${HttpURLConnection.HTTP_UNAUTHORIZED}"
const val EROR_PAYMENT_REQUIRED = "HTTP ${HttpURLConnection.HTTP_PAYMENT_REQUIRED}"
fun String?.openTaskType(): String? = this?.split(":")?.get(0)
@JvmField val CREATOR: Parcelable.Creator<CaldavAccount> = object : Parcelable.Creator<CaldavAccount> {

@ -152,8 +152,8 @@ class TasksAccount : InjectingPreferenceFragment() {
setOnPreferenceClickListener {
showPurchaseDialog()
}
if (subscription == null) {
setTitle(R.string.upgrade_to_pro)
if (subscription == null || subscription.isTasksSubscription) {
setTitle(R.string.button_subscribe)
setSummary(R.string.your_subscription_expired)
} else {
setTitle(R.string.manage_subscription)
@ -203,10 +203,11 @@ class TasksAccount : InjectingPreferenceFragment() {
findPreference(R.string.upgrade_to_pro).apply {
title = getString(
if (subscription == null) {
R.string.upgrade_to_pro
R.string.button_subscribe
} else {
R.string.manage_subscription
})
}
)
summary = if (subscription == null) {
null
} else {

Loading…
Cancel
Save