1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 12:02:33 +01:00

Test tags

This commit is contained in:
Allan Wang 2017-07-02 10:36:38 -07:00
parent 0018677886
commit b148feff51
6 changed files with 54 additions and 27 deletions

View File

@ -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'
}

View File

@ -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 = {

View File

@ -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)

View File

@ -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)

View File

@ -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>

View File

@ -17,7 +17,6 @@ MIN_SDK=21
TARGET_SDK=26
BUILD_TOOLS=26.0.0
VERSION_CODE=11
VERSION_NAME=1.1
KAU=e1e3b37000
KOTLIN=1.1.3