feat(payment): Update Current Subscription screen and logic.

This commit is contained in:
dkadrikj
2025-01-21 10:13:19 +01:00
committed by Dino Kadrikj
parent f9ffddf6a3
commit 16d7451c67
18 changed files with 24 additions and 32 deletions
@@ -33,8 +33,8 @@ import me.proton.core.payment.data.PurchaseManagerImpl
import me.proton.core.payment.data.repository.GooglePurchaseRepositoryImpl
import me.proton.core.payment.data.repository.PaymentsRepositoryImpl
import me.proton.core.payment.data.repository.PurchaseRepositoryImpl
import me.proton.core.payment.domain.IsMobileUpgradesEnabled
import me.proton.core.payment.domain.IsPaymentsV5Enabled
import me.proton.core.payment.domain.features.IsMobileUpgradesEnabled
import me.proton.core.payment.domain.features.IsPaymentsV5Enabled
import me.proton.core.payment.domain.PaymentManager
import me.proton.core.payment.domain.PurchaseManager
import me.proton.core.payment.domain.repository.GooglePurchaseRepository
@@ -25,7 +25,7 @@ import me.proton.core.domain.entity.UserId
import me.proton.core.featureflag.data.IsFeatureFlagEnabledImpl
import me.proton.core.featureflag.domain.FeatureFlagManager
import me.proton.core.featureflag.domain.entity.FeatureId
import me.proton.core.payment.domain.IsMobileUpgradesEnabled
import me.proton.core.payment.domain.features.IsMobileUpgradesEnabled
import javax.inject.Inject
public class IsMobileUpgradesEnabledImpl @Inject constructor(
@@ -24,7 +24,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import me.proton.core.featureflag.data.IsFeatureFlagEnabledImpl
import me.proton.core.featureflag.domain.FeatureFlagManager
import me.proton.core.featureflag.domain.entity.FeatureId
import me.proton.core.payment.domain.IsPaymentsV5Enabled
import me.proton.core.payment.domain.features.IsPaymentsV5Enabled
import javax.inject.Inject
public class IsPaymentsV5EnabledImpl @Inject constructor(
@@ -26,7 +26,7 @@ import me.proton.core.payment.data.api.request.CardDetailsBody
import me.proton.core.payment.data.api.request.CreatePaymentToken
import me.proton.core.payment.data.api.request.IAPDetailsBody
import me.proton.core.payment.data.api.request.PaymentTypeEntity
import me.proton.core.payment.domain.IsPaymentsV5Enabled
import me.proton.core.payment.domain.features.IsPaymentsV5Enabled
import me.proton.core.payment.domain.entity.Card
import me.proton.core.payment.domain.entity.Currency
import me.proton.core.payment.domain.entity.PaymentMethod
@@ -35,7 +35,7 @@ import me.proton.core.network.domain.ApiResult
import me.proton.core.network.domain.session.SessionId
import me.proton.core.network.domain.session.SessionProvider
import me.proton.core.payment.data.api.PaymentsApi
import me.proton.core.payment.domain.IsPaymentsV5Enabled
import me.proton.core.payment.domain.features.IsPaymentsV5Enabled
import me.proton.core.payment.domain.entity.Card
import me.proton.core.payment.domain.entity.Currency
import me.proton.core.payment.domain.entity.Details
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Proton AG
* Copyright (c) 2024 Proton Technologies AG
* This file is part of Proton AG and ProtonCore.
*
* ProtonCore is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
* along with ProtonCore. If not, see <https://www.gnu.org/licenses/>.
*/
package me.proton.core.payment.domain
package me.proton.core.payment.domain.features
import me.proton.core.featureflag.domain.IsFeatureFlagEnabled
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Proton AG
* Copyright (c) 2024 Proton Technologies AG
* This file is part of Proton AG and ProtonCore.
*
* ProtonCore is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
* along with ProtonCore. If not, see <https://www.gnu.org/licenses/>.
*/
package me.proton.core.payment.domain
package me.proton.core.payment.domain.features
import me.proton.core.featureflag.domain.IsFeatureFlagEnabled
@@ -23,7 +23,7 @@ import me.proton.core.accountmanager.domain.AccountManager
import me.proton.core.domain.entity.AppStore
import me.proton.core.domain.entity.UserId
import me.proton.core.network.domain.ApiException
import me.proton.core.payment.domain.IsMobileUpgradesEnabled
import me.proton.core.payment.domain.features.IsMobileUpgradesEnabled
import me.proton.core.user.domain.UserManager
import javax.inject.Inject
@@ -19,8 +19,7 @@
package me.proton.core.payment.domain
import me.proton.core.domain.entity.UserId
import me.proton.core.payment.domain.IsMobileUpgradesEnabled
import me.proton.core.payment.domain.IsPaymentsV5Enabled
import me.proton.core.payment.domain.features.IsMobileUpgradesEnabled
class FakeIsMobileUpgradesEnabled(var isEnabled: Boolean) : IsMobileUpgradesEnabled {
override fun invoke(userId: UserId?): Boolean = isEnabled
@@ -30,7 +30,7 @@ import me.proton.core.domain.entity.UserId
import me.proton.core.network.domain.ApiException
import me.proton.core.network.domain.ApiResult
import me.proton.core.payment.domain.FakeIsMobileUpgradesEnabled
import me.proton.core.payment.domain.IsMobileUpgradesEnabled
import me.proton.core.payment.domain.features.IsMobileUpgradesEnabled
import me.proton.core.payment.domain.entity.PaymentStatus
import me.proton.core.user.domain.UserManager
import kotlin.test.BeforeTest
@@ -19,7 +19,7 @@
package me.proton.core.payment.test
import me.proton.core.domain.entity.UserId
import me.proton.core.payment.domain.IsPaymentsV5Enabled
import me.proton.core.payment.domain.features.IsPaymentsV5Enabled
public class FakeIsPaymentsV5Enabled(public var isEnabled: Boolean) : IsPaymentsV5Enabled {
override fun invoke(userId: UserId?): Boolean = isEnabled
@@ -23,7 +23,7 @@ import me.proton.core.domain.entity.AppStore
import me.proton.core.domain.entity.SessionUserId
import me.proton.core.network.data.ApiProvider
import me.proton.core.network.domain.onParseErrorLog
import me.proton.core.payment.domain.IsPaymentsV5Enabled
import me.proton.core.payment.domain.features.IsPaymentsV5Enabled
import me.proton.core.payment.domain.entity.Currency
import me.proton.core.payment.domain.entity.PaymentTokenEntity
import me.proton.core.payment.domain.entity.SubscriptionCycle
@@ -36,7 +36,7 @@ import me.proton.core.network.domain.ApiManager
import me.proton.core.network.domain.ApiResult
import me.proton.core.network.domain.session.SessionId
import me.proton.core.network.domain.session.SessionProvider
import me.proton.core.payment.domain.IsPaymentsV5Enabled
import me.proton.core.payment.domain.features.IsPaymentsV5Enabled
import me.proton.core.payment.domain.entity.Currency
import me.proton.core.payment.domain.entity.PaymentTokenEntity
import me.proton.core.payment.domain.entity.ProtonPaymentToken
-1
View File
@@ -35,7 +35,6 @@ publishOption.shouldBePublishedAsLib = true
dependencies {
api(
project(Module.accountManagerDomain),
project(Module.domain),
project(Module.featureFlagDomain),
project(Module.networkDomain),
@@ -18,21 +18,15 @@
package me.proton.core.plan.domain.usecase
import kotlinx.coroutines.flow.first
import me.proton.core.accountmanager.domain.AccountManager
import me.proton.core.domain.entity.UserId
import me.proton.core.user.domain.UserManager
import javax.inject.Inject
class HasUserCredits @Inject constructor(
private val accountManager: AccountManager,
private val userManager: UserManager,
) {
suspend operator fun invoke(userId: UserId? = null): Boolean {
val userIdTemp = userId ?: accountManager.getPrimaryUserId().first()
return userIdTemp?.let {
userManager.getUser(it).credit > 0
} ?: false
suspend operator fun invoke(userId: UserId): Boolean {
return userManager.getUser(userId).credit > 0
}
}
@@ -26,11 +26,12 @@ import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import me.proton.core.plan.presentation.R
import me.proton.core.plan.presentation.databinding.BottomSheetManageSubscriptionNoAppBinding
import me.proton.core.presentation.utils.onClick
import com.google.android.material.R as MaterialR
import me.proton.core.plan.presentation.R as CoreR
class ManageSubscriptionNoAppDialog : BottomSheetDialogFragment(R.layout.bottom_sheet_manage_subscription_no_app) {
class ManageSubscriptionNoAppDialog : BottomSheetDialogFragment(CoreR.layout.bottom_sheet_manage_subscription_no_app) {
private lateinit var binding: BottomSheetManageSubscriptionNoAppBinding
@@ -54,7 +55,7 @@ class ManageSubscriptionNoAppDialog : BottomSheetDialogFragment(R.layout.bottom_
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
dialog?.setOnShowListener { it ->
val bottomSheet =
(it as BottomSheetDialog).findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)
(it as BottomSheetDialog).findViewById<View>(MaterialR.id.design_bottom_sheet)
bottomSheet?.let {
val behavior = BottomSheetBehavior.from(it)
behavior.state = BottomSheetBehavior.STATE_EXPANDED
@@ -72,7 +72,7 @@ fun Context.openMarketLink() {
fun Context.openMarketSubscription(purchasedProductId: String?) {
val uri = when (purchasedProductId) {
null -> Uri.parse("https://play.google.com/store/account/subscriptions")
else -> Uri.parse(getString(R.string.play_store_app_subscription, purchasedProductId, packageName))
else -> Uri.parse("https://play.google.com/store/account/subscriptions?sku=$purchasedProductId&amp;package=$packageName")
}
val storeIntent = Intent(Intent.ACTION_VIEW, uri).apply {
addFlags(
@@ -83,7 +83,7 @@ fun Context.openMarketSubscription(purchasedProductId: String?) {
}
when (storeIntent.resolveActivity(packageManager)) {
// we will open app market details if we can not open any deeplink, should be very rare case
null -> openBrowserLink("https://play.google.com/store/apps/details?id=$packageName")
null -> openMarketLink()
else -> startActivity(storeIntent)
}
}
@@ -19,5 +19,4 @@
<resources>
<string name="force_update_link">https://proton.me/support/update-required</string>
<string name="play_store_app_subscription">https://play.google.com/store/account/subscriptions?sku=%1$s&amp;package=%2$s</string>
</resources>