Browse Source

Build noGoogleApi flavor without in app billing library

master
Jonas Lochmann 1 week ago
parent
commit
a357f2f702
Signed by: Jonas Lochmann <git@inkompetenz.org> GPG Key ID: 8B8C9AEE10FA5B36
12 changed files with 311 additions and 1 deletions
  1. +1
    -1
      app/build.gradle
  2. +35
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/ActivityCheckout.kt
  3. +24
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/Billing.kt
  4. +37
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/BillingRequests.kt
  5. +50
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/Checkout.kt
  6. +44
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/Inventory.kt
  7. +21
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/ProductTypes.kt
  8. +18
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/Purchase.kt
  9. +19
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/PurchaseFlow.kt
  10. +22
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/RequestListener.kt
  11. +19
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/Sku.kt
  12. +21
    -0
      app/src/noGoogleApi/java/org/solovyev/android/checkout/Skus.kt

+ 1
- 1
app/build.gradle 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'

+ 35
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/ActivityCheckout.kt 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
}

+ 24
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/Billing.kt 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
}
}

+ 37
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/BillingRequests.kt 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
}
}

+ 50
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/Checkout.kt 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)
}
}

+ 44
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/Inventory.kt 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)
}
}
}

+ 21
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/ProductTypes.kt 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 = ""
}

+ 18
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/Purchase.kt 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)

+ 19
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/PurchaseFlow.kt 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

+ 22
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/RequestListener.kt 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)
}

+ 19
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/Sku.kt 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)

+ 21
- 0
app/src/noGoogleApi/java/org/solovyev/android/checkout/Skus.kt 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
}

Loading…
Cancel
Save