aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-02 10:36:38 -0700
committerAllan Wang <me@allanwang.ca>2017-07-02 10:36:38 -0700
commitb148feff51d7f2805b1af378ad07740bfbeb53a8 (patch)
tree044106601debe01402b3572807ecc1d3f08cf0ba /app
parent0018677886197db4f72d2b49e3d0266526b95435 (diff)
downloadfrost-b148feff51d7f2805b1af378ad07740bfbeb53a8.tar.gz
frost-b148feff51d7f2805b1af378ad07740bfbeb53a8.tar.bz2
frost-b148feff51d7f2805b1af378ad07740bfbeb53a8.zip
Test tagsv1.0.2
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle12
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt14
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt36
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt15
-rw-r--r--app/src/main/res/values/strings_preferences3
5 files changed, 54 insertions, 26 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 9b8446ff..c8f40eb8 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,3 +1,7 @@
+plugins {
+ id 'com.gladed.androidgitversion' version '0.3.4'
+}
+
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
@@ -11,8 +15,8 @@ android {
applicationId "${project.APP_GROUP}." + project.APP_ID.toLowerCase()
minSdkVersion Integer.parseInt(project.MIN_SDK)
targetSdkVersion Integer.parseInt(project.TARGET_SDK)
- versionCode Integer.parseInt(project.VERSION_CODE)
- versionName project.VERSION_NAME
+ versionCode androidGitVersion.code()
+ versionName androidGitVersion.name()
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
@@ -125,3 +129,7 @@ dependencies {
transitive = true;
}
}
+
+androidGitVersion {
+ prefix 'v'
+}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
index a38e124d..0d084b51 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
@@ -15,10 +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
+import com.pitchedapps.frost.utils.iab.*
/**
@@ -28,7 +25,8 @@ class SettingsActivity : KPrefActivity(), IabBroadcastReceiver.IabBroadcastListe
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (!(IAB.helper?.handleActivityResult(requestCode, resultCode, data) ?: false))
- super.onActivityReenter(resultCode, data)
+ super.onActivityResult(requestCode, resultCode, data)
+ adapter.notifyDataSetChanged()
}
@@ -67,6 +65,12 @@ class SettingsActivity : KPrefActivity(), IabBroadcastReceiver.IabBroadcastListe
iicon = CommunityMaterial.Icon.cmd_flask_outline
}
+ plainText(R.string.restore_purchases) {
+ descRes = R.string.restore_purchases
+ iicon = GoogleMaterial.Icon.gmd_refresh
+ onClick = { this@SettingsActivity.restorePurchases(); true }
+ }
+
plainText(R.string.about_frost) {
iicon = GoogleMaterial.Icon.gmd_info
onClick = {
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 ec63cce3..e047e2ff 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
@@ -3,11 +3,13 @@ package com.pitchedapps.frost.utils.iab
import android.app.Activity
import android.content.Context
import ca.allanwang.kau.utils.isFromGooglePlay
-import ca.allanwang.kau.utils.startPlayStoreLink
import com.crashlytics.android.answers.PurchaseEvent
import com.pitchedapps.frost.BuildConfig
-import com.pitchedapps.frost.R
-import com.pitchedapps.frost.utils.*
+import com.pitchedapps.frost.SettingsActivity
+import com.pitchedapps.frost.utils.L
+import com.pitchedapps.frost.utils.Prefs
+import com.pitchedapps.frost.utils.frostAnswers
+import com.pitchedapps.frost.utils.frostAnswersCustom
/**
* Created by Allan Wang on 2017-06-23.
@@ -48,23 +50,20 @@ private const val FROST_PRO = "frost_pro"
val IS_FROST_PRO: Boolean
get() = (BuildConfig.DEBUG && Prefs.debugPro) || Prefs.previouslyPro
-private fun Context.checkFromPlay(): Boolean {
- val isPlay = isFromGooglePlay || BuildConfig.DEBUG
- if (!isPlay) materialDialogThemed {
- title(R.string.uh_oh)
- content(R.string.play_store_not_found)
- positiveText(R.string.kau_ok)
- neutralText(R.string.kau_play_store)
- onNeutral { _, _ -> startPlayStoreLink(R.string.play_store_package_id) }
- }
- return isPlay
+private val Context.isFrostPlay: Boolean
+ get() = isFromGooglePlay || BuildConfig.DEBUG
+
+fun SettingsActivity.restorePurchases() {
+
}
-fun Activity.openPlayProPurchase(code: Int) = openPlayPurchase(FROST_PRO, code)
+fun Activity.openPlayProPurchase(code: Int) = openPlayPurchase(FROST_PRO, code) {
+ Prefs.previouslyPro = true
+}
-fun Activity.openPlayPurchase(key: String, code: Int) {
+fun Activity.openPlayPurchase(key: String, code: Int, onSuccess: (key: String) -> Unit) {
L.d("Open play purchase $key $code")
- if (!checkFromPlay()) return
+ if (!isFrostPlay) return playStoreNotFound()
frostAnswersCustom("PLAY_PURCHASE") {
putCustomAttribute("Key", key)
}
@@ -79,7 +78,10 @@ fun Activity.openPlayPurchase(key: String, code: Int) {
L.d("IAB: inventory ${inv.allOwnedSkus}")
IAB.helper!!.launchPurchaseFlow(this@openPlayPurchase, key, code) {
result, _ ->
- if (result.isSuccess) playStorePurchasedSuccessfully(key)
+ if (result.isSuccess) {
+ onSuccess(key)
+ playStorePurchasedSuccessfully(key)
+ }
frostAnswers {
logPurchase(PurchaseEvent()
.putItemId(key)
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 f0a544f7..08958480 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
@@ -40,8 +40,19 @@ fun Activity.playStoreNoLongerPro() {
}
}
-fun Activity.playStoreNotAvailable() {
- playStoreLog("Store not available")
+fun Activity.playStoreNotFound() {
+ L.d("Play store not found")
+ materialDialogThemed {
+ title(R.string.uh_oh)
+ content(R.string.play_store_not_found)
+ positiveText(R.string.kau_ok)
+ neutralText(R.string.kau_play_store)
+ onNeutral { _, _ -> startPlayStoreLink(R.string.play_store_package_id) }
+ }
+}
+
+fun Activity.playStoreProNotAvailable() {
+ playStoreLog("Pro found; store not available")
materialDialogThemed {
title(R.string.uh_oh)
content(R.string.play_store_not_found)
diff --git a/app/src/main/res/values/strings_preferences b/app/src/main/res/values/strings_preferences
index 36bba6ad..faaaf96c 100644
--- a/app/src/main/res/values/strings_preferences
+++ b/app/src/main/res/values/strings_preferences
@@ -57,4 +57,7 @@
<string name="restart_frost">Restart Frost</string>
<string name="restart_frost_desc">Crashlytics will only submit logs when a crash occurs or if errors are found and the app is restarted. Clicking here will restart the app and flush whatever issues are currently found.</string>
+ <string name="restore_purchases">Restore Purchases</string>
+ <string name="restore_purchases_desc">Restore any previous purchases from the Play Store</string>
+
</resources> \ No newline at end of file