From 95479de3afed369cef8dccfc0957e7a5b982c50b Mon Sep 17 00:00:00 2001 From: Jahir Fiquitiva Date: Sun, 30 Jun 2024 11:58:41 -0500 Subject: [PATCH] feat: update dependencies and gradle, update in-app-billing implementation --- buildSrc/src/main/java/Frames.kt | 4 ++-- buildSrc/src/main/java/Versions.kt | 24 +++++++++---------- gradle/wrapper/gradle-wrapper.properties | 2 +- .../data/viewmodels/BillingViewModel.kt | 13 +++++++--- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/buildSrc/src/main/java/Frames.kt b/buildSrc/src/main/java/Frames.kt index 78b1cdc97..426cb0be4 100644 --- a/buildSrc/src/main/java/Frames.kt +++ b/buildSrc/src/main/java/Frames.kt @@ -2,6 +2,6 @@ object Frames { const val appId = "dev.jahir.frames.app" - const val version = 361 - const val versionName = "3.6.1" + const val version = 362 + const val versionName = "3.6.2" } diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index f8b69f1ea..b715ab461 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -2,13 +2,13 @@ object Versions { // Plugins - const val gradle = "8.3.0" - const val kotlin = "1.9.23" + const val gradle = "8.5.0" + const val kotlin = "2.0.0" const val sonatype = "1.3.0" - const val ksp = "$kotlin-1.0.20" + const val ksp = "$kotlin-1.0.22" // OneSignal - const val oneSignal = "4.8.8" + const val oneSignal = "4.8.10" // App const val minSdk = 21 @@ -16,21 +16,21 @@ object Versions { const val buildTools = "34.0.0" // Coroutines - const val coroutines = "1.8.0" + const val coroutines = "1.8.1" // Android UI - const val appcompat = "1.6.1" + const val appcompat = "1.7.0" const val cardView = "1.0.0" const val recyclerView = "1.3.2" const val swipeRefreshLayout = "1.1.0" const val palette = "1.0.0" const val preference = "1.2.1" - const val materialComponents = "1.11.0" + const val materialComponents = "1.12.0" const val activityKtx = "1.9.0" - const val fragmentKtx = "1.6.2" + const val fragmentKtx = "1.8.1" // ViewModel and LiveData - const val lifecycle = "2.7.0" + const val lifecycle = "2.8.2" const val lifecycleExt = "2.2.0" // Room Database @@ -40,7 +40,7 @@ object Versions { const val work = "2.9.0" // Network & Serialization - const val gson = "2.10.1" + const val gson = "2.11.0" const val retrofit = "2.11.0" // Image loading and Touch Image View @@ -63,11 +63,11 @@ object Versions { const val licenseChecker = "1.2.8" // In-App Billing - const val inAppBilling = "6.2.1" + const val inAppBilling = "7.0.0" // MultiDex const val multidex = "2.0.1" // Muzei - const val muzei = "3.4.1" + const val muzei = "3.4.2" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 47040d6e1..8804d3f3e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jul 19 11:05:13 CEST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/library/src/main/kotlin/dev/jahir/frames/data/viewmodels/BillingViewModel.kt b/library/src/main/kotlin/dev/jahir/frames/data/viewmodels/BillingViewModel.kt index a5117cc9c..231a34b7f 100644 --- a/library/src/main/kotlin/dev/jahir/frames/data/viewmodels/BillingViewModel.kt +++ b/library/src/main/kotlin/dev/jahir/frames/data/viewmodels/BillingViewModel.kt @@ -11,6 +11,7 @@ import com.android.billingclient.api.BillingClientStateListener import com.android.billingclient.api.BillingFlowParams import com.android.billingclient.api.BillingResult import com.android.billingclient.api.ConsumeParams +import com.android.billingclient.api.PendingPurchasesParams import com.android.billingclient.api.ProductDetails import com.android.billingclient.api.Purchase import com.android.billingclient.api.PurchasesUpdatedListener @@ -18,6 +19,7 @@ import com.android.billingclient.api.QueryProductDetailsParams import com.android.billingclient.api.QueryPurchaseHistoryParams import com.android.billingclient.api.QueryPurchasesParams import com.android.billingclient.api.consumePurchase +import com.android.billingclient.api.queryPurchasesAsync import dev.jahir.frames.data.listeners.BillingProcessesListener import dev.jahir.frames.data.models.DetailedPurchaseRecord import dev.jahir.frames.extensions.utils.asDetailedPurchase @@ -61,7 +63,10 @@ class BillingViewModel(application: Application) : AndroidViewModel(application) billingClient = BillingClient .newBuilder(context) .setListener(this) - .enablePendingPurchases() + .enablePendingPurchases( + PendingPurchasesParams.newBuilder() + .enableOneTimeProducts().build() + ) .build() billingClient?.startConnection(this) } @@ -94,6 +99,7 @@ class BillingViewModel(application: Application) : AndroidViewModel(application) BillingClient.ProductType.INAPP -> { inAppProductDetailsData.postValue(details) } + BillingClient.ProductType.SUBS -> { subscriptionsProductDetailsData.postValue(details) } @@ -147,6 +153,7 @@ class BillingViewModel(application: Application) : AndroidViewModel(application) actualPurchases.sortedByDescending { it.purchaseTime } ) } + BillingClient.ProductType.SUBS -> { subscriptionsPurchasesHistoryData.postValue( actualPurchases.sortedByDescending { it.purchaseTime } @@ -170,9 +177,9 @@ class BillingViewModel(application: Application) : AndroidViewModel(application) private suspend fun queryPurchasesHistory(@BillingClient.ProductType productType: String) { if (!isBillingClientReady) return - val params = QueryPurchaseHistoryParams.newBuilder().setProductType(productType).build() + val params = QueryPurchasesParams.newBuilder().setProductType(productType).build() withContext(IO) { - billingClient?.queryPurchaseHistoryAsync(params) { billingResult, purchaseHistoryRecordList -> + billingClient?.queryPurchasesAsync(params) { billingResult, purchaseHistoryRecordList -> if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) { postPurchasesHistory(productType, purchaseHistoryRecordList.orEmpty()