1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-10 13:02:35 +01:00
* Allow file access

* Log all to phone

* Rework billing logic

* Simplify travis process

* More logging

* Fix purchasing
This commit is contained in:
Allan Wang 2017-07-03 22:33:19 -04:00 committed by GitHub
parent bde1c74e57
commit 8a9ecfcbf4
4 changed files with 18 additions and 7 deletions

View File

@ -4,6 +4,7 @@ plugins {
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'com.github.triplet.play'

View File

@ -42,6 +42,7 @@ class AboutActivity : AboutActivityBase(R.string::class.java, configBuilder = {
"glide",
"jsoup"
)
/*
* These are great libraries, but either aren't used directly or are too common to be listed
* Give more emphasis on the unique libs!

View File

@ -40,14 +40,16 @@ object IAB {
}
try {
helper = IabHelper(applicationContext, PUBLIC_BILLING_KEY)
helper!!.enableDebugLogging(BuildConfig.DEBUG, "Frost:")
helper!!.enableDebugLogging(BuildConfig.DEBUG || Prefs.verboseLogging, "Frost:")
helper!!.startSetup {
result ->
L.d("IAB setup finished; ${result.isSuccess}")
if (result.isSuccess) {
L.d("IAB setup success")
if (onStart(helper!!))
helper!!.disposeWhenFinished()
} else {
L.d("IAB setup fail")
if (mustHavePlayStore)
activity.playStoreGenericError("Setup error: ${result.response} ${result.message}")
onFailed()
@ -103,8 +105,8 @@ fun SettingsActivity.restorePurchases() {
}
getInventory(false, true, reset) {
inv, _ ->
val proSku = inv.getSkuDetails(FROST_PRO)
Prefs.pro = proSku != null
val proSku = inv.hasPurchase(FROST_PRO)
Prefs.pro = proSku
L.d("Restore found: ${Prefs.pro}")
finishRestore(restore, Prefs.pro)
}
@ -128,9 +130,9 @@ fun Activity.validatePro() {
L.d("Validate pro")
getInventory(Prefs.pro, true, { if (Prefs.pro) playStoreNoLongerPro() }) {
inv, _ ->
val proSku = inv.getSkuDetails(FROST_PRO)
if (proSku == null && Prefs.pro) playStoreNoLongerPro()
else if (proSku != null && !Prefs.pro) playStoreFoundPro()
val proSku = inv.hasPurchase(FROST_PRO)
if (!proSku && Prefs.pro) playStoreNoLongerPro()
else if (proSku && !Prefs.pro) playStoreFoundPro()
}
}
@ -163,7 +165,11 @@ fun Activity.openPlayPurchase(key: String, code: Int, onSuccess: (key: String) -
L.d("Open play purchase $key $code")
getInventory(true, false, { playStoreGenericError("Query res error") }) {
inv, helper ->
if (inv.getSkuDetails(key) != null) return@getInventory playStoreAlreadyPurchased(key)
if (inv.hasPurchase(key)) {
playStoreAlreadyPurchased(key)
onSuccess(key)
return@getInventory
}
L.d("IAB: inventory ${inv.allOwnedSkus}")
helper.launchPurchaseFlow(this@openPlayPurchase, key, code) {
result, _ ->

View File

@ -87,6 +87,7 @@ fun Activity.playStoreGenericError(text: String? = "Store generic error") {
}
fun Activity.playStoreAlreadyPurchased(key: String) {
L.d("Play store already purchased $key")
materialDialogThemed {
title(R.string.play_already_purchased)
content(String.format(string(R.string.play_already_purchased_content), key))
@ -98,6 +99,7 @@ fun Activity.playStoreAlreadyPurchased(key: String) {
}
fun Activity.playStorePurchasedSuccessfully(key: String) {
L.d("Play store purchased $key successfully")
materialDialogThemed {
title(R.string.play_thank_you)
content(R.string.play_purchased_pro)
@ -106,6 +108,7 @@ fun Activity.playStorePurchasedSuccessfully(key: String) {
}
fun SettingsActivity.purchaseRestored() {
L.d("Purchase restored")
materialDialogThemed {
title(R.string.play_thank_you)
content(R.string.play_purchased_pro)