mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-25 20:29:48 +00:00
android: add google and foss build flavors (#7328)
* android: add google and foss build flavors * android: get the Google Play account country in the google flavor * android, desktop: update whats new * temp: comment out wefunder link
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
package chat.simplex.app
|
||||
|
||||
// Play Billing is only in the google flavor, so the Play country stays unknown here
|
||||
fun loadPlayStoreCountry() {}
|
||||
@@ -0,0 +1,31 @@
|
||||
package chat.simplex.app
|
||||
|
||||
import chat.simplex.common.platform.androidAppContext
|
||||
import chat.simplex.common.platform.androidPlayStoreCountry
|
||||
import com.android.billingclient.api.*
|
||||
|
||||
// Requests the country of the Google Play account into [androidPlayStoreCountry].
|
||||
// It stays null when Play is unavailable or the user is not signed in.
|
||||
fun loadPlayStoreCountry() {
|
||||
val client = BillingClient.newBuilder(androidAppContext)
|
||||
.setListener { _, _ -> }
|
||||
.enablePendingPurchases(PendingPurchasesParams.newBuilder().enableOneTimeProducts().build())
|
||||
.build()
|
||||
client.startConnection(object : BillingClientStateListener {
|
||||
override fun onBillingSetupFinished(result: BillingResult) {
|
||||
if (result.responseCode != BillingClient.BillingResponseCode.OK) {
|
||||
client.endConnection()
|
||||
return
|
||||
}
|
||||
client.getBillingConfigAsync(GetBillingConfigParams.newBuilder().build()) { configResult, config ->
|
||||
if (configResult.responseCode == BillingClient.BillingResponseCode.OK) {
|
||||
androidPlayStoreCountry.value = config?.countryCode
|
||||
}
|
||||
client.endConnection()
|
||||
}
|
||||
}
|
||||
|
||||
// The connection is only used for this one request, it is not retried
|
||||
override fun onBillingServiceDisconnected() = client.endConnection()
|
||||
})
|
||||
}
|
||||
@@ -341,6 +341,8 @@ class SimplexApp: Application(), LifecycleEventObserver {
|
||||
|
||||
override fun androidIsXiaomiDevice(): Boolean = setOf("xiaomi", "redmi", "poco").contains(Build.BRAND.lowercase())
|
||||
|
||||
override fun androidLoadPlayStoreCountry() = loadPlayStoreCountry()
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
@Composable
|
||||
override fun androidLockPortraitOrientation() {
|
||||
@@ -370,6 +372,8 @@ class SimplexApp: Application(), LifecycleEventObserver {
|
||||
override fun androidCreateActiveCallState(): Closeable = ActiveCallState()
|
||||
|
||||
override val androidApiLevel: Int get() = Build.VERSION.SDK_INT
|
||||
|
||||
override val androidIsPlayStoreBuild: Boolean get() = BuildConfig.PLAY_STORE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user