diff options
Diffstat (limited to 'app/src/main/kotlin/com')
4 files changed, 30 insertions, 31 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt index 86731357..16a3d2ae 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt @@ -34,10 +34,7 @@ internal class CrashReportingTree : Timber.Tree() { Log.DEBUG -> if (!Prefs.verboseLogging) return } if (message != null) - if (priority == Log.ERROR) - Crashlytics.log(Log.ERROR, "Frost", message) - else - Crashlytics.log(message) + Crashlytics.log(priority, "Frost", message) if (t != null) Crashlytics.logException(t) } }
\ No newline at end of file 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 ec9d8af1..a96af378 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 @@ -101,7 +101,8 @@ fun SettingsActivity.restorePurchases() { finishRestore(restore, false) } getInventory(false, true, reset) { - val proSku = it.getSkuDetails(FROST_PRO) + inv, _ -> + val proSku = inv.getSkuDetails(FROST_PRO) Prefs.pro = proSku != null L.d("Restore found: ${Prefs.pro}") finishRestore(restore, Prefs.pro) @@ -120,10 +121,13 @@ private fun SettingsActivity.finishRestore(snackbar: Snackbar, hasPro: Boolean) /** * If user has pro, check if it's valid and destroy the helper + * If cache matches result, it finishes silently */ fun Activity.validatePro() { + L.d("Validate pro") getInventory(Prefs.pro, true, { if (Prefs.pro) playStoreNoLongerPro() }) { - val proSku = it.getSkuDetails(FROST_PRO) + inv, _ -> + val proSku = inv.getSkuDetails(FROST_PRO) if (proSku == null && Prefs.pro) playStoreNoLongerPro() else if (proSku != null && !Prefs.pro) playStoreFoundPro() } @@ -133,13 +137,13 @@ fun Activity.getInventory( mustHavePlayStore: Boolean = true, disposeOnFinish: Boolean = true, onFailed: () -> Unit = {}, - onSuccess: (inv: Inventory) -> Unit) { + onSuccess: (inv: Inventory, helper: IabHelper) -> Unit) { IAB(this, mustHavePlayStore, onFailed) { helper -> helper.queryInventoryAsync { res, inv -> if (res.isFailure || inv == null) onFailed() - else onSuccess(inv) + else onSuccess(inv, helper) } disposeOnFinish } @@ -155,27 +159,22 @@ fun Activity.openPlayProPurchase(code: Int) { fun Activity.openPlayPurchase(key: String, code: Int, onSuccess: (key: String) -> Unit) { L.d("Open play purchase $key $code") - IAB(this, true) { - helper -> - helper.queryInventoryAsync { - res, inv -> - if (res.isFailure) return@queryInventoryAsync playStoreGenericError("Query res error") - if (inv?.getSkuDetails(key) != null) return@queryInventoryAsync playStoreAlreadyPurchased(key) - L.d("IAB: inventory ${inv.allOwnedSkus}") - helper.launchPurchaseFlow(this@openPlayPurchase, key, code) { - result, _ -> - if (result.isSuccess) { - onSuccess(key) - playStorePurchasedSuccessfully(key) - } - frostAnswers { - logPurchase(PurchaseEvent() - .putItemId(key) - .putCustomAttribute("result", result.message) - .putSuccess(result.isSuccess)) - } + getInventory(true, false, { playStoreGenericError("Query res error") }) { + inv, helper -> + if (inv.getSkuDetails(key) != null) return@getInventory playStoreAlreadyPurchased(key) + L.d("IAB: inventory ${inv.allOwnedSkus}") + helper.launchPurchaseFlow(this@openPlayPurchase, key, code) { + result, _ -> + if (result.isSuccess) { + onSuccess(key) + playStorePurchasedSuccessfully(key) + } + frostAnswers { + logPurchase(PurchaseEvent() + .putItemId(key) + .putCustomAttribute("result", result.message) + .putSuccess(result.isSuccess)) } } - false } }
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt index 4d03afe4..10499bfa 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt @@ -45,4 +45,5 @@ class FrostChromeClient(webCore: FrostWebViewCore) : WebChromeClient() { } + }
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt index c2a53837..a0ffa3b5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt @@ -58,9 +58,11 @@ class FrostWebViewCore @JvmOverloads constructor( fun setupWebview(url: String, enum: FbTab? = null) { baseUrl = url baseEnum = enum - settings.javaScriptEnabled = true - settings.userAgentString = USER_AGENT_BASIC -// settings.domStorageEnabled = true + with (settings) { + javaScriptEnabled = true + userAgentString = USER_AGENT_BASIC + allowFileAccess = true + } setLayerType(View.LAYER_TYPE_HARDWARE, null) frostWebClient = baseEnum?.webClient?.invoke(this) ?: FrostWebViewClient(this) webViewClient = frostWebClient |