Skip to content

Commit

Permalink
Merge pull request #27 from mvarnagiris/dev
Browse files Browse the repository at this point in the history
v0.5.4
  • Loading branch information
mvarnagiris committed May 22, 2017
2 parents 8c14287 + 0748e26 commit 84c1f3c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v0.5.4
- `fix` This time for real fixed billing crash. Maybe.

### v0.5.3
- `fix` Even more crash fixes.

Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ android {
minSdkVersion min_sdk_version
targetSdkVersion target_sdk_version
multiDexEnabled true
versionCode 13
versionName "0.5.3"
versionCode 14
versionName "0.5.4"
manifestPlaceholders = [crashlytics: privateProperties['CRASHLYTICS']]
}

Expand Down Expand Up @@ -103,7 +103,7 @@ dependencies {
exclude group: 'joda-time', module: 'joda-time'
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
transitive = true
}
compile 'com.akexorcist:RoundCornerProgressBar:2.0.3'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 Mantas Varnagiris.
* Copyright (C) 2017 Mantas Varnagiris.
*
* 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
Expand All @@ -18,4 +18,4 @@ import com.memoizrlabs.Scope
import com.memoizrlabs.Shank
import com.memoizrlabs.shankkotlin.provideSingletonFor

inline fun <reified T : Any> Scope.provideSingleton() = Shank.with(this).provideSingletonFor<T>()
inline fun <reified T : Any> Scope.provideSingletonFor() = Shank.with(this).provideSingletonFor<T>()
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (C) 2017 Mantas Varnagiris.
*
* 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; either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*/

package com.mvcoding.expensius.feature.premium

interface Billing : BillingFlow, BillingProductsService
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 Mantas Varnagiris.
* Copyright (C) 2017 Mantas Varnagiris.
*
* 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
Expand All @@ -23,7 +23,7 @@ import com.mvcoding.expensius.model.SubscriptionType.PREMIUM_PAID
import rx.Observable
import rx.Observable.just

class DummyBillingProductsService(private val appUserSource: DataSource<AppUser>) : BillingProductsService, BillingFlow {
class DummyBillingProductsService(private val appUserSource: DataSource<AppUser>) : Billing {

override fun billingProducts(): Observable<List<BillingProduct>> = appUserSource.data().first().map {
listOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 Mantas Varnagiris.
* Copyright (C) 2017 Mantas Varnagiris.
*
* 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
Expand All @@ -19,7 +19,7 @@ import com.memoizrlabs.ShankModule
import com.memoizrlabs.shankkotlin.provideSingletonFor
import com.memoizrlabs.shankkotlin.registerFactory
import com.mvcoding.expensius.BuildConfig
import com.mvcoding.expensius.extension.provideSingleton
import com.mvcoding.expensius.extension.provideSingletonFor
import com.mvcoding.expensius.feature.BaseActivity
import com.mvcoding.expensius.provideAppUserSource
import com.mvcoding.expensius.provideContext
Expand All @@ -28,24 +28,20 @@ import memoizrlabs.com.shankandroid.withThisScope

class PremiumModule : ShankModule {
override fun registerFactories() {
remoteBillingProductsService()
billingFlow()
billing()
premiumPresenter()
}

private fun remoteBillingProductsService() = registerFactory(BillingProductsService::class) { ->
private fun billing() = registerFactory(Billing::class) { ->
if (BuildConfig.DEBUG) DummyBillingProductsService(provideAppUserSource())
else BillingBillingProductsService(provideContext())
else RealBillingProductsService(provideContext())
}

private fun billingFlow() = registerFactory(BillingFlow::class) { scope: Scope -> provideBillingProductsService(scope) as BillingFlow }

private fun premiumPresenter() = registerFactory(PremiumPresenter::class) { scope: Scope ->
val billingProductsService = provideBillingProductsService(scope)
PremiumPresenter(provideAppUserSource(), provideAppUserSource(), billingProductsService, provideRxSchedulers())
PremiumPresenter(provideAppUserSource(), provideAppUserSource(), provideBilling(scope), provideRxSchedulers())
}
}

private fun provideBillingProductsService(scope: Scope): BillingProductsService = scope.provideSingleton()
fun BaseActivity.provideBillingFlow(): BillingFlow = withThisScope.provideSingletonFor(scope)
private fun provideBilling(scope: Scope) = scope.provideSingletonFor<Billing>()
fun BaseActivity.provideBillingFlow(): BillingFlow = provideBilling(scope)
fun BaseActivity.providePremiumPresenter(): PremiumPresenter = withThisScope.provideSingletonFor(scope)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 Mantas Varnagiris.
* Copyright (C) 2017 Mantas Varnagiris.
*
* 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
Expand All @@ -26,7 +26,7 @@ import com.mvcoding.expensius.model.SubscriptionType.FREE
import com.mvcoding.expensius.model.SubscriptionType.PREMIUM_PAID
import rx.Observable

class BillingBillingProductsService(context: Context) : BillingProductsService, BillingFlow {
class RealBillingProductsService(context: Context) : Billing {

private val premiumItemsIds = listOf("premium_1", "premium_2", "premium_3")

Expand Down
4 changes: 2 additions & 2 deletions billing/src/main/kotlin/com/mvcoding/billing/Purchase.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 Mantas Varnagiris.
* Copyright (C) 2017 Mantas Varnagiris.
*
* 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
Expand Down Expand Up @@ -35,7 +35,7 @@ data class Purchase(
Purchase(
ProductId(it.get("productId").asString),
productType,
OrderId(it.get("orderId").asString),
if (it.has("orderId")) OrderId(it.get("orderId").asString) else OrderId(""),
it.get("packageName").asString,
it.get("purchaseTime").asLong,
it.get("purchaseState").asInt,
Expand Down

0 comments on commit 84c1f3c

Please sign in to comment.