Provide plans for signup and upgrade flow separately

Rationale: VPN wants to be able to have plan selection for plan
upgrade flow but not for signup.
This commit is contained in:
Mateusz Markowicz 2021-11-22 09:16:12 +01:00
parent 8105336ee6
commit c9e7b13f1b
6 changed files with 35 additions and 17 deletions

View File

@ -1,3 +1,10 @@
## Plan [1.18.3]
22 Nov, 2021
### Changes
- Provide plans for signup and upgrade flow separately
## Network [1.16.0] ## Network [1.16.0]
22 Nov, 2021 22 Nov, 2021

View File

@ -18,13 +18,15 @@
package me.proton.android.core.coreexample.di package me.proton.android.core.coreexample.di
import dagger.Binds
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import dagger.hilt.InstallIn import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent import dagger.hilt.components.SingletonComponent
import me.proton.core.network.data.ApiProvider import me.proton.core.network.data.ApiProvider
import me.proton.core.plan.data.repository.PlansRepositoryImpl import me.proton.core.plan.data.repository.PlansRepositoryImpl
import me.proton.core.plan.domain.SupportedPaidPlans import me.proton.core.plan.domain.SupportedSignupPaidPlans
import me.proton.core.plan.domain.SupportedUpgradePaidPlans
import me.proton.core.plan.domain.repository.PlansRepository import me.proton.core.plan.domain.repository.PlansRepository
import javax.inject.Singleton import javax.inject.Singleton
@ -33,7 +35,7 @@ import javax.inject.Singleton
object PlansModule { object PlansModule {
@Provides @Provides
@SupportedPaidPlans @SupportedSignupPaidPlans
fun provideClientSupportedPaidPlanNames(): List<String> = fun provideClientSupportedPaidPlanNames(): List<String> =
listOf("plus") listOf("plus")
@ -42,3 +44,11 @@ object PlansModule {
fun providePlansRepository(apiProvider: ApiProvider): PlansRepository = fun providePlansRepository(apiProvider: ApiProvider): PlansRepository =
PlansRepositoryImpl(provider = apiProvider) PlansRepositoryImpl(provider = apiProvider)
} }
@Module
@InstallIn(SingletonComponent::class)
interface PlansBindsModule {
@Binds
@SupportedUpgradePaidPlans
fun bindClientSupportedUpgradePaidPlanNames(@SupportedSignupPaidPlans plans: List<String>): List<String>
}

View File

@ -23,7 +23,7 @@ plugins {
kotlin("android") kotlin("android")
} }
libVersion = Version(1, 18, 2) libVersion = Version(1, 18, 3)
android() android()

View File

@ -20,6 +20,16 @@ package me.proton.core.plan.domain
import javax.inject.Qualifier import javax.inject.Qualifier
/**
* Plans supported in signup.
*/
@Qualifier @Qualifier
@Retention(AnnotationRetention.BINARY) @Retention(AnnotationRetention.BINARY)
annotation class SupportedPaidPlans annotation class SupportedSignupPaidPlans
/**
* Plans supported in plan upgrade flow.
*/
@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class SupportedUpgradePaidPlans

View File

@ -24,21 +24,16 @@ import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import me.proton.core.domain.entity.UserId
import me.proton.core.payment.domain.entity.SubscriptionCycle
import me.proton.core.payment.presentation.PaymentsOrchestrator import me.proton.core.payment.presentation.PaymentsOrchestrator
import me.proton.core.payment.presentation.onPaymentResult import me.proton.core.plan.domain.SupportedSignupPaidPlans
import me.proton.core.plan.domain.SupportedPaidPlans
import me.proton.core.plan.domain.usecase.GetPlans import me.proton.core.plan.domain.usecase.GetPlans
import me.proton.core.plan.presentation.entity.PlanDetailsListItem import me.proton.core.plan.presentation.entity.PlanDetailsListItem
import me.proton.core.plan.presentation.entity.SelectedPlan
import javax.inject.Inject import javax.inject.Inject
@HiltViewModel @HiltViewModel
internal class SignupPlansViewModel @Inject constructor( internal class SignupPlansViewModel @Inject constructor(
private val getPlans: GetPlans, private val getPlans: GetPlans,
@SupportedPaidPlans val supportedPaidPlanNames: List<String>, @SupportedSignupPaidPlans val supportedPaidPlanNames: List<String>,
paymentsOrchestrator: PaymentsOrchestrator paymentsOrchestrator: PaymentsOrchestrator
) : BasePlansViewModel(paymentsOrchestrator) { ) : BasePlansViewModel(paymentsOrchestrator) {

View File

@ -26,19 +26,15 @@ import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import me.proton.core.domain.entity.UserId import me.proton.core.domain.entity.UserId
import me.proton.core.payment.domain.entity.SubscriptionCycle
import me.proton.core.payment.domain.usecase.GetCurrentSubscription import me.proton.core.payment.domain.usecase.GetCurrentSubscription
import me.proton.core.payment.presentation.PaymentsOrchestrator import me.proton.core.payment.presentation.PaymentsOrchestrator
import me.proton.core.payment.presentation.onPaymentResult import me.proton.core.plan.domain.SupportedUpgradePaidPlans
import me.proton.core.plan.domain.SupportedPaidPlans
import me.proton.core.plan.domain.usecase.GetPlans import me.proton.core.plan.domain.usecase.GetPlans
import me.proton.core.plan.presentation.entity.PlanCurrency import me.proton.core.plan.presentation.entity.PlanCurrency
import me.proton.core.plan.presentation.entity.PlanDetailsListItem import me.proton.core.plan.presentation.entity.PlanDetailsListItem
import me.proton.core.plan.presentation.entity.PlanPricing import me.proton.core.plan.presentation.entity.PlanPricing
import me.proton.core.plan.presentation.entity.PlanType import me.proton.core.plan.presentation.entity.PlanType
import me.proton.core.plan.presentation.entity.SelectedPlan
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Calendar import java.util.Calendar
import java.util.Locale import java.util.Locale
@ -48,7 +44,7 @@ import javax.inject.Inject
internal class UpgradePlansViewModel @Inject constructor( internal class UpgradePlansViewModel @Inject constructor(
private val getPlans: GetPlans, private val getPlans: GetPlans,
private val getCurrentSubscription: GetCurrentSubscription, private val getCurrentSubscription: GetCurrentSubscription,
@SupportedPaidPlans val supportedPaidPlanNames: List<String>, @SupportedUpgradePaidPlans val supportedPaidPlanNames: List<String>,
paymentsOrchestrator: PaymentsOrchestrator paymentsOrchestrator: PaymentsOrchestrator
) : BasePlansViewModel(paymentsOrchestrator) { ) : BasePlansViewModel(paymentsOrchestrator) {