From fb4f71ef83d1bfbd3ae89701dc17f6ae31a35eb7 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 30 Jun 2017 22:21:42 -0700 Subject: Disable verbose logging on restart --- .../main/kotlin/com/pitchedapps/frost/FrostApp.kt | 2 +- .../com/pitchedapps/frost/SettingsActivity.kt | 6 +++- .../kotlin/com/pitchedapps/frost/utils/iab/IAB.kt | 39 ++++++++++++---------- 3 files changed, 28 insertions(+), 19 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt index 4dce7d4a..8d38f2f9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt @@ -13,7 +13,6 @@ import com.mikepenz.materialdrawer.util.DrawerImageLoader import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.utils.CrashReportingTree import com.pitchedapps.frost.utils.Prefs -import com.pitchedapps.frost.utils.iab.IAB import com.raizlabs.android.dbflow.config.FlowConfig import com.raizlabs.android.dbflow.config.FlowManager import io.fabric.sdk.android.Fabric @@ -46,6 +45,7 @@ class FrostApp : Application() { Crashlytics.setUserIdentifier(Prefs.frostId) Timber.plant(CrashReportingTree()) } + Prefs.verboseLogging = false FbCookie() if (Prefs.installDate == -1L) Prefs.installDate = System.currentTimeMillis() if (Prefs.identifier == -1) Prefs.identifier = Random().nextInt(Int.MAX_VALUE) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt index 580c7dbc..7d42accf 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt @@ -15,13 +15,17 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.settings.* import com.pitchedapps.frost.utils.* import com.pitchedapps.frost.utils.iab.IS_FROST_PRO +import com.pitchedapps.frost.utils.iab.IabBroadcastReceiver import com.pitchedapps.frost.utils.iab.openPlayProPurchase /** * Created by Allan Wang on 2017-06-06. */ -class SettingsActivity : KPrefActivity() { +class SettingsActivity : KPrefActivity(), IabBroadcastReceiver.IabBroadcastListener { + override fun receivedBroadcast() { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } override fun kPrefCoreAttributes(): CoreAttributeContract.() -> Unit = { textColor = { Prefs.textColor } 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 0fd10c5b..431ba0b6 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 @@ -22,6 +22,7 @@ object IAB { if (!activity.isFromGooglePlay && !BuildConfig.DEBUG) return L.d("IAB not from google play") try { helper = IabHelper(activity.applicationContext, PUBLIC_BILLING_KEY) + helper!!.enableDebugLogging(BuildConfig.DEBUG, "Frost:") helper!!.startSetup { result -> L.d("IAB result ${result.message}") @@ -63,24 +64,28 @@ fun Activity.openPlayPurchase(key: String, code: Int) { L.d("IAB flag end async") IAB.helper?.flagEndAsync() ?: return playStoreGenericError("Null flag end async") L.d("IAB query inv async") - IAB.helper!!.queryInventoryAsync { - res, inv -> - if (res.isFailure) return@queryInventoryAsync playStoreGenericError("Query res error") - if (inv == null) return@queryInventoryAsync playStoreGenericError("Empty inventory") - L.d("IAB: inventory ${inv.allOwnedSkus}") - val donation = inv.getSkuDetails(key) ?: return@queryInventoryAsync playStoreGenericError("Donation null") - IAB.helper!!.launchPurchaseFlow(this@openPlayPurchase, donation.sku, code) { - result, _ -> - if (result.isSuccess) materialDialogThemed { - title(R.string.play_thank_you) - content(R.string.play_purchased_pro) - positiveText(R.string.kau_ok) - } else playStoreGenericError("Result: ${result.message}") - frostAnswers { - logPurchase(PurchaseEvent() - .putItemId(key) - .putSuccess(result.isSuccess)) + try { + IAB.helper!!.queryInventoryAsync { + res, inv -> + if (res.isFailure) return@queryInventoryAsync playStoreGenericError("Query res error") + if (inv == null) return@queryInventoryAsync playStoreGenericError("Empty inventory") + L.d("IAB: inventory ${inv.allOwnedSkus}") + val donation = inv.getSkuDetails(key) ?: return@queryInventoryAsync playStoreGenericError("Donation null") + IAB.helper!!.launchPurchaseFlow(this@openPlayPurchase, donation.sku, code) { + result, _ -> + if (result.isSuccess) materialDialogThemed { + title(R.string.play_thank_you) + content(R.string.play_purchased_pro) + positiveText(R.string.kau_ok) + } else playStoreGenericError("Result: ${result.message}") + frostAnswers { + logPurchase(PurchaseEvent() + .putItemId(key) + .putSuccess(result.isSuccess)) + } } } + } catch(e: IabHelper.IabAsyncInProgressException) { + L.e(e, "IAB query dup") } } \ No newline at end of file -- cgit v1.2.3