diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-30 15:57:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-30 15:57:27 -0700 |
commit | 14185936f46160997ef9eaae92cb3c8eacae93c5 (patch) | |
tree | 616d132c4191cd025788e9d7faa9654cf20fa9fd /app/src/main/kotlin/com/pitchedapps/frost/utils/iab | |
parent | d94bc858c8a0c273d87d705eb06d35cfd9cf9e08 (diff) | |
download | frost-14185936f46160997ef9eaae92cb3c8eacae93c5.tar.gz frost-14185936f46160997ef9eaae92cb3c8eacae93c5.tar.bz2 frost-14185936f46160997ef9eaae92cb3c8eacae93c5.zip |
Intro (#100)v1.4.1
* Create base activity
* Created some testers
* Update theme and fix mess up
* Update theme and replace paint
* WIP intro drawables
* Create intro screens
* Clear unnecessary dependencies
* Finalize intro panels
* Clean up intro
* Attack intro to settings
* Fix lint
* Finalize intro
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/iab')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABBinder.kt | 26 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt | 6 |
2 files changed, 17 insertions, 15 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABBinder.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABBinder.kt index ab9e37d1..b3992ff4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABBinder.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABBinder.kt @@ -34,7 +34,7 @@ abstract class IABBinder : FrostBilling { override fun Activity.onCreateBilling() { activity = this bp = BillingProcessor.newBillingProcessor(this, PUBLIC_BILLING_KEY, this@IABBinder) - bp!!.initialize() + bp?.initialize() } override fun onDestroyBilling() { @@ -79,10 +79,10 @@ abstract class IABBinder : FrostBilling { L.eThrow("IAB null bp on purchase attempt") return } - if (!bp!!.isOneTimePurchaseSupported) - activity!!.playStorePurchaseUnsupported() + if (!(bp?.isOneTimePurchaseSupported ?: false)) + activity?.playStorePurchaseUnsupported() else - bp!!.purchase(activity, FROST_PRO) + bp?.purchase(activity, FROST_PRO) } } @@ -104,14 +104,14 @@ class IABSettings : IABBinder() { */ override fun restorePurchases() { if (bp == null) return - val load = bp!!.loadOwnedPurchasesFromGoogle() + val load = bp?.loadOwnedPurchasesFromGoogle() ?: return L.d("IAB settings load from google $load") - if (!bp!!.isPurchased(FROST_PRO)) { - if (Prefs.pro) activity!!.playStoreNoLongerPro() + if (!(bp?.isPurchased(FROST_PRO) ?: return)) { + if (Prefs.pro) activity.playStoreNoLongerPro() else purchasePro() } else { - if (!Prefs.pro) activity!!.playStoreFoundPro() - else activity!!.purchaseRestored() + if (!Prefs.pro) activity.playStoreFoundPro() + else activity?.purchaseRestored() } } } @@ -138,12 +138,12 @@ class IABMain : IABBinder() { override fun restorePurchases() { if (restored || bp == null) return restored = true - val load = bp!!.loadOwnedPurchasesFromGoogle() + val load = bp?.loadOwnedPurchasesFromGoogle() ?: false L.d("IAB main load from google $load") - if (!bp!!.isPurchased(FROST_PRO)) { - if (Prefs.pro) activity!!.playStoreNoLongerPro() + if (!(bp?.isPurchased(FROST_PRO) ?: false)) { + if (Prefs.pro) activity.playStoreNoLongerPro() } else { - if (!Prefs.pro) activity!!.playStoreFoundPro() + if (!Prefs.pro) activity.playStoreFoundPro() } onDestroyBilling() } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt index d2f22829..df0f04fd 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt @@ -31,7 +31,7 @@ private fun Activity.playRestart() { } else restart() } -fun Activity.playStoreNoLongerPro() { +fun Activity?.playStoreNoLongerPro() { Prefs.pro = false L.d("IAB No longer pro") frostAnswers { @@ -39,6 +39,7 @@ fun Activity.playStoreNoLongerPro() { .putCustomAttribute("result", "no longer pro") .putSuccess(false)) } + if (this == null) return materialDialogThemed { title(R.string.uh_oh) content(R.string.play_store_not_pro) @@ -49,9 +50,10 @@ fun Activity.playStoreNoLongerPro() { } } -fun Activity.playStoreFoundPro() { +fun Activity?.playStoreFoundPro() { Prefs.pro = true L.d("Found pro") + if (this == null) return materialDialogThemed { title(R.string.found_pro) content(R.string.found_pro_desc) |