mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-18 11:49:01 +00:00
Improve unsubscribe handling
This commit is contained in:
parent
fea83fd387
commit
8e6ccfa6c9
3 changed files with 9 additions and 3 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()))
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue