Improve unsubscribe handling

This commit is contained in:
Phillip Thelen 2020-02-04 14:04:22 +01:00
parent fea83fd387
commit 8e6ccfa6c9
3 changed files with 9 additions and 3 deletions

View file

@ -253,6 +253,8 @@ class NavigationDrawerFragment : DialogFragment() {
}
}
}
} else if (user.isSubscribed) {
subscriptionItem?.subtitle = null
} else {
subscriptionItem?.subtitle = context?.getString(R.string.more_out_of_habitica)
}

View file

@ -179,6 +179,7 @@ class SubscriptionFragment : BaseFragment(), GemPurchaseActivity.CheckoutFragmen
selectedSubscriptionSku?.let { sku ->
purchaseHandler?.purchaseSubscription(sku) {
fetchUser(null)
binding.scrollView.smoothScrollTo(0, 0)
}
}
}
@ -186,7 +187,10 @@ class SubscriptionFragment : BaseFragment(), GemPurchaseActivity.CheckoutFragmen
fun setUser(newUser: User) {
user = newUser
this.updateSubscriptionInfo()
checkIfNeedsCancellation()
purchaseHandler?.checkForSubscription {
purchasedSubscription = it
checkIfNeedsCancellation()
}
}
private fun updateSubscriptionInfo() {
@ -218,7 +222,7 @@ class SubscriptionFragment : BaseFragment(), GemPurchaseActivity.CheckoutFragmen
}
private fun checkIfNeedsCancellation() {
if (user?.purchased?.plan?.isActive == true) {
if (user?.purchased?.plan?.isActive == true && purchasedSubscription?.autoRenewing == false) {
compositeSubscription.add(apiClient.cancelSubscription().subscribe(Consumer {
refresh()
}, RxErrorHandler.handleEmptyError()))

View file

@ -47,7 +47,7 @@ class SubscriptionDetailsView : LinearLayout {
var duration: String? = null
if (plan.planId != null) {
if (plan.planId != null && plan.dateTerminated == null) {
if (plan.planId == SubscriptionPlan.PLANID_BASIC || plan.planId == SubscriptionPlan.PLANID_BASICEARNED) {
duration = resources.getString(R.string.month)
} else if (plan.planId == SubscriptionPlan.PLANID_BASIC3MONTH) {