diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
4 files changed, 15 insertions, 13 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt index f8060d9d..5f0bdc41 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -89,8 +89,10 @@ object Prefs : KPref() { /** * Cache like value to determine if user has or had pro * In most cases, [com.pitchedapps.frost.utils.iab.IS_FROST_PRO] should be looked at instead + * This has been renamed to pro for short, but keep in mind that it only reflects the value + * of when it was previously verified */ - var previouslyPro: Boolean by kpref("previously_pro", false) + var pro: Boolean by kpref("previously_pro", false) var debugPro: Boolean by kpref("debug_pro", false) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 6a99021d..b255c59c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -106,7 +106,7 @@ fun Activity.setFrostTheme(forceTransparent: Boolean = false) { fun Activity.setFrostColors(toolbar: Toolbar? = null, themeWindow: Boolean = true, texts: Array<TextView> = arrayOf(), headers: Array<View> = arrayOf(), backgrounds: Array<View> = arrayOf()) { statusBarColor = Prefs.headerColor.darken(0.1f).withAlpha(255) - navigationBarColor = Prefs.headerColor + if (Prefs.tintNavBar) navigationBarColor = Prefs.headerColor if (themeWindow) window.setBackgroundDrawable(ColorDrawable(Prefs.bgColor)) toolbar?.setBackgroundColor(Prefs.headerColor) toolbar?.setTitleTextColor(Prefs.iconColor) 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 d511f773..b4f8af64 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 @@ -86,7 +86,7 @@ object IAB { private const val FROST_PRO = "frost_pro" val IS_FROST_PRO: Boolean - get() = (BuildConfig.DEBUG && Prefs.debugPro) || Prefs.previouslyPro + get() = (BuildConfig.DEBUG && Prefs.debugPro) || Prefs.pro private val Context.isFrostPlay: Boolean get() = isFromGooglePlay || BuildConfig.DEBUG @@ -99,15 +99,15 @@ fun SettingsActivity.restorePurchases() { } //called if inventory is not properly retrieved val reset = { - if (Prefs.previouslyPro) { - Prefs.previouslyPro = false + if (Prefs.pro) { + Prefs.pro = false Prefs.theme = Theme.DEFAULT.ordinal } finishRestore(restore) } getInventory(false, true, reset) { val proSku = it.getSkuDetails(FROST_PRO) - Prefs.previouslyPro = proSku != null + Prefs.pro = proSku != null finishRestore(restore) } } @@ -116,7 +116,7 @@ private fun SettingsActivity.finishRestore(snackbar: Snackbar?) { snackbar?.dismiss() materialDialogThemed { title(R.string.purchases_restored) - content(if (Prefs.previouslyPro) R.string.purchases_restored_with_pro else R.string.purchases_restored_without_pro) + content(if (Prefs.pro) R.string.purchases_restored_with_pro else R.string.purchases_restored_without_pro) positiveText(R.string.reload) dismissListener { adapter.notifyAdapterDataSetChanged() } } @@ -126,10 +126,10 @@ private fun SettingsActivity.finishRestore(snackbar: Snackbar?) { * If user has pro, check if it's valid and destroy the helper */ fun Activity.validatePro() { - getInventory(Prefs.previouslyPro, true, { if (Prefs.previouslyPro) playStoreNoLongerPro() }) { + getInventory(Prefs.pro, true, { if (Prefs.pro) playStoreNoLongerPro() }) { val proSku = it.getSkuDetails(FROST_PRO) - if (proSku == null && Prefs.previouslyPro) playStoreNoLongerPro() - else if (proSku != null && !Prefs.previouslyPro) playStoreFoundPro() + if (proSku == null && Prefs.pro) playStoreNoLongerPro() + else if (proSku != null && !Prefs.pro) playStoreFoundPro() } } @@ -153,7 +153,7 @@ fun Activity.openPlayProPurchase(code: Int) { if (!IS_FROST_PRO) playStoreProNotAvailable() else openPlayPurchase(FROST_PRO, code) { - Prefs.previouslyPro = true + Prefs.pro = true } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt index 54355d3e..58c21be4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt @@ -30,7 +30,7 @@ private fun Activity.playRestart() { fun Activity.playStoreNoLongerPro() { - Prefs.previouslyPro = false + Prefs.pro = false playStoreLog("No Longer Pro") materialDialogThemed { title(R.string.uh_oh) @@ -43,7 +43,7 @@ fun Activity.playStoreNoLongerPro() { } fun Activity.playStoreFoundPro() { - Prefs.previouslyPro = true + Prefs.pro = true L.d("Found pro") materialDialogThemed { title(R.string.found_pro) |