Skip to content

Commit

Permalink
Remove common module (#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
vegaro authored Jul 5, 2023
1 parent 575ee9c commit ef34062
Show file tree
Hide file tree
Showing 208 changed files with 236 additions and 327 deletions.
1 change: 0 additions & 1 deletion common/.gitignore

This file was deleted.

43 changes: 0 additions & 43 deletions common/build.gradle

This file was deleted.

2 changes: 0 additions & 2 deletions common/consumer-rules.pro

This file was deleted.

3 changes: 0 additions & 3 deletions common/gradle.properties

This file was deleted.

21 changes: 0 additions & 21 deletions common/proguard-rules.pro

This file was deleted.

2 changes: 0 additions & 2 deletions common/src/main/AndroidManifest.xml

This file was deleted.

6 changes: 3 additions & 3 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ platform :android do

desc "Build purchases module integration tests pointing to production"
lane :run_backend_integration_tests do |options|
constants_path = './common/src/test/java/com/revenuecat/purchases/backend_integration_tests/Constants.kt'
constants_path = './purchases/src/test/java/com/revenuecat/purchases/backend_integration_tests/Constants.kt'
replace_text_in_files(
previous_text: 'REVENUECAT_API_KEY',
new_text: ENV['REVENUECAT_API_KEY'],
Expand All @@ -175,10 +175,10 @@ platform :android do
new_text: ENV['LOAD_SHEDDER_REVENUECAT_API_KEY'],
paths_of_files_to_update: [constants_path]
)
# Runing integration test flavor in order to make backend tests run faster, since the jittering is too
# Running integration test flavor in order to make backend tests run faster, since the jittering is too
# long in the `defaults` flavor.
gradle(
task: ':common:testIntegrationTestDebugUnitTest',
task: ':purchases:testIntegrationTestDebugUnitTest',
properties: {
"RUN_INTEGRATION_TESTS" => true
}
Expand Down
1 change: 0 additions & 1 deletion feature/amazon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ android {

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

implementation libs.amazon.appstore.sdk
}
1 change: 0 additions & 1 deletion public/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ dependencies {
implementation libs.billing
implementation libs.kotlin.stdlib

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

Expand Down
4 changes: 2 additions & 2 deletions public/src/main/java/com/revenuecat/purchases/CustomerInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import android.os.Parcelable
import com.revenuecat.purchases.models.RawDataContainer
import com.revenuecat.purchases.models.Transaction
import com.revenuecat.purchases.utils.DateHelperDupe
import com.revenuecat.purchases.utils.JSONObjectParceler
import com.revenuecat.purchases.utils.JSONObjectParcelerDupe
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.TypeParceler
Expand Down Expand Up @@ -38,7 +38,7 @@ import java.util.Date
* Use this for grandfathering users when migrating to subscriptions. This can be null, see -Purchases.restorePurchases
*/
@Parcelize
@TypeParceler<JSONObject, JSONObjectParceler>()
@TypeParceler<JSONObject, JSONObjectParcelerDupe>()
data class CustomerInfo constructor(
val entitlements: EntitlementInfos,
val allExpirationDatesByProduct: Map<String, Date?>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.revenuecat.purchases

import android.os.Parcelable
import com.revenuecat.purchases.models.RawDataContainer
import com.revenuecat.purchases.utils.JSONObjectParceler
import com.revenuecat.purchases.utils.JSONObjectParcelerDupe
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.TypeParceler
Expand Down Expand Up @@ -37,7 +37,7 @@ import java.util.Date
* If not, [VerificationResult.NOT_REQUESTED]
*/
@Parcelize
@TypeParceler<JSONObject, JSONObjectParceler>()
@TypeParceler<JSONObject, JSONObjectParcelerDupe>()
data class EntitlementInfo(
val identifier: String,
val isActive: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.revenuecat.purchases.models
import android.os.Parcelable
import com.revenuecat.purchases.ProductType
import com.revenuecat.purchases.ProrationMode
import com.revenuecat.purchases.utils.JSONObjectParceler
import com.revenuecat.purchases.utils.JSONObjectParcelerDupe
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.TypeParceler
Expand All @@ -13,7 +13,7 @@ import org.json.JSONObject
* Represents an in-app billing purchase.
*/
@Parcelize
@TypeParceler<JSONObject, JSONObjectParceler>()
@TypeParceler<JSONObject, JSONObjectParcelerDupe>()
data class StoreTransaction(
/**
* Unique Google order identifier for the purchased transaction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ class SubscriptionOptions(
}.minByOrNull { it.second }?.first
}

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun billingPeriodToDays(period: Period): Int {
// TODO make internal
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
fun billingPeriodToDays(period: Period): Int {
val days = DAYS_IN_UNIT[period.unit] ?: 0
return period.value * days
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.revenuecat.purchases.utils

import android.os.Parcel
import kotlinx.parcelize.Parceler
import org.json.JSONObject

/** @suppress */
internal object JSONObjectParcelerDupe : Parceler<JSONObject> {

override fun create(parcel: Parcel): JSONObject {
return JSONObject(parcel.readString())
}

override fun JSONObject.write(parcel: Parcel, flags: Int) {
parcel.writeString(this.toString())
}
}
27 changes: 22 additions & 5 deletions purchases/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ apply from: "$rootProject.projectDir/library.gradle"
android {
namespace 'com.revenuecat.purchases.api'

buildFeatures {
buildConfig true
}

productFlavors {
integrationTest {
testApplicationId obtainTestApplicationId()
Expand All @@ -21,6 +25,18 @@ android {
}
}
}

testOptions {
unitTests {
all {
if (project.hasProperty('RUN_INTEGRATION_TESTS')) {
include "com/revenuecat/purchases/backend_integration_tests/**"
} else {
exclude "com/revenuecat/purchases/backend_integration_tests/**"
}
}
}
}
}

def obtainTestApplicationId() {
Expand All @@ -45,23 +61,26 @@ def obtainTestBuildType() {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(":common")
api project(":public")

implementation libs.kotlin.stdlib
implementation libs.androidx.core
implementation libs.androidx.annotation
api libs.billing
implementation libs.androidx.lifecycle.runtime
implementation libs.androidx.lifecycle.common
implementation libs.androidx.lifecycle.process
api libs.billing
implementation libs.tink
implementation libs.playServices.ads.identifier

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
testImplementation libs.okhttp.mockwebserver
testImplementation libs.playServices.ads.identifier

integrationTestImplementation libs.androidx.appcompat
integrationTestImplementation libs.material
Expand Down Expand Up @@ -100,9 +119,7 @@ tasks.dokkaHtmlPartial.configure {
// after https://github.com/Kotlin/kotlinx-kover/issues/362 is fixed
project.afterEvaluate {
dependencies {
kover(project(":common"))
kover(project(":feature:amazon"))
kover(project(":public"))
kover(project(":test-utils"))
}
}
4 changes: 3 additions & 1 deletion purchases/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
-keep class com.revenuecat.** { *; }
-keep class androidx.lifecycle.DefaultLifecycleObserver
-keep class androidx.lifecycle.DefaultLifecycleObserver
-dontwarn com.google.errorprone.annotations.CanIgnoreReturnValue
-dontwarn com.google.errorprone.annotations.Immutable
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.revenuecat.purchases.common
import kotlin.time.Duration.Companion.milliseconds

// These values are modified in the `integrationTest` flavor to make the tests run faster.
object DispatcherConstants {
internal object DispatcherConstants {
val jitterDelay = 5000L.milliseconds
val jitterLongDelay = 10000L.milliseconds
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.revenuecat.purchases.common
import kotlin.time.Duration.Companion.milliseconds

// These values are reduced from the values used in the original code to make the tests run faster.
object DispatcherConstants {
internal object DispatcherConstants {
val jitterDelay = 500L.milliseconds
val jitterLongDelay = 1000L.milliseconds
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typealias PostAmazonReceiptCallback = Pair<(response: JSONObject) -> Unit, (Purc
/** @suppress */
typealias CallbackCacheKey = List<String>

class AmazonBackend(
internal class AmazonBackend(
private val backendHelper: BackendHelper,
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.revenuecat.purchases.common.OfferingParser
import com.revenuecat.purchases.models.StoreProduct
import org.json.JSONObject

class AmazonOfferingParser : OfferingParser() {
internal class AmazonOfferingParser : OfferingParser() {
override fun findMatchingProduct(
productsById: Map<String, List<StoreProduct>>,
packageJson: JSONObject,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.revenuecat.purchases.common.log
import com.revenuecat.purchases.utils.DefaultTimestampProvider
import com.revenuecat.purchases.utils.TimestampProvider

class UserDataHandler(
internal class UserDataHandler(
private val purchasingServiceProvider: PurchasingServiceProvider,
private val mainHandler: Handler,
private val timestampProvider: TimestampProvider = DefaultTimestampProvider(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package com.revenuecat.purchases.common
import java.nio.ByteBuffer
import java.nio.ByteOrder

fun Int.Companion.fromLittleEndianBytes(byteArray: ByteArray): Int {
internal fun Int.Companion.fromLittleEndianBytes(byteArray: ByteArray): Int {
return ByteBuffer.wrap(byteArray).order(ByteOrder.LITTLE_ENDIAN).int
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.revenuecat.purchases.utils.Result
import java.util.Date
import kotlin.time.Duration.Companion.days

class IntermediateSignatureHelper(
internal class IntermediateSignatureHelper(
private val rootSignatureVerifier: SignatureVerifier,
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ private fun ByteArray.copyOf(component: Signature.Component): ByteArray {
return copyOfRange(component.startByte, component.endByte)
}

data class Signature(
internal data class Signature(
val intermediateKey: ByteArray,
val intermediateKeyExpiration: ByteArray,
val intermediateKeySignature: ByteArray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.revenuecat.purchases.common.errorLog
import com.revenuecat.purchases.common.subscriberattributes.DeviceIdentifiersFetcher
import com.revenuecat.purchases.google.attribution.GoogleDeviceIdentifiersFetcher

object AttributionFetcherFactory {
internal object AttributionFetcherFactory {

fun createAttributionFetcher(
store: Store,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ package com.revenuecat.purchases

import android.app.Application
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.caching.DeviceCache
import com.revenuecat.purchases.common.diagnostics.DiagnosticsTracker
import com.revenuecat.purchases.common.errorLog
import com.revenuecat.purchases.google.BillingWrapper

@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
object BillingFactory {
internal object BillingFactory {

@Suppress("LongParameterList")
fun createBilling(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.revenuecat.purchases

import androidx.annotation.VisibleForTesting
import com.revenuecat.purchases.common.GoogleOfferingParser
import com.revenuecat.purchases.common.OfferingParser
import com.revenuecat.purchases.common.errorLog

@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
object OfferingParserFactory {
internal object OfferingParserFactory {

fun createOfferingParser(
store: Store,
Expand Down
Loading

0 comments on commit ef34062

Please sign in to comment.