Skip to content

Commit

Permalink
Updated the minSdk version to 16
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaaatt committed Jul 25, 2021
1 parent d9ae433 commit ad628f4
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 40 deletions.
5 changes: 2 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.4.0-rc01'
implementation 'com.google.android.material:material:1.5.0-alpha01'

implementation 'com.intuit.sdp:sdp-android:1.0.6'

implementation project(':iap')
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.android.billingclient:billing-ktx:4.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

class JavaSampleActivity extends AppCompatActivity {

private ActivityMainBinding binding;

protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

List<String> nonConsumablesList = Collections.singletonList("lifetime");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class KotlinSampleActivity : AppCompatActivity() {
override fun onProductPurchased(purchaseInfo: DataWrappers.PurchaseInfo) {
when (purchaseInfo.sku) {
"base" -> {

purchaseInfo.orderId
}
"moderate" -> {

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.5.10'
ext.kotlin_coroutines_version = '1.5.0-native-mt'
ext.kotlin_version = '1.5.21'
ext.kotlin_coroutines_version = '1.5.1-native-mt'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
6 changes: 3 additions & 3 deletions iap/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ android {
compileSdkVersion 30

defaultConfig {
minSdkVersion 17
minSdkVersion 16
targetSdkVersion 30
versionCode 17
versionCode 16
versionName "1.1.6"
}

Expand All @@ -32,5 +32,5 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.10.0'
testImplementation 'org.mockito:mockito-core:3.11.2'
}
27 changes: 14 additions & 13 deletions iap/src/main/java/com/limerse/iap/BillingService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch

class BillingService(private val context: Context,
private val nonConsumableKeys: List<String>,
private val consumableKeys: List<String>,
private val subscriptionSkuKeys: List<String>)
: IBillingService(), PurchasesUpdatedListener, BillingClientStateListener, AcknowledgePurchaseResponseListener {
class BillingService(
private val context: Context,
private val nonConsumableKeys: List<String>,
private val consumableKeys: List<String>,
private val subscriptionSkuKeys: List<String>
) : IBillingService(), PurchasesUpdatedListener, BillingClientStateListener, AcknowledgePurchaseResponseListener {

private lateinit var mBillingClient: BillingClient
private var decodedKey: String? = null
Expand Down Expand Up @@ -80,7 +81,7 @@ class BillingService(private val context: Context,
sku.toSkuDetails(type) { skuDetails ->
if (skuDetails != null) {
val purchaseParams = BillingFlowParams.newBuilder()
.setSkuDetails(skuDetails).build()
.setSkuDetails(skuDetails).build()
mBillingClient.launchBillingFlow(activity, purchaseParams)
}
}
Expand Down Expand Up @@ -130,10 +131,10 @@ class BillingService(private val context: Context,
BillingClient.BillingResponseCode.DEVELOPER_ERROR ->
Log.e(
TAG, "onPurchasesUpdated: Developer error means that Google Play " +
"does not recognize the configuration. If you are just getting started, " +
"make sure you have configured the application correctly in the " +
"Google Play Console. The SKU product ID must match and the APK you " +
"are using must be signed with release keys."
"does not recognize the configuration. If you are just getting started, " +
"make sure you have configured the application correctly in the " +
"Google Play Console. The SKU product ID must match and the APK you " +
"are using must be signed with release keys."
)
}
}
Expand Down Expand Up @@ -169,7 +170,7 @@ class BillingService(private val context: Context,
}
}
}
else{
else{
productOwned(getPurchaseInfo(purchase), isRestore)
}
}
Expand All @@ -181,13 +182,13 @@ class BillingService(private val context: Context,
// Acknowledge the purchase if it hasn't already been acknowledged.
if (!purchase.isAcknowledged) {
val acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder()
.setPurchaseToken(purchase.purchaseToken).build()
.setPurchaseToken(purchase.purchaseToken).build()
mBillingClient.acknowledgePurchase(acknowledgePurchaseParams, this)
}
} else {
Log.e(
TAG, "processPurchases failed. purchase: $purchase " +
"purchaseState: ${purchase.purchaseState} isSkuReady: ${purchase.skus[0].isSkuReady()}")
"purchaseState: ${purchase.purchaseState} isSkuReady: ${purchase.skus[0].isSkuReady()}")
}
}
} else {
Expand Down
29 changes: 15 additions & 14 deletions iap/src/test/java/com/limerse/iap/BillingTest.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import android.content.Context
import com.limerse.iap.DataWrappers
import com.limerse.iap.IapConnector
import com.limerse.iap.PurchaseServiceListener
import com.limerse.iap.SubscriptionServiceListener
Expand Down Expand Up @@ -26,11 +27,11 @@ class BillingTest {
)
iapConnector.addPurchaseListener(secondListener)
iapConnector.getBillingService()
.productOwnedInternal(TestConstants.TEST_SKU, false)
.productOwnedInternal(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU), false)
Mockito.verify(firstListener, Mockito.times(1))
.onProductPurchased(TestConstants.TEST_SKU)
.onProductPurchased(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU))
Mockito.verify(secondListener, Mockito.times(1))
.onProductPurchased(TestConstants.TEST_SKU)
.onProductPurchased(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU))
}

@Test
Expand Down Expand Up @@ -64,10 +65,10 @@ class BillingTest {
)
iapConnector.addPurchaseListener(secondListener)
iapConnector.removePurchaseListener(firstListener)
iapConnector.getBillingService().productOwnedInternal(TestConstants.Companion.TEST_SKU, false)
Mockito.verify(firstListener, Mockito.never()).onProductPurchased(Mockito.anyString())
iapConnector.getBillingService().productOwnedInternal(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU), false)
Mockito.verify(firstListener, Mockito.never()).onProductPurchased(Mockito.any())
Mockito.verify(secondListener, Mockito.times(1))
.onProductPurchased(TestConstants.Companion.TEST_SKU)
.onProductPurchased(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU))
}

@Test
Expand All @@ -77,9 +78,9 @@ class BillingTest {
PurchaseServiceListener::class.java
)
iapConnector.addPurchaseListener(listener)
iapConnector.getBillingService().productOwnedInternal(TestConstants.Companion.TEST_SKU, false)
iapConnector.getBillingService().productOwnedInternal(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU), false)
Mockito.verify(listener, Mockito.times(1))
.onProductPurchased(TestConstants.Companion.TEST_SKU)
.onProductPurchased(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU))
}

@Test
Expand All @@ -89,9 +90,9 @@ class BillingTest {
PurchaseServiceListener::class.java
)
iapConnector.addPurchaseListener(listener)
iapConnector.getBillingService().productOwnedInternal(TestConstants.TEST_SKU, true)
iapConnector.getBillingService().productOwnedInternal(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU), true)
Mockito.verify(listener, Mockito.times(1))
.onProductRestored(TestConstants.TEST_SKU)
.onProductRestored(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU))
}

@Test
Expand All @@ -102,9 +103,9 @@ class BillingTest {
)
iapConnector.addSubscriptionListener(listener)
iapConnector.getBillingService()
.subscriptionOwnedInternal(TestConstants.TEST_SKU, false)
.subscriptionOwnedInternal(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU), false)
Mockito.verify(listener, Mockito.times(1))
.onSubscriptionPurchased(TestConstants.TEST_SKU)
.onSubscriptionPurchased(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU))
}

@Test
Expand All @@ -115,8 +116,8 @@ class BillingTest {
)
iapConnector.addSubscriptionListener(listener)
iapConnector.getBillingService()
.subscriptionOwnedInternal(TestConstants.TEST_SKU, true)
.subscriptionOwnedInternal(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU), true)
Mockito.verify(listener, Mockito.times(1))
.onSubscriptionRestored(TestConstants.TEST_SKU)
.onSubscriptionRestored(DataWrappers.PurchaseInfo(sku = TestConstants.TEST_SKU))
}
}

0 comments on commit ad628f4

Please sign in to comment.