diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/build.gradle | 4 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt | 2 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt | 11 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt | 4 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt | 19 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt | 32 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 2 | ||||
-rw-r--r-- | app/src/main/res/values/strings_preferences | 4 | ||||
-rw-r--r-- | app/src/main/res/xml/changelog.xml | 4 |
9 files changed, 62 insertions, 20 deletions
diff --git a/app/build.gradle b/app/build.gradle index 89e3abaa..9b8446ff 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -53,8 +53,8 @@ android { resValue "string", "frost_web", "Frost Web Test" } release { - minifyEnabled false - shrinkResources false + minifyEnabled true + shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' resValue "string", "app_name", "Frost" resValue "string", "frost_web", "Frost Web" diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt index 85b70a60..b4d7973e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt @@ -339,7 +339,7 @@ class MainActivity : BaseActivity(), FrostWebViewSearch.SearchContract { observable.observeOn(AndroidSchedulers.mainThread()).subscribe { hiddenSearchView?.query(it) } } foregroundColor = Prefs.textColor - backgroundColor = Prefs.bgColor + backgroundColor = Prefs.bgColor.withMinAlpha(200) openListener = { hiddenSearchView?.pauseLoad = false } closeListener = { hiddenSearchView?.pauseLoad = true } onItemClick = { _, key, _, _ -> launchWebOverlay(key) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt index 7d42accf..a38e124d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt @@ -1,5 +1,6 @@ package com.pitchedapps.frost +import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem @@ -14,6 +15,7 @@ import com.mikepenz.community_material_typeface_library.CommunityMaterial import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.settings.* import com.pitchedapps.frost.utils.* +import com.pitchedapps.frost.utils.iab.IAB import com.pitchedapps.frost.utils.iab.IS_FROST_PRO import com.pitchedapps.frost.utils.iab.IabBroadcastReceiver import com.pitchedapps.frost.utils.iab.openPlayProPurchase @@ -23,8 +25,15 @@ import com.pitchedapps.frost.utils.iab.openPlayProPurchase * Created by Allan Wang on 2017-06-06. */ class SettingsActivity : KPrefActivity(), IabBroadcastReceiver.IabBroadcastListener { + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + if (!(IAB.helper?.handleActivityResult(requestCode, resultCode, data) ?: false)) + super.onActivityReenter(resultCode, data) + } + + override fun receivedBroadcast() { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + L.d("IAB broadcast") } override fun kPrefCoreAttributes(): CoreAttributeContract.() -> Unit = { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt index fcb22320..e0e18622 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt @@ -15,8 +15,8 @@ fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = { descRes = R.string.experimental_disclaimer_info } - checkbox(R.string.search, { Prefs.searchBar }, { Prefs.searchBar = it; setResult(MainActivity.REQUEST_SEARCH) }) { - descRes = R.string.search_desc + checkbox(R.string.search_bar, { Prefs.searchBar }, { Prefs.searchBar = it; setResult(MainActivity.REQUEST_SEARCH) }) { + descRes = R.string.search_bar_desc } checkbox(R.string.verbose_logging, { Prefs.verboseLogging }, { Prefs.verboseLogging = it }) { 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 431ba0b6..ec63cce3 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 @@ -34,6 +34,13 @@ object IAB { } } } + + /** + * If user has pro, check if it's valid and destroy the helper + */ + fun validatePro(activity: Activity) { + + } } private const val FROST_PRO = "frost_pro" @@ -68,19 +75,15 @@ fun Activity.openPlayPurchase(key: String, code: Int) { IAB.helper!!.queryInventoryAsync { res, inv -> if (res.isFailure) return@queryInventoryAsync playStoreGenericError("Query res error") - if (inv == null) return@queryInventoryAsync playStoreGenericError("Empty inventory") + if (inv?.getSkuDetails(key) != null) return@queryInventoryAsync playStoreAlreadyPurchased(key) L.d("IAB: inventory ${inv.allOwnedSkus}") - val donation = inv.getSkuDetails(key) ?: return@queryInventoryAsync playStoreGenericError("Donation null") - IAB.helper!!.launchPurchaseFlow(this@openPlayPurchase, donation.sku, code) { + IAB.helper!!.launchPurchaseFlow(this@openPlayPurchase, key, 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}") + if (result.isSuccess) playStorePurchasedSuccessfully(key) frostAnswers { logPurchase(PurchaseEvent() .putItemId(key) + .putCustomAttribute("result", result.message) .putSuccess(result.isSuccess)) } } 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 e855138f..f0a544f7 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 @@ -3,7 +3,10 @@ package com.pitchedapps.frost.utils.iab import android.app.Activity import ca.allanwang.kau.utils.restart import ca.allanwang.kau.utils.startPlayStoreLink +import ca.allanwang.kau.utils.string +import com.pitchedapps.frost.MainActivity import com.pitchedapps.frost.R +import com.pitchedapps.frost.SettingsActivity import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.materialDialogThemed @@ -15,6 +18,14 @@ private fun playStoreLog(text: String) { L.e(Throwable(text), "Play Store Exception") } +private fun Activity.playRestart() { + if (this is MainActivity) restart() + else if (this is SettingsActivity) { + setResult(MainActivity.REQUEST_RESTART) + finish() + } +} + fun Activity.playStoreNoLongerPro() { if (!Prefs.previouslyPro) return //never pro to begin with Prefs.previouslyPro = false @@ -24,7 +35,7 @@ fun Activity.playStoreNoLongerPro() { content(R.string.play_store_not_pro) positiveText(R.string.reload) dismissListener { - this@playStoreNoLongerPro.restart() + this@playStoreNoLongerPro.playRestart() } } } @@ -47,4 +58,23 @@ fun Activity.playStoreGenericError(text: String = "Store generic error") { content(R.string.play_store_billing_error) positiveText(R.string.kau_ok) } +} + +fun Activity.playStoreAlreadyPurchased(key: String) { + materialDialogThemed { + title(R.string.play_already_purchased) + content(String.format(string(R.string.play_already_purchased_content), key)) + positiveText(R.string.reload) + dismissListener { + this@playStoreAlreadyPurchased.playRestart() + } + } +} + +fun Activity.playStorePurchasedSuccessfully(key: String) { + materialDialogThemed { + title(R.string.play_thank_you) + content(R.string.play_purchased_pro) + positiveText(R.string.kau_ok) + } }
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ec7a6cf6..d6c8afd7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -55,6 +55,8 @@ <string name="play_store_billing_error">Something went wrong. Please try again later.</string> <string name="play_thank_you">Thank you!</string> <string name="play_purchased_pro">Thank you for your support! Enjoy the pro version.</string> + <string name="play_already_purchased">Already Purchased</string> + <string name="play_already_purchased_content">Looks like you\'ve already purchased %s. Enjoy!</string> <string name="define_dbflow"></string> <!-- Author section --> diff --git a/app/src/main/res/values/strings_preferences b/app/src/main/res/values/strings_preferences index 347e8c5b..36bba6ad 100644 --- a/app/src/main/res/values/strings_preferences +++ b/app/src/main/res/values/strings_preferences @@ -50,8 +50,8 @@ <string name="experimental_desc">Enable early access to potentially unstable features</string> <string name="experimental_disclaimer">Disclaimer</string> <string name="experimental_disclaimer_info">Experimental features may be unstable and may never make it to production. Use at your own risk, send feedback, and feel free to disable them if they don\'t work well.</string> - <string name="search">Search Type</string> - <string name="search_desc">Enable the search bar instead of a search overlay</string> + <string name="search_bar">Search Bar</string> + <string name="search_bar_desc">Enable the search bar instead of a search overlay</string> <string name="verbose_logging">Verbose Logging</string> <string name="verbose_logging_desc">Enable verbose logging to help with crash reports. Logging will only be sent once an error is encountered, so repeat the issue to notify the dev. This will automatically be disabled if the app restarts.</string> <string name="restart_frost">Restart Frost</string> diff --git a/app/src/main/res/xml/changelog.xml b/app/src/main/res/xml/changelog.xml index ed64c75e..e189577e 100644 --- a/app/src/main/res/xml/changelog.xml +++ b/app/src/main/res/xml/changelog.xml @@ -18,9 +18,7 @@ <item text="Fixed up main layout" /> <item text="Fix some theme components" /> <item text="Added behaviour settings" /> - <item text="" /> - <item text="" /> - <item text="" /> + <item text="Added about section with links" /> <version title="v0.3" /> <item text="Added rounded icons option" /> |