Build noGoogleApi flavor without in app billing library

This commit is contained in:
Jonas Lochmann 2019-12-02 00:00:00 +00:00
parent 9e628c7826
commit a357f2f702
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
12 changed files with 311 additions and 1 deletions

View file

@ -195,7 +195,7 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
implementation 'org.solovyev.android:checkout:1.2.1'
googleApiImplementation 'org.solovyev.android:checkout:1.2.1'
implementation('io.socket:socket.io-client:1.0.0') {
exclude group: 'org.json', module: 'json'

View file

@ -0,0 +1,35 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
import android.content.Intent
object ActivityCheckout: Checkout() {
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
// do nothing
}
fun start() {
// do nothing
}
fun createPurchaseFlow(listener: RequestListener<Purchase>) {
// do nothing
}
val purchaseFlow = PurchaseFlow
}

View file

@ -0,0 +1,24 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
import android.app.Application
class Billing(application: Application, config: DefaultConfiguration) {
abstract class DefaultConfiguration {
abstract fun getPublicKey(): String
}
}

View file

@ -0,0 +1,37 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
import io.timelimit.android.async.Threads
object BillingRequests {
fun consume(token: String, listener: RequestListener<Any>) {
Threads.mainThreadHandler.post {
listener.onSuccess(0)
}
}
fun getSkus(product: String, skus: List<String>, listener: RequestListener<Skus>) {
Threads.mainThreadHandler.post {
listener.onSuccess(Skus)
}
}
fun purchase(productType: String, sku: String, something: Unit?, purchaseFlow: PurchaseFlow) {
// do nothing
}
}

View file

@ -0,0 +1,50 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
import android.app.Activity
import io.timelimit.android.async.Threads
open class Checkout {
companion object {
private val instance = Checkout()
fun forActivity(activity: Activity, billing: Billing) = ActivityCheckout
fun forApplication(billing: Billing) = instance
}
fun start(listener: EmptyListener) {
Threads.mainThreadHandler.post {
listener.onReady(
billingSupported = false,
product = "",
requests = BillingRequests
)
}
}
fun whenReady(listener: EmptyListener) = start(listener)
fun stop() {
// nothing to do
}
fun makeInventory() = Inventory
abstract class EmptyListener {
abstract fun onReady(requests: BillingRequests, product: String, billingSupported: Boolean)
}
}

View file

@ -0,0 +1,44 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
import io.timelimit.android.async.Threads
object Inventory {
object Products {
object Type {
val purchases = emptyList<Purchase>()
}
operator fun get(type: String) = Type
}
object Request {
fun create() = this
fun loadAllPurchases() = this
}
interface Callback {
fun onLoaded(products: Inventory.Products)
}
fun load(request: Inventory.Request, callback: Callback) {
Threads.mainThreadHandler.post {
callback.onLoaded(Products)
}
}
}

View file

@ -0,0 +1,21 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
object ProductTypes {
const val IN_APP = ""
}

View file

@ -0,0 +1,18 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
data class Purchase (val data: String, val signature: String, val token: String, val sku: String)

View file

@ -0,0 +1,19 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
object PurchaseFlow

View file

@ -0,0 +1,22 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
interface RequestListener<T> {
fun onSuccess(result: T)
fun onError(response: Int, e: Exception)
}

View file

@ -0,0 +1,19 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
data class Sku(val description: String, val price: String)

View file

@ -0,0 +1,21 @@
/*
* TimeLimit Copyright <C> 2019 Jonas Lochmann
*
* 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
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.solovyev.android.checkout
object Skus {
fun getSku(skuId: String): Sku? = null
}