Skip to content

Commit

Permalink
Move amazon module into purchases (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
vegaro authored Jun 30, 2023
1 parent e6e498c commit 6f336b1
Show file tree
Hide file tree
Showing 55 changed files with 23 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.revenuecat.purchases.ProductType;
import com.revenuecat.purchases.amazon.AmazonStoreProduct;
import com.revenuecat.purchases.amazon.AmazonStoreProductKt;
import com.revenuecat.purchases.models.GoogleSubscriptionOption;
import com.revenuecat.purchases.models.GoogleStoreProduct;
import com.revenuecat.purchases.models.GoogleStoreProductKt;
import com.revenuecat.purchases.models.Price;
Expand Down
59 changes: 0 additions & 59 deletions feature/amazon/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
alias libs.plugins.android.library
alias libs.plugins.kotlin.android
alias libs.plugins.kotlin.parcelize
alias libs.plugins.mavenPublish
}

Expand All @@ -11,67 +10,9 @@ android {
namespace 'com.revenuecat.purchases.amazon'
}

ext {
amazon2Version = "2.0.76"
amazon2FileName = "in-app-purchasing-${amazon2Version}.jar"
}

dependencies {
implementation project(":purchases")
implementation project(":common")

implementation libs.kotlin.stdlib
implementation libs.androidx.annotation
implementation libs.amazon.appstore.sdk

testImplementation project(":test-utils")
testImplementation libs.amazon.appstore.sdk
testImplementation libs.bundles.test
}

// Not running with this flag causes verification issues due to the way the Amazon jar is compiled
// https://github.com/robolectric/robolectric-gradle-plugin/issues/144#issuecomment-265899560
tasks.withType(Test) { jvmArgs += "-noverify" }

task getAmazonLibrary {
ext {
downloadURL = "https://amzndevresources.com/iap/sdk/AmazonInAppPurchasing_Android.zip"
destFile = new File(projectDir, "libs/$amazon2FileName")
}

inputs.property('downloadURL', downloadURL)
inputs.property('fileToExtract', amazon2FileName)
outputs.file(destFile)

doLast {
if (!destFile.exists()) {
println 'Downloading Amazon dependency'
File destDir = destFile.parentFile
destDir.mkdirs()

File downloadFile = new File(temporaryDir, 'download.zip')
new URL(downloadURL).withInputStream { is ->
downloadFile.withOutputStream { it << is }
}

project.copy {
from {
zipTree(downloadFile).matching { include "**/$amazon2FileName" }.singleFile
}

into(destDir)
}
}
}
}

task cleanAmazonLibrary(type: Delete) {
delete new File(projectDir, "libs/$amazon2FileName")
}

afterEvaluate {
preDefaultsDebugBuild.dependsOn cleanAmazonLibrary
preDefaultsReleaseBuild.dependsOn cleanAmazonLibrary
preIntegrationTestDebugBuild.dependsOn cleanAmazonLibrary
preIntegrationTestReleaseBuild.dependsOn cleanAmazonLibrary
}
4 changes: 0 additions & 4 deletions feature/amazon/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
<action android:name="com.amazon.inapp.purchasing.NOTIFY" />
</intent-filter>
</receiver>
<activity
android:name=".purchasing.ProxyAmazonBillingActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
</application>

</manifest>
4 changes: 4 additions & 0 deletions purchases/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
alias libs.plugins.kotlin.android
alias libs.plugins.mavenPublish
alias libs.plugins.dokka
alias libs.plugins.kotlin.parcelize
}

apply from: "$rootProject.projectDir/library.gradle"
Expand Down Expand Up @@ -54,10 +55,13 @@ dependencies {
implementation libs.androidx.lifecycle.common
implementation libs.androidx.lifecycle.process

compileOnly libs.amazon.appstore.sdk

testImplementation project(":test-utils")
testImplementation libs.bundles.test
testImplementation libs.billing
testImplementation libs.coroutines.test
testImplementation libs.amazon.appstore.sdk

integrationTestImplementation libs.androidx.appcompat
integrationTestImplementation libs.material
Expand Down
10 changes: 9 additions & 1 deletion purchases/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.INTERNET" />
<application>
<activity
android:name="com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
</application>

</manifest>

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.os.Bundle
import android.os.ResultReceiver
import androidx.annotation.VisibleForTesting
import com.revenuecat.purchases.amazon.PurchasingServiceProvider
import com.revenuecat.purchases.amazon.R
import com.revenuecat.purchases.api.R

internal class ProxyAmazonBillingActivity : Activity() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.revenuecat.purchases

import android.app.Application
import android.content.Context
import android.os.Handler
import androidx.annotation.VisibleForTesting
import com.revenuecat.purchases.amazon.AmazonBilling
import com.revenuecat.purchases.common.BackendHelper
import com.revenuecat.purchases.common.BillingAbstract
import com.revenuecat.purchases.common.caching.DeviceCache
import com.revenuecat.purchases.common.diagnostics.DiagnosticsTracker
import com.revenuecat.purchases.common.errorLog
Expand All @@ -31,21 +30,14 @@ object BillingFactory {
)
Store.AMAZON -> {
try {
Class.forName("com.revenuecat.purchases.amazon.AmazonBilling")
.getConstructor(
Context::class.java,
DeviceCache::class.java,
Boolean::class.java,
Handler::class.java,
BackendHelper::class.java,
).newInstance(
application.applicationContext,
cache,
observerMode,
Handler(application.mainLooper),
backendHelper,
) as BillingAbstract
} catch (e: ClassNotFoundException) {
AmazonBilling(
application.applicationContext,
cache,
observerMode,
Handler(application.mainLooper),
backendHelper,
)
} catch (e: NoClassDefFoundError) {
errorLog("Make sure purchases-amazon is added as dependency", e)
throw e
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import com.revenuecat.purchases.amazon.helpers.dummyAmazonProduct
import com.revenuecat.purchases.amazon.helpers.dummyReceipt
import com.revenuecat.purchases.amazon.helpers.dummyUserData
import com.revenuecat.purchases.amazon.helpers.successfulRVSResponse
import com.revenuecat.purchases.common.BillingAbstract
import com.revenuecat.purchases.common.sha1
import com.revenuecat.purchases.models.PurchaseState
import com.revenuecat.purchases.models.StoreProduct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import java.math.BigDecimal
import kotlin.text.Typography.nbsp

@RunWith(AndroidJUnit4::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.revenuecat.purchases.amazon
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.revenuecat.purchases.amazon.helpers.dummyAmazonProduct
import com.revenuecat.purchases.models.Period
import com.revenuecat.purchases.models.SubscriptionOptions
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.junit.runner.RunWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,8 @@ package com.revenuecat.purchases.amazon

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.revenuecat.purchases.ProductType
import com.revenuecat.purchases.amazon.helpers.dummyAmazonProduct
import com.revenuecat.purchases.amazon.helpers.stubStoreProductForAmazon
import com.revenuecat.purchases.models.GoogleStoreProduct
import com.revenuecat.purchases.models.GoogleSubscriptionOption
import com.revenuecat.purchases.models.Period
import com.revenuecat.purchases.models.Price
import com.revenuecat.purchases.models.PricingPhase
import com.revenuecat.purchases.models.PurchasingData
import com.revenuecat.purchases.models.RecurrenceMode
import com.revenuecat.purchases.models.SubscriptionOptions
import com.revenuecat.purchases.utils.mockProductDetails
import org.assertj.core.api.AssertionsForInterfaceTypes.assertThat
import org.json.JSONObject
import org.junit.Test
Expand Down

0 comments on commit 6f336b1

Please sign in to comment.