Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Assume that QA builds are Pro entitled #1971

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
package app.tivi.entitlements

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flowOf

interface EntitlementManager {
fun setup() = Unit
suspend fun hasProEntitlement(): Boolean = false
fun observeProEntitlement(): Flow<Boolean> = emptyFlow()
suspend fun hasProEntitlement(): Boolean
fun observeProEntitlement(): Flow<Boolean>

companion object {
val Always: EntitlementManager = object : EntitlementManager {
override suspend fun hasProEntitlement(): Boolean = true
override fun observeProEntitlement(): Flow<Boolean> = flowOf(true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

package app.tivi.entitlements

import app.tivi.inject.ApplicationScope
import me.tatarka.inject.annotations.Provides

actual interface EntitlementsPlatformComponent {
@ApplicationScope
@Provides
fun bindEntitlementManager(): EntitlementManager = object : EntitlementManager {}
fun bindEntitlementManager(): EntitlementManager = EntitlementManager.Always
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

package app.tivi.entitlements

import app.tivi.app.ApplicationInfo
import app.tivi.app.Flavor
import app.tivi.appinitializers.AppInitializer
import app.tivi.inject.ApplicationScope
import me.tatarka.inject.annotations.IntoSet
Expand All @@ -11,7 +13,15 @@ import me.tatarka.inject.annotations.Provides
actual interface EntitlementsPlatformComponent {
@ApplicationScope
@Provides
fun bindEntitlementManager(impl: RevenueCatEntitlementManager): EntitlementManager = impl
fun provideEntitlementManager(
applicationInfo: ApplicationInfo,
revenueCatImpl: () -> RevenueCatEntitlementManager,
): EntitlementManager = when (applicationInfo.flavor) {
// QA builds use different package/bundle ids so we can't use IAPs. Assume that QA == Pro
Flavor.Qa -> EntitlementManager.Always
// For standard build, we can use IAPs
Flavor.Standard -> revenueCatImpl()
}

@Provides
@IntoSet
Expand Down
Loading