diff options
Diffstat (limited to 'android/lib')
51 files changed, 1616 insertions, 22 deletions
diff --git a/android/lib/billing/build.gradle.kts b/android/lib/billing/build.gradle.kts new file mode 100644 index 0000000000..255459f453 --- /dev/null +++ b/android/lib/billing/build.gradle.kts @@ -0,0 +1,76 @@ +plugins { + id(Dependencies.Plugin.androidLibraryId) + id(Dependencies.Plugin.kotlinAndroidId) +} + +android { + namespace = "net.mullvad.mullvadvpn.lib.billing" + compileSdk = Versions.Android.compileSdkVersion + + defaultConfig { + minSdk = Versions.Android.minSdkVersion + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = Versions.jvmTarget + } + + lint { + lintConfig = file("${rootProject.projectDir}/config/lint.xml") + abortOnError = true + warningsAsErrors = true + } + + packaging { + resources { + pickFirsts += setOf( + // Fixes packaging error caused by: jetified-junit-* + "META-INF/LICENSE.md", + "META-INF/LICENSE-notice.md" + ) + } + } +} + +dependencies { + implementation(Dependencies.Kotlin.stdlib) + implementation(Dependencies.KotlinX.coroutinesAndroid) + + implementation(Dependencies.Koin.core) + implementation(Dependencies.Koin.android) + + //Billing library + implementation(Dependencies.billingClient) + + //Model + implementation(project(Dependencies.Mullvad.modelLib)) + + //IPC + implementation(project(Dependencies.Mullvad.ipcLib)) + + //Payment library + implementation(project(Dependencies.Mullvad.paymentLib)) + + // Test dependencies + testImplementation(project(Dependencies.Mullvad.commonTestLib)) + testImplementation(Dependencies.Kotlin.test) + testImplementation(Dependencies.KotlinX.coroutinesTest) + testImplementation(Dependencies.MockK.core) + testImplementation(Dependencies.junit) + testImplementation(Dependencies.turbine) + + androidTestImplementation(project(Dependencies.Mullvad.commonTestLib)) + androidTestImplementation(Dependencies.MockK.android) + androidTestImplementation(Dependencies.Kotlin.test) + androidTestImplementation(Dependencies.KotlinX.coroutinesTest) + androidTestImplementation(Dependencies.turbine) + androidTestImplementation(Dependencies.junit) + androidTestImplementation(Dependencies.AndroidX.espressoContrib) + androidTestImplementation(Dependencies.AndroidX.espressoCore) +} diff --git a/android/lib/billing/src/androidTest/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepositoryTest.kt b/android/lib/billing/src/androidTest/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepositoryTest.kt new file mode 100644 index 0000000000..85982007b8 --- /dev/null +++ b/android/lib/billing/src/androidTest/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepositoryTest.kt @@ -0,0 +1,388 @@ +package net.mullvad.mullvadvpn.lib.billing + +import android.app.Activity +import android.content.Context +import app.cash.turbine.test +import com.android.billingclient.api.BillingClient +import com.android.billingclient.api.BillingClient.BillingResponseCode +import com.android.billingclient.api.BillingClientStateListener +import com.android.billingclient.api.BillingFlowParams +import com.android.billingclient.api.BillingResult +import com.android.billingclient.api.ProductDetails +import com.android.billingclient.api.ProductDetailsResult +import com.android.billingclient.api.Purchase +import com.android.billingclient.api.PurchasesResult +import com.android.billingclient.api.PurchasesUpdatedListener +import com.android.billingclient.api.QueryPurchasesParams +import com.android.billingclient.api.queryProductDetails +import com.android.billingclient.api.queryPurchasesAsync +import io.mockk.CapturingSlot +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.every +import io.mockk.mockk +import io.mockk.mockkStatic +import io.mockk.unmockkAll +import io.mockk.verify +import kotlin.test.assertEquals +import kotlin.test.assertIs +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.launch +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.runTest +import net.mullvad.mullvadvpn.lib.billing.model.BillingException +import net.mullvad.mullvadvpn.lib.billing.model.PurchaseEvent +import net.mullvad.mullvadvpn.lib.common.test.TestCoroutineRule +import net.mullvad.mullvadvpn.lib.common.test.assertLists +import org.junit.After +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.koin.core.context.startKoin +import org.koin.core.context.stopKoin +import org.koin.dsl.module + +class BillingRepositoryTest { + @get:Rule val testCoroutineRule = TestCoroutineRule() + + private val mockContext: Context = mockk() + private lateinit var billingRepository: BillingRepository + + private val mockBillingClientBuilder: BillingClient.Builder = mockk(relaxed = true) + private val mockBillingClient: BillingClient = mockk() + + private val purchaseUpdatedListenerSlot: CapturingSlot<PurchasesUpdatedListener> = + CapturingSlot() + + @Before + fun setUp() { + startKoin { modules(module { single { mockk<Activity>() } }) } + + mockkStatic(BILLING_CLIENT_CLASS) + mockkStatic(BILLING_CLIENT_KOTLIN_CLASS) + mockkStatic(BILLING_FLOW_PARAMS) + + every { BillingClient.newBuilder(any()) } returns mockBillingClientBuilder + every { mockBillingClientBuilder.enablePendingPurchases() } returns mockBillingClientBuilder + every { mockBillingClientBuilder.setListener(capture(purchaseUpdatedListenerSlot)) } returns + mockBillingClientBuilder + every { mockBillingClientBuilder.build() } returns mockBillingClient + + billingRepository = BillingRepository(mockContext) + } + + @After + fun tearDown() { + unmockkAll() + stopKoin() + } + + @Test + fun testQueryProductsOk() = runTest { + // Arrange + val mockBillingResult: BillingResult = mockk() + val mockProductDetails: ProductDetails = mockk() + val expectedProductDetailsResult: ProductDetailsResult = mockk() + val productId = "TEST" + val price = "44.4" + + every { mockBillingResult.responseCode } returns BillingResponseCode.OK + every { mockBillingClient.isReady } returns true + every { mockBillingClient.connectionState } returns BillingClient.ConnectionState.CONNECTED + coEvery { mockBillingClient.queryProductDetails(any()) } returns + expectedProductDetailsResult + every { expectedProductDetailsResult.billingResult } returns mockBillingResult + every { expectedProductDetailsResult.productDetailsList } returns listOf(mockProductDetails) + every { mockProductDetails.productId } returns productId + every { mockProductDetails.oneTimePurchaseOfferDetails?.formattedPrice } returns price + + // Act + val result = billingRepository.queryProducts(listOf(productId)) + + // Assert + assertEquals(expectedProductDetailsResult, result) + } + + @Test + fun testQueryProductsItemUnavailable() = runTest { + // Arrange + val mockBillingResult: BillingResult = mockk() + val mockProductDetailsResult: ProductDetailsResult = mockk() + + every { mockBillingResult.responseCode } returns BillingResponseCode.ITEM_UNAVAILABLE + every { mockBillingClient.isReady } returns true + every { mockBillingClient.connectionState } returns BillingClient.ConnectionState.CONNECTED + coEvery { mockBillingClient.queryProductDetails(any()) } returns mockProductDetailsResult + every { mockProductDetailsResult.billingResult } returns mockBillingResult + every { mockProductDetailsResult.productDetailsList } returns emptyList() + + // Act + val result = billingRepository.queryProducts(listOf("TEST")) + + // Assert + assertEquals(mockProductDetailsResult, result) + } + + @Test + fun testQueryProductsBillingUnavailable() = runTest { + // Arrange + val mockBillingResult: BillingResult = mockk() + val mockProductDetailsResult: ProductDetailsResult = mockk() + + every { mockBillingResult.responseCode } returns BillingResponseCode.BILLING_UNAVAILABLE + every { mockBillingClient.isReady } returns true + every { mockBillingClient.connectionState } returns BillingClient.ConnectionState.CONNECTED + coEvery { mockBillingClient.queryProductDetails(any()) } returns mockProductDetailsResult + every { mockProductDetailsResult.billingResult } returns mockBillingResult + every { mockProductDetailsResult.productDetailsList } returns emptyList() + + // Act + val result = billingRepository.queryProducts(listOf("TEST")) + + // Assert + assertEquals(mockProductDetailsResult, result) + } + + @Test + fun testStartPurchaseFlowOk() = runTest { + // Arrange + val mockProductBillingResult: BillingResult = mockk() + val mockBillingResult: BillingResult = mockk() + val transactionId = "MOCK22" + val mockProductDetails: ProductDetails = mockk(relaxed = true) + val mockActivityProvider: () -> Activity = mockk() + every { mockBillingResult.responseCode } returns BillingResponseCode.OK + every { mockBillingClient.isReady } returns true + every { mockBillingClient.connectionState } returns BillingClient.ConnectionState.CONNECTED + every { mockBillingClient.launchBillingFlow(any(), any()) } returns mockBillingResult + every { BillingFlowParams.newBuilder() } returns mockk(relaxed = true) + every { mockProductBillingResult.responseCode } returns BillingResponseCode.OK + every { mockActivityProvider() } returns mockk() + + // Act + val result = + billingRepository.startPurchaseFlow( + mockProductDetails, + transactionId, + mockActivityProvider + ) + + // Assert + assertEquals(mockBillingResult, result) + } + + @Test + fun testStartPurchaseFlowBillingUnavailable() = runTest { + // Arrange + val mockBillingResult: BillingResult = mockk() + val transactionId = "MOCK22" + val mockProductDetails: ProductDetails = mockk(relaxed = true) + val mockActivityProvider: () -> Activity = mockk() + every { mockBillingResult.responseCode } returns BillingResponseCode.BILLING_UNAVAILABLE + every { mockBillingClient.isReady } returns true + every { mockBillingClient.connectionState } returns BillingClient.ConnectionState.CONNECTED + every { mockBillingClient.launchBillingFlow(any(), any()) } returns mockBillingResult + every { BillingFlowParams.newBuilder() } returns mockk(relaxed = true) + every { mockActivityProvider() } returns mockk() + + // Act + val result = + billingRepository.startPurchaseFlow( + mockProductDetails, + transactionId, + mockActivityProvider + ) + + // Assert + assertEquals(mockBillingResult, result) + } + + @Test + fun testQueryPurchasesFoundPurchases() = runTest { + // Arrange + val mockResult: PurchasesResult = mockk() + val mockPurchase: Purchase = mockk() + every { mockResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockResult.purchasesList } returns listOf(mockPurchase) + every { mockBillingClient.isReady } returns true + every { mockBillingClient.connectionState } returns BillingClient.ConnectionState.CONNECTED + coEvery { mockBillingClient.queryPurchasesAsync(any<QueryPurchasesParams>()) } returns + mockResult + every { BillingFlowParams.newBuilder() } returns mockk(relaxed = true) + + // Act + val result = billingRepository.queryPurchases() + + // Assert + assertEquals(mockResult, result) + } + + @Test + fun testQueryPurchasesNoPurchaseFound() = runTest { + // Arrange + val mockResult: PurchasesResult = mockk() + every { mockResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockResult.purchasesList } returns emptyList() + every { mockBillingClient.isReady } returns true + every { mockBillingClient.connectionState } returns BillingClient.ConnectionState.CONNECTED + coEvery { mockBillingClient.queryPurchasesAsync(any<QueryPurchasesParams>()) } returns + mockResult + every { BillingFlowParams.newBuilder() } returns mockk(relaxed = true) + + // Act + val result = billingRepository.queryPurchases() + + // Assert + assertEquals(mockResult, result) + } + + @Test + fun testQueryPurchasesError() = runTest { + // Arrange + val responseCode = BillingResponseCode.ITEM_UNAVAILABLE + val message = "ERROR" + val expectedError = BillingException(responseCode, message) + val mockResult: PurchasesResult = mockk() + every { mockResult.billingResult.responseCode } returns responseCode + every { mockResult.billingResult.debugMessage } returns message + every { mockResult.purchasesList } returns emptyList() + every { mockBillingClient.isReady } returns true + every { mockBillingClient.connectionState } returns BillingClient.ConnectionState.CONNECTED + coEvery { mockBillingClient.queryPurchasesAsync(any<QueryPurchasesParams>()) } returns + mockResult + every { BillingFlowParams.newBuilder() } returns mockk(relaxed = true) + + // Act + val result = billingRepository.queryPurchases() + + // Assert + assertEquals( + expectedError.toBillingResult().responseCode, + result.billingResult.responseCode + ) + assertEquals(expectedError.message, result.billingResult.debugMessage) + } + + @Test + fun testPurchaseEventPurchaseComplete() = runTest { + // Arrange + val mockPurchase: Purchase = mockk() + val mockPurchaseList = listOf(mockPurchase) + val mockBillingResult: BillingResult = mockk() + every { mockBillingResult.responseCode } returns BillingResponseCode.OK + + // Act, Assert + billingRepository.purchaseEvents.test { + purchaseUpdatedListenerSlot.captured.onPurchasesUpdated( + mockBillingResult, + mockPurchaseList + ) + val result = awaitItem() + assertIs<PurchaseEvent.Completed>(result) + assertLists(mockPurchaseList, result.purchases) + } + } + + @Test + fun testPurchaseEventUserCanceled() = runTest { + // Arrange + val mockBillingResult: BillingResult = mockk() + val mockResponseCode: Int = BillingResponseCode.USER_CANCELED + every { mockBillingResult.responseCode } returns mockResponseCode + + // Act, Assert + billingRepository.purchaseEvents.test { + purchaseUpdatedListenerSlot.captured.onPurchasesUpdated(mockBillingResult, null) + val result = awaitItem() + assertIs<PurchaseEvent.UserCanceled>(result) + } + } + + @Test + fun testPurchaseEventError() = runTest { + // Arrange + val mockDebugMessage = "ERROR" + val mockBillingResult: BillingResult = mockk() + val mockResponseCode: Int = BillingResponseCode.ERROR + val expectedError = + BillingException(responseCode = mockResponseCode, message = mockDebugMessage) + every { mockBillingResult.responseCode } returns mockResponseCode + every { mockBillingResult.debugMessage } returns mockDebugMessage + + // Act, Assert + billingRepository.purchaseEvents.test { + purchaseUpdatedListenerSlot.captured.onPurchasesUpdated(mockBillingResult, null) + val result = awaitItem() + assertIs<PurchaseEvent.Error>(result) + assertEquals(expectedError.message, result.exception.message) + } + } + + @Test + fun testEnsureConnectedStartConnection() = runTest { + // Arrange + val mockStartConnectionResult: BillingResult = mockk() + every { mockBillingClient.isReady } returns false + every { mockBillingClient.connectionState } returns + BillingClient.ConnectionState.DISCONNECTED + every { mockBillingClient.startConnection(any()) } answers + { + firstArg<BillingClientStateListener>() + .onBillingSetupFinished(mockStartConnectionResult) + } + every { mockStartConnectionResult.responseCode } returns BillingResponseCode.OK + coEvery { mockBillingClient.queryPurchasesAsync(any<QueryPurchasesParams>()) } returns + mockk(relaxed = true) + + // Act + billingRepository.queryPurchases() + + // Assert + verify { mockBillingClient.startConnection(any()) } + coVerify { mockBillingClient.queryPurchasesAsync(any<QueryPurchasesParams>()) } + } + + @OptIn(ExperimentalCoroutinesApi::class) + @Test + fun testEnsureConnectedOnlyOneSuccessfulConnection() = + runTest(UnconfinedTestDispatcher()) { + // Arrange + var hasConnected = false + val mockStartConnectionResult: BillingResult = mockk() + every { mockBillingClient.isReady } answers { hasConnected } + every { mockBillingClient.connectionState } answers + { + if (hasConnected) { + BillingClient.ConnectionState.CONNECTED + } else { + BillingClient.ConnectionState.DISCONNECTED + } + } + every { mockBillingClient.startConnection(any()) } answers + { + hasConnected = true + firstArg<BillingClientStateListener>() + .onBillingSetupFinished(mockStartConnectionResult) + } + every { mockStartConnectionResult.responseCode } returns BillingResponseCode.OK + coEvery { mockBillingClient.queryPurchasesAsync(any<QueryPurchasesParams>()) } returns + mockk(relaxed = true) + coEvery { mockBillingClient.queryProductDetails(any()) } returns mockk(relaxed = true) + + // Act + launch { billingRepository.queryPurchases() } + launch { billingRepository.queryProducts(listOf("MOCK")) } + + // Assert + verify(exactly = 1) { mockBillingClient.startConnection(any()) } + coVerify { mockBillingClient.queryPurchasesAsync(any<QueryPurchasesParams>()) } + coVerify { mockBillingClient.queryProductDetails(any()) } + } + + companion object { + private const val BILLING_CLIENT_CLASS = "com.android.billingclient.api.BillingClient" + private const val BILLING_CLIENT_KOTLIN_CLASS = + "com.android.billingclient.api.BillingClientKotlinKt" + private const val BILLING_FLOW_PARAMS = "com.android.billingclient.api.BillingFlowParams" + } +} diff --git a/android/lib/billing/src/main/AndroidManifest.xml b/android/lib/billing/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..b2d3ea1235 --- /dev/null +++ b/android/lib/billing/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" /> diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepository.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepository.kt new file mode 100644 index 0000000000..76df623ada --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepository.kt @@ -0,0 +1,167 @@ +package net.mullvad.mullvadvpn.lib.billing + +import android.app.Activity +import com.android.billingclient.api.BillingClient.BillingResponseCode +import com.android.billingclient.api.Purchase +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.firstOrNull +import kotlinx.coroutines.flow.flow +import net.mullvad.mullvadvpn.lib.billing.extension.getProductDetails +import net.mullvad.mullvadvpn.lib.billing.extension.nonPendingPurchases +import net.mullvad.mullvadvpn.lib.billing.extension.responseCode +import net.mullvad.mullvadvpn.lib.billing.extension.toBillingException +import net.mullvad.mullvadvpn.lib.billing.extension.toPaymentAvailability +import net.mullvad.mullvadvpn.lib.billing.extension.toPaymentStatus +import net.mullvad.mullvadvpn.lib.billing.extension.toPurchaseResult +import net.mullvad.mullvadvpn.lib.billing.model.BillingException +import net.mullvad.mullvadvpn.lib.billing.model.PurchaseEvent +import net.mullvad.mullvadvpn.lib.payment.PaymentRepository +import net.mullvad.mullvadvpn.lib.payment.ProductIds +import net.mullvad.mullvadvpn.lib.payment.model.PaymentAvailability +import net.mullvad.mullvadvpn.lib.payment.model.ProductId +import net.mullvad.mullvadvpn.lib.payment.model.PurchaseResult +import net.mullvad.mullvadvpn.lib.payment.model.VerificationResult +import net.mullvad.mullvadvpn.model.PlayPurchase +import net.mullvad.mullvadvpn.model.PlayPurchaseInitResult +import net.mullvad.mullvadvpn.model.PlayPurchaseVerifyResult + +class BillingPaymentRepository( + private val billingRepository: BillingRepository, + private val playPurchaseRepository: PlayPurchaseRepository +) : PaymentRepository { + + override fun queryPaymentAvailability(): Flow<PaymentAvailability> = flow { + emit(PaymentAvailability.Loading) + val purchases = billingRepository.queryPurchases() + val productIdToPaymentStatus = + purchases.purchasesList + .filter { it.products.isNotEmpty() } + .associate { it.products.first() to it.purchaseState.toPaymentStatus() } + emit( + billingRepository + .queryProducts(listOf(ProductIds.OneMonth)) + .toPaymentAvailability(productIdToPaymentStatus) + ) + } + + override fun purchaseProduct( + productId: ProductId, + activityProvider: () -> Activity + ): Flow<PurchaseResult> = flow { + emit(PurchaseResult.FetchingProducts) + + val productDetailsResult = billingRepository.queryProducts(listOf(productId.value)) + + val productDetails = + when (productDetailsResult.responseCode()) { + BillingResponseCode.OK -> { + productDetailsResult.getProductDetails(productId.value) + ?: run { + emit(PurchaseResult.Error.NoProductFound(productId)) + return@flow + } + } + else -> { + emit( + PurchaseResult.Error.FetchProductsError( + productId, + productDetailsResult.toBillingException() + ) + ) + return@flow + } + } + + // Get transaction id + emit(PurchaseResult.FetchingObfuscationId) + val obfuscatedId: String = + when (val result = initialisePurchase()) { + is PlayPurchaseInitResult.Ok -> result.obfuscatedId + else -> { + emit(PurchaseResult.Error.TransactionIdError(productId, null)) + return@flow + } + } + + val result = + billingRepository.startPurchaseFlow( + productDetails = productDetails, + obfuscatedId = obfuscatedId, + activityProvider = activityProvider + ) + + if (result.responseCode == BillingResponseCode.OK) { + emit(PurchaseResult.BillingFlowStarted) + } else { + emit( + PurchaseResult.Error.BillingError( + BillingException(result.responseCode, result.debugMessage) + ) + ) + return@flow + } + + // Wait for a callback from the billing library + when (val event = billingRepository.purchaseEvents.firstOrNull()) { + is PurchaseEvent.Error -> emit(event.toPurchaseResult()) + is PurchaseEvent.Completed -> { + val purchase = + event.purchases.firstOrNull() + ?: run { + emit(PurchaseResult.Error.BillingError(null)) + return@flow + } + if (purchase.purchaseState == Purchase.PurchaseState.PENDING) { + emit(PurchaseResult.Completed.Pending) + } else { + emit(PurchaseResult.VerificationStarted) + if (verifyPurchase(event.purchases.first()) == PlayPurchaseVerifyResult.Ok) { + emit(PurchaseResult.Completed.Success) + } else { + emit(PurchaseResult.Error.VerificationError(null)) + } + } + } + PurchaseEvent.UserCanceled -> emit(event.toPurchaseResult()) + else -> emit(PurchaseResult.Error.BillingError(null)) + } + } + + override fun verifyPurchases(): Flow<VerificationResult> = flow { + emit(VerificationResult.FetchingUnfinishedPurchases) + val purchasesResult = billingRepository.queryPurchases() + when (purchasesResult.responseCode()) { + BillingResponseCode.OK -> { + val purchases = purchasesResult.nonPendingPurchases() + if (purchases.isNotEmpty()) { + emit(VerificationResult.VerificationStarted) + val verificationResult = verifyPurchase(purchases.first()) + emit( + when (verificationResult) { + is PlayPurchaseVerifyResult.Error -> + VerificationResult.Error.VerificationError(null) + PlayPurchaseVerifyResult.Ok -> VerificationResult.Success + } + ) + } else { + emit(VerificationResult.NothingToVerify) + } + } + else -> + emit(VerificationResult.Error.BillingError(purchasesResult.toBillingException())) + } + } + + private suspend fun initialisePurchase(): PlayPurchaseInitResult { + return playPurchaseRepository.initializePlayPurchase() + } + + private suspend fun verifyPurchase(purchase: Purchase): PlayPurchaseVerifyResult { + return playPurchaseRepository.verifyPlayPurchase( + PlayPurchase( + productId = purchase.products.first(), + purchaseToken = purchase.purchaseToken, + ) + ) + } +} diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepository.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepository.kt new file mode 100644 index 0000000000..6274f8cb6f --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepository.kt @@ -0,0 +1,194 @@ +package net.mullvad.mullvadvpn.lib.billing + +import android.app.Activity +import android.content.Context +import com.android.billingclient.api.BillingClient +import com.android.billingclient.api.BillingClient.BillingResponseCode +import com.android.billingclient.api.BillingClientStateListener +import com.android.billingclient.api.BillingFlowParams +import com.android.billingclient.api.BillingResult +import com.android.billingclient.api.ProductDetails +import com.android.billingclient.api.ProductDetailsResult +import com.android.billingclient.api.PurchasesResult +import com.android.billingclient.api.PurchasesUpdatedListener +import com.android.billingclient.api.QueryProductDetailsParams +import com.android.billingclient.api.QueryProductDetailsParams.Product +import com.android.billingclient.api.QueryPurchasesParams +import com.android.billingclient.api.queryProductDetails +import com.android.billingclient.api.queryPurchasesAsync +import kotlin.coroutines.Continuation +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException +import kotlin.coroutines.suspendCoroutine +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock +import net.mullvad.mullvadvpn.lib.billing.model.BillingException +import net.mullvad.mullvadvpn.lib.billing.model.PurchaseEvent + +class BillingRepository(context: Context) { + + private val billingClient: BillingClient + + private val purchaseUpdateListener: PurchasesUpdatedListener = + PurchasesUpdatedListener { result, purchases -> + when (result.responseCode) { + BillingResponseCode.OK -> { + _purchaseEvents.tryEmit( + PurchaseEvent.Completed(purchases?.toList() ?: emptyList()) + ) + } + BillingResponseCode.USER_CANCELED -> { + _purchaseEvents.tryEmit(PurchaseEvent.UserCanceled) + } + else -> { + _purchaseEvents.tryEmit( + PurchaseEvent.Error( + exception = + BillingException( + responseCode = result.responseCode, + message = result.debugMessage + ) + ) + ) + } + } + } + + private val _purchaseEvents = MutableSharedFlow<PurchaseEvent>(extraBufferCapacity = 1) + val purchaseEvents = _purchaseEvents.asSharedFlow() + + init { + billingClient = + BillingClient.newBuilder(context) + .enablePendingPurchases() + .setListener(purchaseUpdateListener) + .build() + } + + private val ensureConnectedMutex = Mutex() + + private suspend fun ensureConnected() = + ensureConnectedMutex.withLock { + suspendCoroutine { + if ( + billingClient.isReady && + billingClient.connectionState == BillingClient.ConnectionState.CONNECTED + ) { + it.resume(Unit) + } else { + startConnection(it) + } + } + } + + private fun startConnection(continuation: Continuation<Unit>) { + billingClient.startConnection( + object : BillingClientStateListener { + override fun onBillingServiceDisconnected() { + // Maybe do something here? + continuation.resumeWithException( + BillingException( + BillingResponseCode.SERVICE_DISCONNECTED, + "Billing service disconnected" + ) + ) + } + + override fun onBillingSetupFinished(result: BillingResult) { + if (result.responseCode == BillingResponseCode.OK) { + continuation.resume(Unit) + } else { + continuation.resumeWithException( + BillingException(result.responseCode, result.debugMessage) + ) + } + } + } + ) + } + + suspend fun queryProducts(productIds: List<String>): ProductDetailsResult { + return queryProductDetails(productIds) + } + + suspend fun startPurchaseFlow( + productDetails: ProductDetails, + obfuscatedId: String, + activityProvider: () -> Activity + ): BillingResult { + return try { + ensureConnected() + + val productDetailsParamsList = + listOf( + BillingFlowParams.ProductDetailsParams.newBuilder() + .setProductDetails(productDetails) + .build() + ) + + val billingFlowParams = + BillingFlowParams.newBuilder() + .setProductDetailsParamsList(productDetailsParamsList) + .setObfuscatedAccountId(obfuscatedId) + .build() + + val activity = activityProvider() + // Launch the billing flow + billingClient.launchBillingFlow(activity, billingFlowParams) + } catch (t: Throwable) { + if (t is BillingException) { + t.toBillingResult() + } else { + throw t + } + } + } + + suspend fun queryPurchases(): PurchasesResult { + return try { + ensureConnected() + + val queryPurchaseHistoryParams: QueryPurchasesParams = + QueryPurchasesParams.newBuilder() + .setProductType(BillingClient.ProductType.INAPP) + .build() + + billingClient.queryPurchasesAsync(queryPurchaseHistoryParams) + } catch (t: Throwable) { + if (t is BillingException) { + t.toPurchasesResult() + } else { + throw t + } + } + } + + private suspend fun queryProductDetails(productIds: List<String>): ProductDetailsResult { + return try { + ensureConnected() + + val productList = + productIds.map { productId -> + Product.newBuilder() + .setProductId(productId) + .setProductType(BillingClient.ProductType.INAPP) + .build() + } + val params = QueryProductDetailsParams.newBuilder() + params.setProductList(productList) + + billingClient.queryProductDetails(params.build()) + } catch (t: Throwable) { + if (t is BillingException) { + return ProductDetailsResult(t.toBillingResult(), null) + } else { + return ProductDetailsResult( + BillingResult.newBuilder().setResponseCode(BillingResponseCode.ERROR).build(), + null + ) + } + } + } +} diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/PlayPurchaseRepository.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/PlayPurchaseRepository.kt new file mode 100644 index 0000000000..ac71372f76 --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/PlayPurchaseRepository.kt @@ -0,0 +1,33 @@ +package net.mullvad.mullvadvpn.lib.billing + +import kotlinx.coroutines.flow.first +import net.mullvad.mullvadvpn.lib.ipc.Event +import net.mullvad.mullvadvpn.lib.ipc.MessageHandler +import net.mullvad.mullvadvpn.lib.ipc.Request +import net.mullvad.mullvadvpn.lib.ipc.events +import net.mullvad.mullvadvpn.model.PlayPurchase +import net.mullvad.mullvadvpn.model.PlayPurchaseInitError +import net.mullvad.mullvadvpn.model.PlayPurchaseInitResult +import net.mullvad.mullvadvpn.model.PlayPurchaseVerifyError +import net.mullvad.mullvadvpn.model.PlayPurchaseVerifyResult + +class PlayPurchaseRepository(private val messageHandler: MessageHandler) { + suspend fun initializePlayPurchase(): PlayPurchaseInitResult { + val result = messageHandler.trySendRequest(Request.InitPlayPurchase) + + return if (result) { + messageHandler.events<Event.PlayPurchaseInitResultEvent>().first().result + } else { + PlayPurchaseInitResult.Error(PlayPurchaseInitError.OtherError) + } + } + + suspend fun verifyPlayPurchase(purchase: PlayPurchase): PlayPurchaseVerifyResult { + val result = messageHandler.trySendRequest(Request.VerifyPlayPurchase(purchase)) + return if (result) { + messageHandler.events<Event.PlayPurchaseVerifyResultEvent>().first().result + } else { + PlayPurchaseVerifyResult.Error(PlayPurchaseVerifyError.OtherError) + } + } +} diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/ProductDetailsResultExtensions.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/ProductDetailsResultExtensions.kt new file mode 100644 index 0000000000..3e4aee180a --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/ProductDetailsResultExtensions.kt @@ -0,0 +1,13 @@ +package net.mullvad.mullvadvpn.lib.billing.extension + +import com.android.billingclient.api.ProductDetails +import com.android.billingclient.api.ProductDetailsResult +import net.mullvad.mullvadvpn.lib.billing.model.BillingException + +fun ProductDetailsResult.getProductDetails(productId: String): ProductDetails? = + this.productDetailsList?.firstOrNull { it.productId == productId } + +fun ProductDetailsResult.responseCode(): Int = this.billingResult.responseCode + +fun ProductDetailsResult.toBillingException(): BillingException = + BillingException(responseCode = this.responseCode(), message = this.billingResult.debugMessage) diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/ProductDetailsResultToPaymentAvailability.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/ProductDetailsResultToPaymentAvailability.kt new file mode 100644 index 0000000000..37cc701724 --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/ProductDetailsResultToPaymentAvailability.kt @@ -0,0 +1,37 @@ +package net.mullvad.mullvadvpn.lib.billing.extension + +import com.android.billingclient.api.BillingClient +import com.android.billingclient.api.ProductDetailsResult +import net.mullvad.mullvadvpn.lib.billing.model.BillingException +import net.mullvad.mullvadvpn.lib.payment.model.PaymentAvailability +import net.mullvad.mullvadvpn.lib.payment.model.PaymentStatus + +fun ProductDetailsResult.toPaymentAvailability( + productIdToPaymentStatus: Map<String, PaymentStatus?> +) = + when (this.billingResult.responseCode) { + BillingClient.BillingResponseCode.OK -> { + val productDetailsList = this.productDetailsList + if (productDetailsList?.isNotEmpty() == true) { + PaymentAvailability.ProductsAvailable( + productDetailsList.toPaymentProducts(productIdToPaymentStatus) + ) + } else { + PaymentAvailability.NoProductsFounds + } + } + BillingClient.BillingResponseCode.BILLING_UNAVAILABLE -> + PaymentAvailability.Error.BillingUnavailable + BillingClient.BillingResponseCode.SERVICE_UNAVAILABLE -> + PaymentAvailability.Error.ServiceUnavailable + BillingClient.BillingResponseCode.DEVELOPER_ERROR -> + PaymentAvailability.Error.DeveloperError + BillingClient.BillingResponseCode.FEATURE_NOT_SUPPORTED -> + PaymentAvailability.Error.FeatureNotSupported + BillingClient.BillingResponseCode.ITEM_UNAVAILABLE -> + PaymentAvailability.Error.ItemUnavailable + else -> + PaymentAvailability.Error.Other( + BillingException(this.billingResult.responseCode, this.billingResult.debugMessage) + ) + } diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/ProductDetailsToPaymentProduct.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/ProductDetailsToPaymentProduct.kt new file mode 100644 index 0000000000..fa9a20613f --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/ProductDetailsToPaymentProduct.kt @@ -0,0 +1,17 @@ +package net.mullvad.mullvadvpn.lib.billing.extension + +import com.android.billingclient.api.ProductDetails +import net.mullvad.mullvadvpn.lib.payment.model.PaymentProduct +import net.mullvad.mullvadvpn.lib.payment.model.PaymentStatus +import net.mullvad.mullvadvpn.lib.payment.model.ProductId +import net.mullvad.mullvadvpn.lib.payment.model.ProductPrice + +fun ProductDetails.toPaymentProduct(productIdToStatus: Map<String, PaymentStatus?>) = + PaymentProduct( + productId = ProductId(this.productId), + price = ProductPrice(this.oneTimePurchaseOfferDetails?.formattedPrice ?: ""), + productIdToStatus[this.productId] + ) + +fun List<ProductDetails>.toPaymentProducts(productIdToStatus: Map<String, PaymentStatus?>) = + this.map { it.toPaymentProduct(productIdToStatus) } diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/PurchaseEventToPurchaseResult.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/PurchaseEventToPurchaseResult.kt new file mode 100644 index 0000000000..e0e4bf0a77 --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/PurchaseEventToPurchaseResult.kt @@ -0,0 +1,11 @@ +package net.mullvad.mullvadvpn.lib.billing.extension + +import net.mullvad.mullvadvpn.lib.billing.model.PurchaseEvent +import net.mullvad.mullvadvpn.lib.payment.model.PurchaseResult + +fun PurchaseEvent.toPurchaseResult() = + when (this) { + is PurchaseEvent.Error -> PurchaseResult.Error.BillingError(this.exception) + is PurchaseEvent.Completed -> PurchaseResult.VerificationStarted + PurchaseEvent.UserCanceled -> PurchaseResult.Completed.Cancelled + } diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/PurchaseStateToPaymentStatus.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/PurchaseStateToPaymentStatus.kt new file mode 100644 index 0000000000..701e5fde3d --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/PurchaseStateToPaymentStatus.kt @@ -0,0 +1,11 @@ +package net.mullvad.mullvadvpn.lib.billing.extension + +import com.android.billingclient.api.Purchase +import net.mullvad.mullvadvpn.lib.payment.model.PaymentStatus + +internal fun Int.toPaymentStatus(): PaymentStatus? = + when (this) { + Purchase.PurchaseState.PURCHASED -> PaymentStatus.VERIFICATION_IN_PROGRESS + Purchase.PurchaseState.PENDING -> PaymentStatus.PENDING + else -> null + } diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/PurchasesResultExtensions.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/PurchasesResultExtensions.kt new file mode 100644 index 0000000000..d76d1a8b7e --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/extension/PurchasesResultExtensions.kt @@ -0,0 +1,13 @@ +package net.mullvad.mullvadvpn.lib.billing.extension + +import com.android.billingclient.api.Purchase +import com.android.billingclient.api.PurchasesResult +import net.mullvad.mullvadvpn.lib.billing.model.BillingException + +fun PurchasesResult.nonPendingPurchases(): List<Purchase> = + this.purchasesList.filter { it.purchaseState != Purchase.PurchaseState.PENDING } + +fun PurchasesResult.responseCode(): Int = this.billingResult.responseCode + +fun PurchasesResult.toBillingException(): BillingException = + BillingException(responseCode = this.responseCode(), message = this.billingResult.debugMessage) diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/model/BillingException.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/model/BillingException.kt new file mode 100644 index 0000000000..08f6a89cca --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/model/BillingException.kt @@ -0,0 +1,15 @@ +package net.mullvad.mullvadvpn.lib.billing.model + +import com.android.billingclient.api.BillingResult +import com.android.billingclient.api.PurchasesResult + +class BillingException(private val responseCode: Int, message: String) : Throwable(message) { + + fun toBillingResult(): BillingResult = + BillingResult.newBuilder() + .setResponseCode(responseCode) + .setDebugMessage(message ?: "") + .build() + + fun toPurchasesResult(): PurchasesResult = PurchasesResult(toBillingResult(), emptyList()) +} diff --git a/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/model/PurchaseEvent.kt b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/model/PurchaseEvent.kt new file mode 100644 index 0000000000..b88f31cae6 --- /dev/null +++ b/android/lib/billing/src/main/kotlin/net/mullvad/mullvadvpn/lib/billing/model/PurchaseEvent.kt @@ -0,0 +1,11 @@ +package net.mullvad.mullvadvpn.lib.billing.model + +import com.android.billingclient.api.Purchase + +sealed interface PurchaseEvent { + data object UserCanceled : PurchaseEvent + + data class Error(val exception: BillingException) : PurchaseEvent + + data class Completed(val purchases: List<Purchase>) : PurchaseEvent +} diff --git a/android/lib/billing/src/test/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepositoryTest.kt b/android/lib/billing/src/test/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepositoryTest.kt new file mode 100644 index 0000000000..fe25457e49 --- /dev/null +++ b/android/lib/billing/src/test/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepositoryTest.kt @@ -0,0 +1,377 @@ +package net.mullvad.mullvadvpn.lib.billing + +import app.cash.turbine.test +import com.android.billingclient.api.BillingClient.BillingResponseCode +import com.android.billingclient.api.BillingResult +import com.android.billingclient.api.ProductDetails +import com.android.billingclient.api.ProductDetailsResult +import com.android.billingclient.api.Purchase +import io.mockk.coEvery +import io.mockk.every +import io.mockk.mockk +import io.mockk.mockkStatic +import kotlin.test.assertEquals +import kotlin.test.assertIs +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.test.runTest +import net.mullvad.mullvadvpn.lib.billing.extension.toPaymentProduct +import net.mullvad.mullvadvpn.lib.billing.model.PurchaseEvent +import net.mullvad.mullvadvpn.lib.common.test.TestCoroutineRule +import net.mullvad.mullvadvpn.lib.payment.model.PaymentAvailability +import net.mullvad.mullvadvpn.lib.payment.model.PaymentProduct +import net.mullvad.mullvadvpn.lib.payment.model.ProductId +import net.mullvad.mullvadvpn.lib.payment.model.PurchaseResult +import net.mullvad.mullvadvpn.model.PlayPurchaseInitError +import net.mullvad.mullvadvpn.model.PlayPurchaseInitResult +import net.mullvad.mullvadvpn.model.PlayPurchaseVerifyError +import net.mullvad.mullvadvpn.model.PlayPurchaseVerifyResult +import org.junit.Before +import org.junit.Rule +import org.junit.Test + +class BillingPaymentRepositoryTest { + @get:Rule val testCoroutineRule = TestCoroutineRule() + + private val mockBillingRepository: BillingRepository = mockk() + private val mockPlayPurchaseRepository: PlayPurchaseRepository = mockk() + + private val purchaseEventFlow = MutableSharedFlow<PurchaseEvent>(extraBufferCapacity = 1) + + private lateinit var paymentRepository: BillingPaymentRepository + + @Before + fun setUp() { + mockkStatic(PRODUCT_DETAILS_TO_PAYMENT_PRODUCT_EXT) + + every { mockBillingRepository.purchaseEvents } returns purchaseEventFlow + + paymentRepository = + BillingPaymentRepository( + billingRepository = mockBillingRepository, + playPurchaseRepository = mockPlayPurchaseRepository + ) + } + + @Test + fun testQueryAvailablePaymentProductsAvailable() = runTest { + // Arrange + val expectedProduct: PaymentProduct = mockk() + val mockProduct: ProductDetails = mockk() + val mockResult: ProductDetailsResult = mockk() + coEvery { mockBillingRepository.queryPurchases() } returns mockk(relaxed = true) + coEvery { mockBillingRepository.queryProducts(any()) } returns mockResult + every { mockProduct.toPaymentProduct(any()) } returns expectedProduct + every { mockResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockResult.productDetailsList } returns listOf(mockProduct) + + // Act, Assert + paymentRepository.queryPaymentAvailability().test { + // Loading + awaitItem() + val result = awaitItem() + assertIs<PaymentAvailability.ProductsAvailable>(result) + assertEquals(expectedProduct, result.products.first()) + awaitComplete() + } + } + + @Test + fun testQueryAvailablePaymentProductsUnavailable() = runTest { + // Arrange + val mockResult: ProductDetailsResult = mockk() + every { mockResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockResult.productDetailsList } returns emptyList() + coEvery { mockBillingRepository.queryPurchases() } returns mockk(relaxed = true) + coEvery { mockBillingRepository.queryProducts(any()) } returns mockResult + + // Act, Assert + paymentRepository.queryPaymentAvailability().test { + // Loading + awaitItem() + val result = awaitItem() + assertIs<PaymentAvailability.NoProductsFounds>(result) + awaitComplete() + } + } + + @Test + fun testQueryAvailablePaymentBillingUnavailableError() = runTest { + // Arrange + val mockResult: ProductDetailsResult = mockk() + every { mockResult.billingResult.responseCode } returns + BillingResponseCode.BILLING_UNAVAILABLE + coEvery { mockBillingRepository.queryPurchases() } returns mockk(relaxed = true) + coEvery { mockBillingRepository.queryProducts(any()) } returns mockResult + + // Act, Assert + paymentRepository.queryPaymentAvailability().test { + // Loading + awaitItem() + val result = awaitItem() + assertIs<PaymentAvailability.Error.BillingUnavailable>(result) + awaitComplete() + } + } + + @Test + fun testPurchaseBillingProductStartPurchaseFetchProductsError() = runTest { + // Arrange + val mockProductId = ProductId("MOCK") + val mockProductDetailsResult = mockk<ProductDetailsResult>() + every { mockProductDetailsResult.billingResult.responseCode } returns + BillingResponseCode.BILLING_UNAVAILABLE + every { mockProductDetailsResult.billingResult.debugMessage } returns "ERROR" + coEvery { mockBillingRepository.queryProducts(listOf(mockProductId.value)) } returns + mockProductDetailsResult + + // Act, Assert + paymentRepository.purchaseProduct(mockProductId, mockk()).test { + assertIs<PurchaseResult.FetchingProducts>(awaitItem()) + val result = awaitItem() + assertIs<PurchaseResult.Error.FetchProductsError>(result) + awaitComplete() + } + } + + @Test + fun testPurchaseBillingProductStartPurchaseNoProductsFoundError() = runTest { + // Arrange + val mockProductId = ProductId("MOCK") + val mockProductDetailsResult = mockk<ProductDetailsResult>() + every { mockProductDetailsResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockProductDetailsResult.productDetailsList } returns emptyList() + coEvery { mockBillingRepository.queryProducts(listOf(mockProductId.value)) } returns + mockProductDetailsResult + + // Act, Assert + paymentRepository.purchaseProduct(mockProductId, mockk()).test { + assertIs<PurchaseResult.FetchingProducts>(awaitItem()) + val result = awaitItem() + assertIs<PurchaseResult.Error.NoProductFound>(result) + awaitComplete() + } + } + + @Test + fun testPurchaseBillingProductStartPurchaseTransactionIdError() = runTest { + // Arrange + val mockProductId = ProductId("MOCK") + val mockProductDetailsResult = mockk<ProductDetailsResult>() + val mockProductDetails: ProductDetails = mockk() + every { mockProductDetails.productId } returns mockProductId.value + every { mockProductDetailsResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockProductDetailsResult.productDetailsList } returns listOf(mockProductDetails) + coEvery { mockBillingRepository.queryProducts(listOf(mockProductId.value)) } returns + mockProductDetailsResult + coEvery { mockPlayPurchaseRepository.initializePlayPurchase() } returns + PlayPurchaseInitResult.Error(PlayPurchaseInitError.OtherError) + + // Act, Assert + paymentRepository.purchaseProduct(mockProductId, mockk()).test { + assertIs<PurchaseResult.FetchingProducts>(awaitItem()) + assertIs<PurchaseResult.FetchingObfuscationId>(awaitItem()) + val result = awaitItem() + assertIs<PurchaseResult.Error.TransactionIdError>(result) + awaitComplete() + } + } + + @Test + fun testPurchaseBillingProductStartPurchaseFlowBillingError() = runTest { + // Arrange + val mockProductId = ProductId("MOCK") + val mockProductDetailsResult = mockk<ProductDetailsResult>() + val mockProductDetails: ProductDetails = mockk() + every { mockProductDetails.productId } returns mockProductId.value + every { mockProductDetailsResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockProductDetailsResult.productDetailsList } returns listOf(mockProductDetails) + coEvery { mockBillingRepository.queryProducts(listOf(mockProductId.value)) } returns + mockProductDetailsResult + val mockBillingResult: BillingResult = mockk() + every { mockBillingResult.responseCode } returns BillingResponseCode.BILLING_UNAVAILABLE + every { mockBillingResult.debugMessage } returns "Mock error" + coEvery { + mockBillingRepository.startPurchaseFlow( + productDetails = any(), + obfuscatedId = any(), + activityProvider = any() + ) + } returns mockBillingResult + coEvery { mockPlayPurchaseRepository.initializePlayPurchase() } returns + PlayPurchaseInitResult.Ok("MOCK") + + // Act, Assert + paymentRepository.purchaseProduct(mockProductId, mockk()).test { + // Purchase started + assertIs<PurchaseResult.FetchingProducts>(awaitItem()) + assertIs<PurchaseResult.FetchingObfuscationId>(awaitItem()) + val result = awaitItem() + assertIs<PurchaseResult.Error.BillingError>(result) + awaitComplete() + } + } + + @Test + fun testPurchaseBillingProductPurchaseCanceled() = runTest { + // Arrange + val mockProductId = ProductId("MOCK") + val mockProductDetailsResult = mockk<ProductDetailsResult>() + val mockProductDetails: ProductDetails = mockk() + every { mockProductDetails.productId } returns mockProductId.value + every { mockProductDetailsResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockProductDetailsResult.productDetailsList } returns listOf(mockProductDetails) + coEvery { mockBillingRepository.queryProducts(listOf(mockProductId.value)) } returns + mockProductDetailsResult + val mockObfuscatedId = "MOCK-ID" + val mockBillingResult: BillingResult = mockk() + every { mockBillingResult.responseCode } returns BillingResponseCode.OK + coEvery { + mockBillingRepository.startPurchaseFlow( + productDetails = any(), + obfuscatedId = mockObfuscatedId, + activityProvider = any() + ) + } returns mockBillingResult + coEvery { mockPlayPurchaseRepository.initializePlayPurchase() } returns + PlayPurchaseInitResult.Ok(mockObfuscatedId) + + // Act, Assert + paymentRepository.purchaseProduct(mockProductId, mockk()).test { + assertIs<PurchaseResult.FetchingProducts>(awaitItem()) + assertIs<PurchaseResult.FetchingObfuscationId>(awaitItem()) + assertIs<PurchaseResult.BillingFlowStarted>(awaitItem()) + purchaseEventFlow.tryEmit(PurchaseEvent.UserCanceled) + val result = awaitItem() + assertIs<PurchaseResult.Completed.Cancelled>(result) + awaitComplete() + } + } + + @Test + fun testPurchaseBillingProductVerificationError() = runTest { + // Arrange + val mockProductId = ProductId("MOCK") + val mockProductDetailsResult = mockk<ProductDetailsResult>() + val mockProductDetails: ProductDetails = mockk() + every { mockProductDetails.productId } returns mockProductId.value + every { mockProductDetailsResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockProductDetailsResult.productDetailsList } returns listOf(mockProductDetails) + coEvery { mockBillingRepository.queryProducts(listOf(mockProductId.value)) } returns + mockProductDetailsResult + val mockPurchaseToken = "TOKEN" + val mockBillingPurchase: Purchase = mockk() + val mockBillingResult: BillingResult = mockk() + every { mockBillingPurchase.purchaseState } returns Purchase.PurchaseState.PURCHASED + every { mockBillingResult.responseCode } returns BillingResponseCode.OK + every { mockBillingPurchase.products } returns listOf(mockProductId.value) + every { mockBillingPurchase.purchaseToken } returns mockPurchaseToken + coEvery { + mockBillingRepository.startPurchaseFlow( + productDetails = any(), + obfuscatedId = any(), + activityProvider = any() + ) + } returns mockBillingResult + coEvery { mockPlayPurchaseRepository.initializePlayPurchase() } returns + PlayPurchaseInitResult.Ok("MOCK-ID") + coEvery { mockPlayPurchaseRepository.verifyPlayPurchase(any()) } returns + PlayPurchaseVerifyResult.Error(PlayPurchaseVerifyError.OtherError) + + // Act, Assert + paymentRepository.purchaseProduct(mockProductId, mockk()).test { + assertIs<PurchaseResult.FetchingProducts>(awaitItem()) + assertIs<PurchaseResult.FetchingObfuscationId>(awaitItem()) + assertIs<PurchaseResult.BillingFlowStarted>(awaitItem()) + purchaseEventFlow.tryEmit(PurchaseEvent.Completed(listOf(mockBillingPurchase))) + assertIs<PurchaseResult.VerificationStarted>(awaitItem()) + val result = awaitItem() + assertIs<PurchaseResult.Error.VerificationError>(result) + awaitComplete() + } + } + + @Test + fun testPurchaseBillingProductPurchaseCompleted() = runTest { + // Arrange + val mockProductId = ProductId("MOCK") + val mockProductDetailsResult = mockk<ProductDetailsResult>() + val mockProductDetails: ProductDetails = mockk() + every { mockProductDetails.productId } returns mockProductId.value + every { mockProductDetailsResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockProductDetailsResult.productDetailsList } returns listOf(mockProductDetails) + coEvery { mockBillingRepository.queryProducts(listOf(mockProductId.value)) } returns + mockProductDetailsResult + val mockPurchaseToken = "TOKEN" + val mockBillingPurchase: Purchase = mockk() + val mockBillingResult: BillingResult = mockk() + every { mockBillingPurchase.purchaseState } returns Purchase.PurchaseState.PURCHASED + every { mockBillingResult.responseCode } returns BillingResponseCode.OK + every { mockBillingPurchase.products } returns listOf(mockProductId.value) + every { mockBillingPurchase.purchaseToken } returns mockPurchaseToken + coEvery { + mockBillingRepository.startPurchaseFlow( + productDetails = any(), + obfuscatedId = any(), + activityProvider = any() + ) + } returns mockBillingResult + coEvery { mockPlayPurchaseRepository.initializePlayPurchase() } returns + PlayPurchaseInitResult.Ok("MOCK") + coEvery { mockPlayPurchaseRepository.verifyPlayPurchase(any()) } returns + PlayPurchaseVerifyResult.Ok + + // Act, Assert + paymentRepository.purchaseProduct(mockProductId, mockk()).test { + assertIs<PurchaseResult.FetchingProducts>(awaitItem()) + assertIs<PurchaseResult.FetchingObfuscationId>(awaitItem()) + assertIs<PurchaseResult.BillingFlowStarted>(awaitItem()) + purchaseEventFlow.tryEmit(PurchaseEvent.Completed(listOf(mockBillingPurchase))) + assertIs<PurchaseResult.VerificationStarted>(awaitItem()) + val result = awaitItem() + assertIs<PurchaseResult.Completed.Success>(result) + awaitComplete() + } + } + + @Test + fun testPurchaseBillingProductPurchasePending() = runTest { + // Arrange + val mockProductId = ProductId("MOCK") + val mockProductDetailsResult = mockk<ProductDetailsResult>() + val mockProductDetails: ProductDetails = mockk() + every { mockProductDetails.productId } returns mockProductId.value + every { mockProductDetailsResult.billingResult.responseCode } returns BillingResponseCode.OK + every { mockProductDetailsResult.productDetailsList } returns listOf(mockProductDetails) + coEvery { mockBillingRepository.queryProducts(listOf(mockProductId.value)) } returns + mockProductDetailsResult + val mockBillingPurchase: Purchase = mockk() + val mockBillingResult: BillingResult = mockk() + every { mockBillingPurchase.purchaseState } returns Purchase.PurchaseState.PENDING + every { mockBillingResult.responseCode } returns BillingResponseCode.OK + coEvery { + mockBillingRepository.startPurchaseFlow( + productDetails = any(), + obfuscatedId = any(), + activityProvider = any() + ) + } returns mockBillingResult + coEvery { mockPlayPurchaseRepository.initializePlayPurchase() } returns + PlayPurchaseInitResult.Ok("MOCK") + + // Act, Assert + paymentRepository.purchaseProduct(mockProductId, mockk()).test { + assertIs<PurchaseResult.FetchingProducts>(awaitItem()) + assertIs<PurchaseResult.FetchingObfuscationId>(awaitItem()) + assertIs<PurchaseResult.BillingFlowStarted>(awaitItem()) + purchaseEventFlow.tryEmit(PurchaseEvent.Completed(listOf(mockBillingPurchase))) + val result = awaitItem() + assertIs<PurchaseResult.Completed.Pending>(result) + awaitComplete() + } + } + + companion object { + private const val PRODUCT_DETAILS_TO_PAYMENT_PRODUCT_EXT = + "net.mullvad.mullvadvpn.lib.billing.extension.ProductDetailsToPaymentProductKt" + } +} diff --git a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt index c5ede20327..e1079807f1 100644 --- a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt +++ b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt @@ -5,16 +5,16 @@ import kotlinx.parcelize.Parcelize import net.mullvad.mullvadvpn.model.AccountCreationResult import net.mullvad.mullvadvpn.model.AccountExpiry import net.mullvad.mullvadvpn.model.AccountHistory -import net.mullvad.mullvadvpn.model.AppVersionInfo import net.mullvad.mullvadvpn.model.DeviceListEvent import net.mullvad.mullvadvpn.model.DeviceState import net.mullvad.mullvadvpn.model.GeoIpLocation import net.mullvad.mullvadvpn.model.LoginResult +import net.mullvad.mullvadvpn.model.PlayPurchaseInitResult +import net.mullvad.mullvadvpn.model.PlayPurchaseVerifyResult import net.mullvad.mullvadvpn.model.RelayList import net.mullvad.mullvadvpn.model.RemoveDeviceResult import net.mullvad.mullvadvpn.model.Settings import net.mullvad.mullvadvpn.model.TunnelState -import net.mullvad.mullvadvpn.model.VoucherSubmissionResult // Events that can be sent from the service sealed class Event : Message.EventMessage() { @@ -61,6 +61,11 @@ sealed class Event : Message.EventMessage() { val result: net.mullvad.mullvadvpn.model.VoucherSubmissionResult ) : Event() + @Parcelize data class PlayPurchaseInitResultEvent(val result: PlayPurchaseInitResult) : Event() + + @Parcelize + data class PlayPurchaseVerifyResultEvent(val result: PlayPurchaseVerifyResult) : Event() + @Parcelize object VpnPermissionRequest : Event() companion object { diff --git a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/MessageHandler.kt b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/MessageHandler.kt new file mode 100644 index 0000000000..04de35e3bd --- /dev/null +++ b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/MessageHandler.kt @@ -0,0 +1,14 @@ +package net.mullvad.mullvadvpn.lib.ipc + +import kotlin.reflect.KClass +import kotlinx.coroutines.flow.Flow + +interface MessageHandler { + fun <R : Event> events(klass: KClass<R>): Flow<R> + + fun trySendRequest(request: Request): Boolean +} + +inline fun <reified R : Event> MessageHandler.events(): Flow<R> { + return this.events(R::class) +} diff --git a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt index 38237e84b3..b73010785a 100644 --- a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt +++ b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt @@ -9,6 +9,7 @@ import net.mullvad.mullvadvpn.model.DnsOptions import net.mullvad.mullvadvpn.model.GeographicLocationConstraint import net.mullvad.mullvadvpn.model.ObfuscationSettings import net.mullvad.mullvadvpn.model.Ownership +import net.mullvad.mullvadvpn.model.PlayPurchase import net.mullvad.mullvadvpn.model.Providers import net.mullvad.mullvadvpn.model.QuantumResistantState import net.mullvad.mullvadvpn.model.WireguardConstraints @@ -83,6 +84,10 @@ sealed class Request : Message.RequestMessage() { @Parcelize data class SubmitVoucher(val voucher: String) : Request() + @Parcelize data object InitPlayPurchase : Request() + + @Parcelize data class VerifyPlayPurchase(val playPurchase: PlayPurchase) : Request() + @Parcelize data class UnregisterListener(val listenerId: Int) : Request() @Parcelize data class VpnPermissionResponse(val isGranted: Boolean) : Request() diff --git a/android/lib/payment/build.gradle.kts b/android/lib/payment/build.gradle.kts new file mode 100644 index 0000000000..23f945b4f9 --- /dev/null +++ b/android/lib/payment/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id(Dependencies.Plugin.androidLibraryId) + id(Dependencies.Plugin.kotlinAndroidId) +} + +android { + namespace = "net.mullvad.mullvadvpn.lib.payment" + compileSdk = Versions.Android.compileSdkVersion + + defaultConfig { + minSdk = Versions.Android.minSdkVersion + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = Versions.jvmTarget + } + + lint { + lintConfig = file("${rootProject.projectDir}/config/lint.xml") + abortOnError = true + warningsAsErrors = true + } + + packaging { + resources { + pickFirsts += setOf( + // Fixes packaging error caused by: jetified-junit-* + "META-INF/LICENSE.md", + "META-INF/LICENSE-notice.md" + ) + } + } +} + +dependencies { + implementation(Dependencies.Kotlin.stdlib) + implementation(Dependencies.KotlinX.coroutinesAndroid) +} diff --git a/android/lib/payment/src/main/AndroidManifest.xml b/android/lib/payment/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..b2d3ea1235 --- /dev/null +++ b/android/lib/payment/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" /> diff --git a/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/PaymentProvider.kt b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/PaymentProvider.kt new file mode 100644 index 0000000000..431b406dc0 --- /dev/null +++ b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/PaymentProvider.kt @@ -0,0 +1,3 @@ +package net.mullvad.mullvadvpn.lib.payment + +@JvmInline value class PaymentProvider(val paymentRepository: PaymentRepository?) diff --git a/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/PaymentRepository.kt b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/PaymentRepository.kt new file mode 100644 index 0000000000..73fd0c061d --- /dev/null +++ b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/PaymentRepository.kt @@ -0,0 +1,20 @@ +package net.mullvad.mullvadvpn.lib.payment + +import android.app.Activity +import kotlinx.coroutines.flow.Flow +import net.mullvad.mullvadvpn.lib.payment.model.PaymentAvailability +import net.mullvad.mullvadvpn.lib.payment.model.ProductId +import net.mullvad.mullvadvpn.lib.payment.model.PurchaseResult +import net.mullvad.mullvadvpn.lib.payment.model.VerificationResult + +interface PaymentRepository { + + fun purchaseProduct( + productId: ProductId, + activityProvider: () -> Activity + ): Flow<PurchaseResult> + + fun verifyPurchases(): Flow<VerificationResult> + + fun queryPaymentAvailability(): Flow<PaymentAvailability> +} diff --git a/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/ProductIds.kt b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/ProductIds.kt new file mode 100644 index 0000000000..8754968891 --- /dev/null +++ b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/ProductIds.kt @@ -0,0 +1,5 @@ +package net.mullvad.mullvadvpn.lib.payment + +object ProductIds { + const val OneMonth = "one_month" +} diff --git a/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PaymentAvailability.kt b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PaymentAvailability.kt new file mode 100644 index 0000000000..012237d825 --- /dev/null +++ b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PaymentAvailability.kt @@ -0,0 +1,25 @@ +package net.mullvad.mullvadvpn.lib.payment.model + +sealed interface PaymentAvailability { + data object Loading : PaymentAvailability + + data class ProductsAvailable(val products: List<PaymentProduct>) : PaymentAvailability + + data object ProductsUnavailable : PaymentAvailability + + data object NoProductsFounds : PaymentAvailability + + sealed interface Error : PaymentAvailability { + data object BillingUnavailable : Error + + data object ServiceUnavailable : Error + + data object FeatureNotSupported : Error + + data object DeveloperError : Error + + data object ItemUnavailable : Error + + data class Other(val exception: Throwable) : Error + } +} diff --git a/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PaymentProduct.kt b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PaymentProduct.kt new file mode 100644 index 0000000000..8945453d37 --- /dev/null +++ b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PaymentProduct.kt @@ -0,0 +1,7 @@ +package net.mullvad.mullvadvpn.lib.payment.model + +data class PaymentProduct( + val productId: ProductId, + val price: ProductPrice, + val status: PaymentStatus? +) diff --git a/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PaymentStatus.kt b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PaymentStatus.kt new file mode 100644 index 0000000000..37574249a6 --- /dev/null +++ b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PaymentStatus.kt @@ -0,0 +1,6 @@ +package net.mullvad.mullvadvpn.lib.payment.model + +enum class PaymentStatus { + PENDING, + VERIFICATION_IN_PROGRESS +} diff --git a/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/ProductId.kt b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/ProductId.kt new file mode 100644 index 0000000000..f14fefab28 --- /dev/null +++ b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/ProductId.kt @@ -0,0 +1,3 @@ +package net.mullvad.mullvadvpn.lib.payment.model + +@JvmInline value class ProductId(val value: String) diff --git a/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/ProductPrice.kt b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/ProductPrice.kt new file mode 100644 index 0000000000..5dc90db5fb --- /dev/null +++ b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/ProductPrice.kt @@ -0,0 +1,3 @@ +package net.mullvad.mullvadvpn.lib.payment.model + +@JvmInline value class ProductPrice(val value: String) diff --git a/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PurchaseResult.kt b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PurchaseResult.kt new file mode 100644 index 0000000000..f5b89bffe6 --- /dev/null +++ b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/PurchaseResult.kt @@ -0,0 +1,34 @@ +package net.mullvad.mullvadvpn.lib.payment.model + +sealed interface PurchaseResult { + data object FetchingProducts : PurchaseResult + + data object FetchingObfuscationId : PurchaseResult + + data object BillingFlowStarted : PurchaseResult + + data object VerificationStarted : PurchaseResult + + sealed interface Completed : PurchaseResult { + data object Success : Completed + + data object Cancelled : Completed + + // This ends our part of the purchase flow. The rest is handled by Google and the api. + data object Pending : Completed + } + + sealed interface Error : PurchaseResult { + data class NoProductFound(val productId: ProductId) : Error + + data class FetchProductsError(val productId: ProductId, val exception: Throwable?) : Error + + data class TransactionIdError(val productId: ProductId, val exception: Throwable?) : Error + + data class BillingError(val exception: Throwable?) : Error + + data class VerificationError(val exception: Throwable?) : Error + } + + fun isTerminatingState(): Boolean = this is Completed || this is Error +} diff --git a/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/VerificationResult.kt b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/VerificationResult.kt new file mode 100644 index 0000000000..725ea0af68 --- /dev/null +++ b/android/lib/payment/src/main/kotlin/net/mullvad/mullvadvpn/lib/payment/model/VerificationResult.kt @@ -0,0 +1,19 @@ +package net.mullvad.mullvadvpn.lib.payment.model + +sealed interface VerificationResult { + data object FetchingUnfinishedPurchases : VerificationResult + + data object VerificationStarted : VerificationResult + + // No verification was needed as there is no purchases to verify + data object NothingToVerify : VerificationResult + + data object Success : VerificationResult + + // Generic error, add more cases as needed + sealed interface Error : VerificationResult { + data class BillingError(val exception: Throwable?) : Error + + data class VerificationError(val exception: Throwable?) : Error + } +} diff --git a/android/lib/resource/src/main/res/values-da/strings.xml b/android/lib/resource/src/main/res/values-da/strings.xml index 503a66789a..160a34ea5f 100644 --- a/android/lib/resource/src/main/res/values-da/strings.xml +++ b/android/lib/resource/src/main/res/values-da/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Køb kredit</string> <string name="buy_more_credit">Køb mere kredit</string> <string name="cancel">Annuller</string> - <string name="changes_dialog_dismiss_button">Forstået!</string> <string name="changes_dialog_subtitle">Ændringer i denne version:</string> <string name="confirm_local_dns">Den lokale DNS-server fungerer ikke, medmindre du aktiverer \"Lokal netværksdeling\" under Indstillinger.</string> <string name="confirm_no_email">Du er ved at sende rapporten om problemet, men har ikke angivet hvordan vi kan kontakte dig. Hvis du ønsker et svar på din rapport, skal du indtaste en e-mail-adresse.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Viser den aktuelle VPN-tunnelstatus</string> <string name="foreground_notification_channel_name">VPN-tunnelstatus</string> <string name="go_to_login">Gå til login</string> + <string name="got_it">Forstået!</string> <string name="here_is_your_account_number">Her er dit kontonummer. Gem det!</string> <string name="hide_account_number">Skjul kontonummer</string> <string name="hint_default">Standard</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Tid udløbet</string> <string name="paid_until">Betalt indtil</string> <string name="pay_to_start_using">For at begynde at bruge appen skal du først føje tid til din konto.</string> + <string name="payment_completed_dialog_title">Tid blev tilføjet</string> <string name="port">Port</string> <string name="privacy_disclaimer_title">Privatliv</string> <string name="privacy_policy_label">Fortrolighedspolitik</string> diff --git a/android/lib/resource/src/main/res/values-de/strings.xml b/android/lib/resource/src/main/res/values-de/strings.xml index fd9fc039e1..fd6b6f8d59 100644 --- a/android/lib/resource/src/main/res/values-de/strings.xml +++ b/android/lib/resource/src/main/res/values-de/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Guthaben erwerben</string> <string name="buy_more_credit">Mehr Guthaben erwerben</string> <string name="cancel">Abbrechen</string> - <string name="changes_dialog_dismiss_button">Verstanden!</string> <string name="changes_dialog_subtitle">Änderungen in dieser Version:</string> <string name="confirm_local_dns">Der lokale DNS-Server wird nicht funktionieren, solange „Teilen im lokalen Netzwerk“ nicht in den Einstellungen aktiviert ist.</string> <string name="confirm_no_email">Sie wollen einen Problembericht senden, ohne uns die Möglichkeit zu geben, Sie zu erreichen. Wenn Sie sich eine Antwort zu Ihrem Problem wünschen, müssen Sie eine E-Mail-Adresse eingeben.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Zeigt den aktuellen Status des VPN-Tunnels an</string> <string name="foreground_notification_channel_name">Status des VPN-Tunnels</string> <string name="go_to_login">Zur Anmeldung</string> + <string name="got_it">Verstanden!</string> <string name="here_is_your_account_number">Hier ist Ihre Kontonummer. Verlieren Sie sie nicht!</string> <string name="hide_account_number">Kontonummer verbergen</string> <string name="hint_default">Standard</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Zeit abgelaufen</string> <string name="paid_until">Bezahlt bis</string> <string name="pay_to_start_using">Um mit der Nutzung dieser App zu beginnen, müssen Sie erst einmal Zeit zu Ihrem Konto hinzufügen.</string> + <string name="payment_completed_dialog_title">Zeit erfolgreich hinzugefügt</string> <string name="port">Port</string> <string name="privacy_disclaimer_title">Datenschutz</string> <string name="privacy_policy_label">Datenschutzrichtlinie</string> diff --git a/android/lib/resource/src/main/res/values-es/strings.xml b/android/lib/resource/src/main/res/values-es/strings.xml index d936ca5ba9..4eff30768e 100644 --- a/android/lib/resource/src/main/res/values-es/strings.xml +++ b/android/lib/resource/src/main/res/values-es/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Comprar créditos</string> <string name="buy_more_credit">Comprar más créditos</string> <string name="cancel">Cancelar</string> - <string name="changes_dialog_dismiss_button">¡Entendido!</string> <string name="changes_dialog_subtitle">Cambios en esta versión:</string> <string name="confirm_local_dns">El servidor DNS local no funcionará a no ser que habilite la opción «Uso compartido de red local» en Preferencias.</string> <string name="confirm_no_email">Va a enviar el informe de problemas sin indicar una forma de contacto. Para obtener una respuesta sobre el informe, necesita especificar su dirección de correo electrónico.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Muestra el estado actual del túnel VPN</string> <string name="foreground_notification_channel_name">Estado del túnel VPN</string> <string name="go_to_login">Iniciar sesión</string> + <string name="got_it">¡Entendido!</string> <string name="here_is_your_account_number">Este es un número de cuenta. ¡Guárdelo bien!</string> <string name="hide_account_number">Ocultar número de cuenta</string> <string name="hint_default">Predeterminado</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Tiempo agotado</string> <string name="paid_until">Pagado hasta</string> <string name="pay_to_start_using">Para empezar a usar la aplicación, primero necesita agregar tiempo a su cuenta.</string> + <string name="payment_completed_dialog_title">Se añadió correctamente el tiempo</string> <string name="port">Puerto</string> <string name="privacy_disclaimer_title">Privacidad</string> <string name="privacy_policy_label">Política de privacidad</string> diff --git a/android/lib/resource/src/main/res/values-fi/strings.xml b/android/lib/resource/src/main/res/values-fi/strings.xml index c0c14178db..a48af8610e 100644 --- a/android/lib/resource/src/main/res/values-fi/strings.xml +++ b/android/lib/resource/src/main/res/values-fi/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Osta käyttöaikaa</string> <string name="buy_more_credit">Uudista tilaus</string> <string name="cancel">Peruuta</string> - <string name="changes_dialog_dismiss_button">Selvä!</string> <string name="changes_dialog_subtitle">Muutokset tässä versiossa:</string> <string name="confirm_local_dns">Paikallinen DNS-palvelin ei toimi, ellet ota paikallisen verkon jakamisasetusta käyttöön asetuksissa.</string> <string name="confirm_no_email">Olet aikeissa lähettää ongelmaraportin ilman yhteystietojasi. Mikäli haluat vastauksen raporttiisi, anna sähköpostosoite.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Näyttää VPN-tunnelin nykyisen tilan</string> <string name="foreground_notification_channel_name">VPN-tunnelin tila</string> <string name="go_to_login">Siirry kirjautumiseen</string> + <string name="got_it">Selvä!</string> <string name="here_is_your_account_number">Tässä tulee tilisi numero. Laita se talteen!</string> <string name="hide_account_number">Piilota tilin numero</string> <string name="hint_default">Oletus</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Ei käyttöaikaa</string> <string name="paid_until">Maksu ennen</string> <string name="pay_to_start_using">Voit aloittaa sovelluksen käyttämisen lisäämällä ensin aikaa tilillesi.</string> + <string name="payment_completed_dialog_title">Aika lisättiin onnistuneesti</string> <string name="port">Portti</string> <string name="privacy_disclaimer_title">Tietosuoja</string> <string name="privacy_policy_label">Tietosuojakäytäntö</string> diff --git a/android/lib/resource/src/main/res/values-fr/strings.xml b/android/lib/resource/src/main/res/values-fr/strings.xml index 26272030bd..0abbdf0037 100644 --- a/android/lib/resource/src/main/res/values-fr/strings.xml +++ b/android/lib/resource/src/main/res/values-fr/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Acheter des crédits</string> <string name="buy_more_credit">Acheter plus de crédits</string> <string name="cancel">Annuler</string> - <string name="changes_dialog_dismiss_button">Compris !</string> <string name="changes_dialog_subtitle">Modifications dans cette version :</string> <string name="confirm_local_dns">Le serveur DNS local ne fonctionnera pas si vous n\'activez pas le « Partage du réseau local » dans les préférences.</string> <string name="confirm_no_email">Vous êtes sur le point d\'envoyer un signalement de problème sans nous fournir un moyen de vous contacter. Si vous désirez une réponse à votre signalement, vous devez saisir une adresse e-mail.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Affiche l\'état actuel du tunnel VPN</string> <string name="foreground_notification_channel_name">État du tunnel VPN</string> <string name="go_to_login">Aller à la connexion</string> + <string name="got_it">Compris !</string> <string name="here_is_your_account_number">Voici votre numéro de compte. Gardez-le !</string> <string name="hide_account_number">Masquer le numéro de compte</string> <string name="hint_default">Par défaut</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Plus de temps</string> <string name="paid_until">Payé jusqu\'au</string> <string name="pay_to_start_using">Pour commencer à utiliser l\'application, vous devez d\'abord ajouter du temps à votre compte.</string> + <string name="payment_completed_dialog_title">Le temps a bien été ajouté</string> <string name="port">Port</string> <string name="privacy_disclaimer_title">Confidentialité</string> <string name="privacy_policy_label">Politique de confidentialité</string> diff --git a/android/lib/resource/src/main/res/values-it/strings.xml b/android/lib/resource/src/main/res/values-it/strings.xml index 02a9572498..8ae92f4880 100644 --- a/android/lib/resource/src/main/res/values-it/strings.xml +++ b/android/lib/resource/src/main/res/values-it/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Acquista credito</string> <string name="buy_more_credit">Acquista altro credito</string> <string name="cancel">Annulla</string> - <string name="changes_dialog_dismiss_button">Ok!</string> <string name="changes_dialog_subtitle">Modifiche in questa versione:</string> <string name="confirm_local_dns">Il server DNS locale non funzionerà a meno che non si abiliti \"Condivisione rete locale\" in Preferenze.</string> <string name="confirm_no_email">Stai inviando la segnalazione di un problema senza averci indicato un modo per ricontattarti. Se desideri ricevere risposta, inserisci un indirizzo e-mail.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Mostra lo stato attuale del tunnel VPN</string> <string name="foreground_notification_channel_name">Stato del tunnel VPN</string> <string name="go_to_login">Vai al login</string> + <string name="got_it">Ok!</string> <string name="here_is_your_account_number">Ecco il tuo numero di account. Salvalo!</string> <string name="hide_account_number">Nascondi numero di account</string> <string name="hint_default">Predefinito</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Scaduto</string> <string name="paid_until">Pagato fino al</string> <string name="pay_to_start_using">Per iniziare a utilizzare l\'app, devi prima aggiungere tempo al tuo account.</string> + <string name="payment_completed_dialog_title">L\'ora è stata aggiunta correttamente</string> <string name="port">Porta</string> <string name="privacy_disclaimer_title">Privacy</string> <string name="privacy_policy_label">Informativa sulla privacy</string> diff --git a/android/lib/resource/src/main/res/values-ja/strings.xml b/android/lib/resource/src/main/res/values-ja/strings.xml index a132977f84..a05cdc3db7 100644 --- a/android/lib/resource/src/main/res/values-ja/strings.xml +++ b/android/lib/resource/src/main/res/values-ja/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">クレジットを購入</string> <string name="buy_more_credit">追加クレジットを購入</string> <string name="cancel">キャンセル</string> - <string name="changes_dialog_dismiss_button">了解</string> <string name="changes_dialog_subtitle">このバージョンでの変更内容:</string> <string name="confirm_local_dns">環境設定で \"ローカルネットワーク共有\" を有効にしない限り、ローカルDNSサーバーは機能しません。</string> <string name="confirm_no_email">お客様への返信先を入力せずに問題の報告を送信しようとしています。ご報告に対する返信が必要な場合は、返信先のメールアドレスを入力する必要があります。</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">現在のVPNトンネルのステータスを表示します</string> <string name="foreground_notification_channel_name">VPNトンネルのステータス</string> <string name="go_to_login">ログインに進む</string> + <string name="got_it">了解</string> <string name="here_is_your_account_number">これがあなたのアカウント番号です。保存してください!</string> <string name="hide_account_number">アカウント番号の非表示</string> <string name="hint_default">デフォルト</string> @@ -133,6 +133,7 @@ <string name="out_of_time">時間切れ</string> <string name="paid_until">次の日時まで支払い済み</string> <string name="pay_to_start_using">アプリを使い始めるには、まずはアカウントに時間を追加する必要があります。</string> + <string name="payment_completed_dialog_title">時間を正常に追加しました</string> <string name="port">ポート</string> <string name="privacy_disclaimer_title">プライバシー</string> <string name="privacy_policy_label">プライバシーポリシー</string> diff --git a/android/lib/resource/src/main/res/values-ko/strings.xml b/android/lib/resource/src/main/res/values-ko/strings.xml index ea976767b2..b3a098c919 100644 --- a/android/lib/resource/src/main/res/values-ko/strings.xml +++ b/android/lib/resource/src/main/res/values-ko/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">크레딧 구매</string> <string name="buy_more_credit">추가 크레딧 구매</string> <string name="cancel">취소</string> - <string name="changes_dialog_dismiss_button">확인!</string> <string name="changes_dialog_subtitle">이 버전의 변경 사항:</string> <string name="confirm_local_dns">환경 설정에서 ”로컬 네트워크 공유”를 활성화하지 않으면 로컬 DNS 서버가 작동하지 않습니다.</string> <string name="confirm_no_email">연락처 없이 문제 보고서를 보내려고 합니다. 보고서에 대한 답변을 원하면 이메일 주소를 입력해야 합니다.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">현재 VPN 터널 상태 표시</string> <string name="foreground_notification_channel_name">VPN 터널 상태</string> <string name="go_to_login">로그인하기</string> + <string name="got_it">확인!</string> <string name="here_is_your_account_number">계정 번호는 다음과 같습니다. 저장하세요!</string> <string name="hide_account_number">계정 번호 숨기기</string> <string name="hint_default">기본값</string> @@ -133,6 +133,7 @@ <string name="out_of_time">시간 초과</string> <string name="paid_until">유효 기간</string> <string name="pay_to_start_using">앱 사용을 시작하려면, 먼저 계정에 시간을 추가해야 합니다.</string> + <string name="payment_completed_dialog_title">시간이 성공적으로 추가되었습니다.</string> <string name="port">포트</string> <string name="privacy_disclaimer_title">개인 정보 보호</string> <string name="privacy_policy_label">개인정보 보호정책</string> diff --git a/android/lib/resource/src/main/res/values-my/strings.xml b/android/lib/resource/src/main/res/values-my/strings.xml index 0b4014148f..bfd0e3e2bd 100644 --- a/android/lib/resource/src/main/res/values-my/strings.xml +++ b/android/lib/resource/src/main/res/values-my/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">ခရက်ဒစ် ဝယ်ရန်</string> <string name="buy_more_credit">ခရက်ဒစ်များ ဝယ်ရန်</string> <string name="cancel">မလုပ်တော့ပါ</string> - <string name="changes_dialog_dismiss_button">ရပါပြီ။</string> <string name="changes_dialog_subtitle">ဤဗားရှင်းတွင် ပြောင်းလဲမှုများ-</string> <string name="confirm_local_dns">လိုကယ် DNS ဆာဗာသည် လိုလားမှုများအောက်ရှိ \"လိုကယ် ကွန်ရက် ဝေမျှမှု\"ကို မဖွင့်မချင်း အလုပ်လုပ်မည် မဟုတ်ပါ။</string> <string name="confirm_no_email">သင်သည် သင့်ထံ ကျွန်ုပ်တို့ ပြန်ဆက်သွယ်နိုင်မည့် နည်းလမ်း မပါဘဲ ပြဿနာ ရီပို့တ်ကို ပေးပို့တော့မည် ဖြစ်ပါသည်။ သင့်ရီပို့တ်အတွက် အဖြေ ရရှိလိုပါက အီမေးလိပ်စာ ဖြည့်သွင်းပေးရပါမည်။</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">လက်ရှိ VPN Tunnel အခြေအနေကို ပြသပေးပါသည်</string> <string name="foreground_notification_channel_name">VPN Tunnel အခြေအနေ</string> <string name="go_to_login">ဝင်ရောက်ရန် သွားပါ</string> + <string name="got_it">ရပါပြီ။</string> <string name="here_is_your_account_number">ဤသည်မှာ သင့်အကောင့်နံပါတ် ဖြစ်ပါသည်။ သိမ်းမှတ်ထားပါ။</string> <string name="hide_account_number">အကောင့်နံပါတ်ကို ဝှက်ရန်</string> <string name="hint_default">ပုံသေ</string> @@ -133,6 +133,7 @@ <string name="out_of_time">အချိန်စေ့သွားပါပြီ</string> <string name="paid_until">ဖော်ပြပါအထိ ပေးချေထားပြီး</string> <string name="pay_to_start_using">အက်ပ်ကို စသုံးရန်အတွက် ဦးစွာ သင့်အကောင့်တွင် အချိန်ပေါင်းထည့်ပေးရန် လိုအပ်ပါသည်။</string> + <string name="payment_completed_dialog_title">အချိန်ကို အောင်မြင်စွာ ပေါင်းထည့်ပြီးပြီ</string> <string name="port">ပေါ့တ်</string> <string name="privacy_disclaimer_title">ကိုယ်ရေးအချက်အလက် လုံခြုံရေး</string> <string name="privacy_policy_label">ကိုယ်ပိုင်အချက်အလက် မူဝါဒ</string> diff --git a/android/lib/resource/src/main/res/values-nb/strings.xml b/android/lib/resource/src/main/res/values-nb/strings.xml index 47330dfb71..d9fa3d5e85 100644 --- a/android/lib/resource/src/main/res/values-nb/strings.xml +++ b/android/lib/resource/src/main/res/values-nb/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Kjøp kreditt</string> <string name="buy_more_credit">Kjøp mer kreditt</string> <string name="cancel">Avbryt</string> - <string name="changes_dialog_dismiss_button">Forstått!</string> <string name="changes_dialog_subtitle">Endringer i denne versjonen:</string> <string name="confirm_local_dns">Den lokale DNS-serveren fungerer ikke med mindre du aktiverer «Deling av lokalt nettverk» under Innstillinger.</string> <string name="confirm_no_email">Problemrapporten blir nå sendt uten en måte for oss å kontakte deg på. Hvis du ønsker svar på rapporten, må du oppgi en e-postadresse.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Viser gjeldende VPN-tunnelstatus</string> <string name="foreground_notification_channel_name">VPN-tunnelstatus</string> <string name="go_to_login">Gå til pålogging</string> + <string name="got_it">Forstått!</string> <string name="here_is_your_account_number">Dette er kontonummeret ditt. Ta vare på det!</string> <string name="hide_account_number">Skjul kontonummer</string> <string name="hint_default">Standard</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Tiden har utløpt</string> <string name="paid_until">Betalt fram til</string> <string name="pay_to_start_using">For å starte bruken av appen, må du først legge til tid til kontoen.</string> + <string name="payment_completed_dialog_title">Tid ble lagt til</string> <string name="port">Port</string> <string name="privacy_disclaimer_title">Personvern</string> <string name="privacy_policy_label">Retningslinjer for personvern</string> diff --git a/android/lib/resource/src/main/res/values-nl/strings.xml b/android/lib/resource/src/main/res/values-nl/strings.xml index 0d9d53f35b..07de845443 100644 --- a/android/lib/resource/src/main/res/values-nl/strings.xml +++ b/android/lib/resource/src/main/res/values-nl/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Krediet kopen</string> <string name="buy_more_credit">Meer krediet kopen</string> <string name="cancel">Annuleren</string> - <string name="changes_dialog_dismiss_button">Begrepen!</string> <string name="changes_dialog_subtitle">Wijzigingen in deze versie:</string> <string name="confirm_local_dns">De lokale DNS-server werkt niet tenzij u \"Lokale netwerken delen\" inschakelt onder Voorkeuren.</string> <string name="confirm_no_email">U staat op het punt om het probleemrapport te verzenden zonder een contactmethode op te geven. Voer een e-mailadres in als u een antwoord wenst op het rapport.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Toont de huidige status van de VPN-tunnel</string> <string name="foreground_notification_channel_name">Status VPN-tunnel</string> <string name="go_to_login">Ga naar aanmelden</string> + <string name="got_it">Begrepen!</string> <string name="here_is_your_account_number">Hier is uw accountnummer. Sla het op!</string> <string name="hide_account_number">Accountnummer verbergen</string> <string name="hint_default">Standaard</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Geen tijd meer</string> <string name="paid_until">Betaald tot</string> <string name="pay_to_start_using">Om de app te gebruiken, moet u eerst tijd toevoegen aan uw account.</string> + <string name="payment_completed_dialog_title">Tijd is toegevoegd</string> <string name="port">Poort</string> <string name="privacy_disclaimer_title">Privacy</string> <string name="privacy_policy_label">Privacybeleid</string> diff --git a/android/lib/resource/src/main/res/values-pl/strings.xml b/android/lib/resource/src/main/res/values-pl/strings.xml index 062bfa926d..fdbc8b58bb 100644 --- a/android/lib/resource/src/main/res/values-pl/strings.xml +++ b/android/lib/resource/src/main/res/values-pl/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Kup doładowanie</string> <string name="buy_more_credit">Doładuj konto</string> <string name="cancel">Anuluj</string> - <string name="changes_dialog_dismiss_button">Jasne!</string> <string name="changes_dialog_subtitle">Zmiany w tej wersji:</string> <string name="confirm_local_dns">Lokalny serwer DNS nie będzie działał, dopóki nie włączysz opcji „Udostępnianie sieci lokalnej” w Preferencjach.</string> <string name="confirm_no_email">Za chwilę wyślesz zgłoszenie problemu, nie umożliwiając nam skontaktowania się z Tobą. Aby uzyskać odpowiedź na zgłoszenie, musisz podać adres e-mail.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Pokazuje bieżący status tunelu VPN</string> <string name="foreground_notification_channel_name">Status tunelu VPN</string> <string name="go_to_login">Przejdź do logowania</string> + <string name="got_it">Jasne!</string> <string name="here_is_your_account_number">Oto Twój numer konta. Zachowaj go!</string> <string name="hide_account_number">Ukryj numer konta</string> <string name="hint_default">Domyślnie</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Koniec czasu</string> <string name="paid_until">Płatne do</string> <string name="pay_to_start_using">Aby rozpocząć korzystanie z aplikacji, musisz najpierw dodać czas do swojego konta.</string> + <string name="payment_completed_dialog_title">Dodano czas</string> <string name="port">Port</string> <string name="privacy_disclaimer_title">Prywatność</string> <string name="privacy_policy_label">Polityka prywatności</string> diff --git a/android/lib/resource/src/main/res/values-pt/strings.xml b/android/lib/resource/src/main/res/values-pt/strings.xml index 79d4b57a3d..702161aeff 100644 --- a/android/lib/resource/src/main/res/values-pt/strings.xml +++ b/android/lib/resource/src/main/res/values-pt/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Comprar crédito</string> <string name="buy_more_credit">Comprar mais crédito</string> <string name="cancel">Cancelar</string> - <string name="changes_dialog_dismiss_button">Entendido!</string> <string name="changes_dialog_subtitle">Alterações nesta versão:</string> <string name="confirm_local_dns">O servidor DNS local não funcionará exceto se ativar \"Partilha de rede local\" em Preferências.</string> <string name="confirm_no_email">Está prestes a enviar o relatório de problema sem que tenhamos uma forma de lhe responder. Se pretender uma resposta ao seu relatório, tem de introduzir um endereço de email.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Indica o estado atual do túnel VPN</string> <string name="foreground_notification_channel_name">Estado do túnel VPN</string> <string name="go_to_login">Ir para a ligação</string> + <string name="got_it">Entendido!</string> <string name="here_is_your_account_number">Aqui tem o seu número de conta. Guarde-o!</string> <string name="hide_account_number">Ocultar número de conta</string> <string name="hint_default">Padrão</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Sem tempo</string> <string name="paid_until">Pago até</string> <string name="pay_to_start_using">Para começar a utilizar a aplicação, primeiro tem de adicionar tempo à sua conta.</string> + <string name="payment_completed_dialog_title">Tempo adicionado com sucesso</string> <string name="port">Porta</string> <string name="privacy_disclaimer_title">Privacidade</string> <string name="privacy_policy_label">Política de privacidade</string> diff --git a/android/lib/resource/src/main/res/values-ru/strings.xml b/android/lib/resource/src/main/res/values-ru/strings.xml index 95a4dc2d7a..c2f122a862 100644 --- a/android/lib/resource/src/main/res/values-ru/strings.xml +++ b/android/lib/resource/src/main/res/values-ru/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Пополнить баланс</string> <string name="buy_more_credit">Пополнить баланс</string> <string name="cancel">Отмена</string> - <string name="changes_dialog_dismiss_button">Понятно!</string> <string name="changes_dialog_subtitle">Изменения в этой версии:</string> <string name="confirm_local_dns">Локальный DNS-сервер не будет работать, пока вы не включите «Обмен данными в локальной сети» в разделе «Параметры».</string> <string name="confirm_no_email">Вы собираетесь отправить отчет о проблеме, не оставив контакты. Если вы хотите получить ответ, введите свой адрес электронной почты.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Показывает текущее состояние VPN-туннеля</string> <string name="foreground_notification_channel_name">Состояние туннеля VPN</string> <string name="go_to_login">Войти</string> + <string name="got_it">Понятно!</string> <string name="here_is_your_account_number">Вот номер вашей учетной записи. Сохраните его!</string> <string name="hide_account_number">Скрыть номер учетной записи</string> <string name="hint_default">По умолчанию</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Закончилось время</string> <string name="paid_until">Оплачено до</string> <string name="pay_to_start_using">Чтобы пользоваться приложением, нужно добавить время на учетную запись.</string> + <string name="payment_completed_dialog_title">Время добавлено</string> <string name="port">Порт</string> <string name="privacy_disclaimer_title">Конфиденциальность</string> <string name="privacy_policy_label">Политика конфиденциальности</string> diff --git a/android/lib/resource/src/main/res/values-sv/strings.xml b/android/lib/resource/src/main/res/values-sv/strings.xml index 4ae8326b6f..c453cb2fa9 100644 --- a/android/lib/resource/src/main/res/values-sv/strings.xml +++ b/android/lib/resource/src/main/res/values-sv/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Köp kredit</string> <string name="buy_more_credit">Köp mer kredit</string> <string name="cancel">Avbryt</string> - <string name="changes_dialog_dismiss_button">Jag förstår!</string> <string name="changes_dialog_subtitle">Ändringar i den här versionen:</string> <string name="confirm_local_dns">Den lokala DNS-servern fungerar inte om du inte aktiverar \"Lokal nätverksdelning\" under Inställningar.</string> <string name="confirm_no_email">Du är på väg att skicka problemrapporten utan att vi har möjlighet att besvara dig. Om du vill ha svar på din rapport måste du ange en e-postadress.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Visar nuvarande status för VPN-tunnel</string> <string name="foreground_notification_channel_name">VPN-tunnelstatus</string> <string name="go_to_login">Gå till inloggning</string> + <string name="got_it">Jag förstår!</string> <string name="here_is_your_account_number">Här är ditt kontonummer. Spara det!</string> <string name="hide_account_number">Dölj kontonummer</string> <string name="hint_default">Standard</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Ingen tid kvar</string> <string name="paid_until">Betalat till</string> <string name="pay_to_start_using">Om du vill börja använda appen måste du först lägga till tid i ditt konto.</string> + <string name="payment_completed_dialog_title">Tid har lagts till</string> <string name="port">Port</string> <string name="privacy_disclaimer_title">Sekretess</string> <string name="privacy_policy_label">Sekretesspolicy</string> diff --git a/android/lib/resource/src/main/res/values-th/strings.xml b/android/lib/resource/src/main/res/values-th/strings.xml index 0297f8be3e..cce7148a7f 100644 --- a/android/lib/resource/src/main/res/values-th/strings.xml +++ b/android/lib/resource/src/main/res/values-th/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">ซื้อเครดิต</string> <string name="buy_more_credit">ซื้อเครดิตเพิ่ม</string> <string name="cancel">ยกเลิก</string> - <string name="changes_dialog_dismiss_button">รับทราบ!</string> <string name="changes_dialog_subtitle">การเปลี่ยนแปลงในเวอร์ชันนี้:</string> <string name="confirm_local_dns">เซิร์ฟเวอร์ DNS ท้องถิ่นจะไม่ทำงาน เว้นแต่คุณจะเปิดใช้ \"การแชร์ในเครือข่ายท้องถิ่น\" ซึ่งอยู่ในส่วนการกำหนดค่า</string> <string name="confirm_no_email">คุณกำลังจะส่งรายงานปัญหา โดยไม่มีการระบุวิธีการติดต่อกลับให้กับเรา และคุณจำเป็นต้องป้อนที่อยู่อีเมลของคุณ หากคุณอยากให้เราตอบกลับการรายงานของคุณ</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">แสดงสถานะอุโมงค์ VPN ในปัจจุบัน</string> <string name="foreground_notification_channel_name">สถานะอุโมงค์ VPN</string> <string name="go_to_login">ไปเข้าสู่ระบบ</string> + <string name="got_it">รับทราบ!</string> <string name="here_is_your_account_number">นี่คือหมายเลขบัญชีของคุณ จดบันทึกไว้ด้วยนะ!</string> <string name="hide_account_number">ซ่อนหมายเลขบัญชี</string> <string name="hint_default">ค่าเริ่มต้น</string> @@ -133,6 +133,7 @@ <string name="out_of_time">หมดเวลา</string> <string name="paid_until">ชำระเงินแล้วจนถึง</string> <string name="pay_to_start_using">คุณจำเป็นต้องเพิ่มเวลาไปยังบัญชีของคุณก่อน เพื่อที่จะเริ่มใช้งานแอป</string> + <string name="payment_completed_dialog_title">เพิ่มเวลาสำเร็จแล้ว</string> <string name="port">พอร์ต</string> <string name="privacy_disclaimer_title">ความเป็นส่วนตัว</string> <string name="privacy_policy_label">นโยบายความเป็นส่วนตัว</string> diff --git a/android/lib/resource/src/main/res/values-tr/strings.xml b/android/lib/resource/src/main/res/values-tr/strings.xml index 46d9797b69..92a18749f5 100644 --- a/android/lib/resource/src/main/res/values-tr/strings.xml +++ b/android/lib/resource/src/main/res/values-tr/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">Kredi satın alın</string> <string name="buy_more_credit">Daha fazla kredi satın alın</string> <string name="cancel">İptal et</string> - <string name="changes_dialog_dismiss_button">Anladım!</string> <string name="changes_dialog_subtitle">Bu sürümdeki değişiklikler:</string> <string name="confirm_local_dns">Tercihler sekmesinin altındaki \"Yerel Ağ Paylaşımı\" seçeneğini etkinleştirmediğiniz sürece yerel DNS sunucusu çalışmaz.</string> <string name="confirm_no_email">Sorun raporunu, size geri dönüş yapmamıza imkan vermeyen bir şekilde göndermek üzeresiniz. Sorununuz için yanıt almak istiyorsanız bir e-posta adresi girmelisiniz.</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">Mevcut VPN tünelinin durumunu gösterir</string> <string name="foreground_notification_channel_name">VPN tüneli durumu</string> <string name="go_to_login">Giriş sayfasına git</string> + <string name="got_it">Anladım!</string> <string name="here_is_your_account_number">İşte hesap numaranız. Kaydedin!</string> <string name="hide_account_number">Hesap numarasını gizle</string> <string name="hint_default">Varsayılan</string> @@ -133,6 +133,7 @@ <string name="out_of_time">Süre doldu</string> <string name="paid_until">Şu tarihe kadar ödendi:</string> <string name="pay_to_start_using">Uygulamayı kullanmaya başlamak için önce hesabınıza süre eklemeniz gerekir.</string> + <string name="payment_completed_dialog_title">Süre başarıyla eklendi</string> <string name="port">Port</string> <string name="privacy_disclaimer_title">Gizlilik</string> <string name="privacy_policy_label">Gizlilik politikası</string> diff --git a/android/lib/resource/src/main/res/values-zh-rCN/strings.xml b/android/lib/resource/src/main/res/values-zh-rCN/strings.xml index 2134a212e3..26c61fa644 100644 --- a/android/lib/resource/src/main/res/values-zh-rCN/strings.xml +++ b/android/lib/resource/src/main/res/values-zh-rCN/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">购买额度</string> <string name="buy_more_credit">购买更多额度</string> <string name="cancel">取消</string> - <string name="changes_dialog_dismiss_button">知道了!</string> <string name="changes_dialog_subtitle">此版本中的变更:</string> <string name="confirm_local_dns">除非您在“偏好设置”下启用“本地网络共享”,否则本地 DNS 服务器将不会运行。</string> <string name="confirm_no_email">您即将发送问题报告,但没有提供让我们可以联系到您的方式。如果您希望获得回复,必须输入您的电子邮件地址。</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">显示当前的 VPN 隧道状态</string> <string name="foreground_notification_channel_name">VPN 隧道状态</string> <string name="go_to_login">前往登录</string> + <string name="got_it">知道了!</string> <string name="here_is_your_account_number">以下是您的帐号。请妥善保存!</string> <string name="hide_account_number">隐藏帐号</string> <string name="hint_default">默认</string> @@ -133,6 +133,7 @@ <string name="out_of_time">已没有时间</string> <string name="paid_until">到期时间</string> <string name="pay_to_start_using">要开始使用本应用,您首先需要向帐户中充入时间。</string> + <string name="payment_completed_dialog_title">时间已成功添加</string> <string name="port">端口</string> <string name="privacy_disclaimer_title">隐私</string> <string name="privacy_policy_label">隐私政策</string> diff --git a/android/lib/resource/src/main/res/values-zh-rTW/strings.xml b/android/lib/resource/src/main/res/values-zh-rTW/strings.xml index 1949488b29..a3eee83dde 100644 --- a/android/lib/resource/src/main/res/values-zh-rTW/strings.xml +++ b/android/lib/resource/src/main/res/values-zh-rTW/strings.xml @@ -32,7 +32,6 @@ <string name="buy_credit">購買點數</string> <string name="buy_more_credit">購買更多點數</string> <string name="cancel">取消</string> - <string name="changes_dialog_dismiss_button">知道了!</string> <string name="changes_dialog_subtitle">此版本中的變更:</string> <string name="confirm_local_dns">若要使本機 DNS 伺服器運作,需先在「偏好設定」下啟用「本機網路共用」。</string> <string name="confirm_no_email">您即將傳送的問題報告未包含回覆方式資訊。如果想收到您這份報告的回覆,請輸入您的電子郵件位址。</string> @@ -89,6 +88,7 @@ <string name="foreground_notification_channel_description">顯示目前的 VPN 通道狀態</string> <string name="foreground_notification_channel_name">VPN 通道狀態</string> <string name="go_to_login">前往登入</string> + <string name="got_it">知道了!</string> <string name="here_is_your_account_number">以下是您的帳號。請妥善保管!</string> <string name="hide_account_number">隱藏帳號</string> <string name="hint_default">預設</string> @@ -133,6 +133,7 @@ <string name="out_of_time">逾時</string> <string name="paid_until">支付至</string> <string name="pay_to_start_using">需先在帳戶中加時,才能開始使用本應用程式。</string> + <string name="payment_completed_dialog_title">已成功新增時間</string> <string name="port">連接埠</string> <string name="privacy_disclaimer_title">隱私權</string> <string name="privacy_policy_label">隱私權政策</string> diff --git a/android/lib/resource/src/main/res/values/strings.xml b/android/lib/resource/src/main/res/values/strings.xml index a769d91bcb..f3b0b0d157 100644 --- a/android/lib/resource/src/main/res/values/strings.xml +++ b/android/lib/resource/src/main/res/values/strings.xml @@ -151,7 +151,6 @@ <string name="show_account_number">Show account number</string> <string name="failed_to_remove_device">Failed to remove device</string> <string name="changes_dialog_subtitle">Changes in this version:</string> - <string name="changes_dialog_dismiss_button">Got it!</string> <string name="always_on_vpn_error_notification_title">Always-on VPN assigned to other app</string> <string name="always_on_vpn_error_notification_content"> <![CDATA[Unable to start tunnel connection. Please disable Always-on VPN for <b>%s</b> before using Mullvad VPN.]]> @@ -229,4 +228,19 @@ <string name="less_than_one_day">less than one day</string> <string name="top_bar_time_left">Time left: %s</string> <string name="top_bar_device_name">Device name: %s</string> + <string name="add_30_days_time_x">Add 30 days time (%s)</string> + <string name="add_30_days_time">Add 30 days time</string> + <string name="payment_completed_dialog_title">Time was successfully added</string> + <string name="payment_completed_dialog_message">30 days was added to your account.</string> + <string name="got_it">Got it!</string> + <string name="payment_billing_error_dialog_title">Google Play unavailable</string> + <string name="payment_billing_error_dialog_message">We were unable to start the payment process, please make sure you have the latest version of Google Play.</string> + <string name="payment_obfuscation_id_error_dialog_title">Mullvad services unavailable</string> + <string name="payment_obfuscation_id_error_dialog_message">We were unable to start the payment process, please try again later.</string> + <string name="payment_status_pending">Google Play payment pending</string> + <string name="payment_status_verification_in_progress">Verifying purchase</string> + <string name="payment_pending_dialog_title">Verifying purchase</string> + <string name="payment_pending_dialog_message">We are currently verifying your purchase, this might take some time. Your time will be added if the verification is successful.</string> + <string name="loading_connecting">Connecting...</string> + <string name="loading_verifying">Verifying purchase...</string> </resources> diff --git a/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt b/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt index 20a1c2f3e1..404b556d94 100644 --- a/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt +++ b/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt @@ -32,6 +32,7 @@ data class Dimensions( val dialogIconSize: Dp = 48.dp, val expandableCellChevronSize: Dp = 30.dp, val iconFailSuccessTopMargin: Dp = 30.dp, + val iconHeight: Dp = 44.dp, val indentedCellStartPadding: Dp = 38.dp, val infoButtonVerticalPadding: Dp = 13.dp, val largePadding: Dp = 32.dp, |
