mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-10 04:52:38 +01:00
Dev (#13)
* Allow file access * Log all to phone * Rework billing logic
This commit is contained in:
parent
01250f9382
commit
8edd98fcee
@ -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)
|
||||
}
|
||||
}
|
@ -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,12 +159,9 @@ 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)
|
||||
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, _ ->
|
||||
@ -176,6 +177,4 @@ fun Activity.openPlayPurchase(key: String, code: Int, onSuccess: (key: String) -
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
@ -45,4 +45,5 @@ class FrostChromeClient(webCore: FrostWebViewCore) : WebChromeClient() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user