From 01250f93826b24bd53b46426999e9cdea17fecd8 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 3 Jul 2017 16:57:00 -0400 Subject: [PATCH] Fix purchase recognition (#12) * Update travis * Update bad billing booleans * Remove empty cancel fun --- .idea/misc.xml | 2 +- .travis.yml | 4 ++-- app/build.gradle | 2 +- .../com/pitchedapps/frost/utils/iab/IAB.kt | 24 ++++++++----------- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 7319f0219..085136f8d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -53,7 +53,7 @@ - + diff --git a/.travis.yml b/.travis.yml index 6f2f6392f..cda20a808 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,8 @@ before_install: - chmod +x gradlew after_success: - chmod +x ./generate-apk-release.sh -- "./generate-apk-release.sh" -- if [[ "$TRAVIS_BRANCH" == "master" ]]; then ./gradlew app:publishApkRelease; fi +# Do one or the other +- if [[ "$TRAVIS_BRANCH" == "master" ]]; then ./gradlew app:publishApkRelease; else ./generate-apk-release.sh; fi script: - cd $TRAVIS_BUILD_DIR/ - "./gradlew assembleReleaseTest" diff --git a/app/build.gradle b/app/build.gradle index 3de0e84eb..13060352f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,7 +25,7 @@ android { baseCode offset codeFormat = 'MMNNPPXX' //since we use travis, all builds will be dirty - format = '%tag%%.count%%%' + format = '%tag%%.count%%-commit%' prefix 'v' } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt index b4f8af647..ec9d8af15 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt @@ -66,10 +66,6 @@ object IAB { fun handleActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean = helper?.handleActivityResult(requestCode, resultCode, data) ?: false - fun cancel() { - - } - /** * Call this after any execution to dispose the helper * Ensure that async calls have already finished beforehand @@ -93,30 +89,30 @@ private val Context.isFrostPlay: Boolean fun SettingsActivity.restorePurchases() { //like validate, but with a snackbar and without other prompts - var restore: Snackbar? = null - restore = container.snackbar(R.string.restoring_purchases, Snackbar.LENGTH_INDEFINITE) { - setAction(R.string.kau_close) { restore?.dismiss() } - } + val restore = container.snackbar(R.string.restoring_purchases, Snackbar.LENGTH_INDEFINITE) + restore.setAction(R.string.kau_close) { restore.dismiss() } //called if inventory is not properly retrieved val reset = { + L.d("Restore reset") if (Prefs.pro) { Prefs.pro = false Prefs.theme = Theme.DEFAULT.ordinal } - finishRestore(restore) + finishRestore(restore, false) } getInventory(false, true, reset) { val proSku = it.getSkuDetails(FROST_PRO) Prefs.pro = proSku != null - finishRestore(restore) + L.d("Restore found: ${Prefs.pro}") + finishRestore(restore, Prefs.pro) } } -private fun SettingsActivity.finishRestore(snackbar: Snackbar?) { - snackbar?.dismiss() +private fun SettingsActivity.finishRestore(snackbar: Snackbar, hasPro: Boolean) { + snackbar.dismiss() materialDialogThemed { title(R.string.purchases_restored) - content(if (Prefs.pro) R.string.purchases_restored_with_pro else R.string.purchases_restored_without_pro) + content(if (hasPro) R.string.purchases_restored_with_pro else R.string.purchases_restored_without_pro) positiveText(R.string.reload) dismissListener { adapter.notifyAdapterDataSetChanged() } } @@ -150,7 +146,7 @@ fun Activity.getInventory( } fun Activity.openPlayProPurchase(code: Int) { - if (!IS_FROST_PRO) + if (!isFrostPlay) playStoreProNotAvailable() else openPlayPurchase(FROST_PRO, code) { Prefs.pro = true