Update Google Play Billing Library

This commit is contained in:
Jonas Lochmann 2025-07-21 02:00:00 +02:00
parent 3d49bd8229
commit 4498aa191f
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
3 changed files with 21 additions and 7 deletions

View file

@ -218,7 +218,7 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp-tls:4.9.3' implementation 'com.squareup.okhttp3:okhttp-tls:4.9.3'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3' implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
googleApiImplementation "com.android.billingclient:billing-ktx:7.1.1" googleApiImplementation "com.android.billingclient:billing-ktx:8.0.0"
implementation('io.socket:socket.io-client:2.0.0') { implementation('io.socket:socket.io-client:2.0.0') {
exclude group: 'org.json', module: 'json' exclude group: 'org.json', module: 'json'

View file

@ -1,5 +1,5 @@
/* /*
* TimeLimit Copyright <C> 2019 - 2023 Jonas Lochmann * TimeLimit Copyright <C> 2019 - 2025 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -74,9 +74,14 @@ class ActivityPurchaseModel(application: Application): AndroidViewModel(applicat
clientMutex.withLock { clientMutex.withLock {
if (_billingClient == null) { if (_billingClient == null) {
_billingClient = BillingClient.newBuilder(getApplication()) _billingClient = BillingClient.newBuilder(getApplication())
.enablePendingPurchases() .enablePendingPurchases(
.setListener(purchaseUpdatedListener) PendingPurchasesParams
.build() .newBuilder()
.enableOneTimeProducts()
.build()
)
.setListener(purchaseUpdatedListener)
.build()
} }
val initBillingClient = _billingClient!! val initBillingClient = _billingClient!!

View file

@ -1,5 +1,5 @@
/* /*
* TimeLimit Copyright <C> 2019 - 2022 Jonas Lochmann * TimeLimit Copyright <C> 2019 - 2025 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -42,7 +42,7 @@ object BillingClient {
enum class ProductType { INAPP } enum class ProductType { INAPP }
object Builder { object Builder {
fun enablePendingPurchases() = this fun enablePendingPurchases(params: PendingPurchasesParams) = this
fun setListener(listener: PurchasesUpdatedListener) = this fun setListener(listener: PurchasesUpdatedListener) = this
fun build() = BillingClient fun build() = BillingClient
} }
@ -144,3 +144,12 @@ object QueryPurchasesParams {
fun setProductType(type: BillingClient.ProductType) = this fun setProductType(type: BillingClient.ProductType) = this
fun build() = this fun build() = this
} }
object PendingPurchasesParams {
object Builder {
fun enableOneTimeProducts() = this
fun build() = PendingPurchasesParams
}
fun newBuilder() = Builder
}