Adds build flavor with endofuse parameter to ease the creation of limited use versions

od
Laurent 6 years ago
parent 561bfd8b1c
commit 9f4617e1d1
  1. 13
      app/build.gradle
  2. 2
      app/src/main/java/net/pokeranalytics/android/PokerAnalyticsApplication.kt
  3. 27
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FeedFragment.kt
  4. 58
      app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt
  5. 19
      app/src/main/java/net/pokeranalytics/android/util/billing/AppGuard.kt

@ -29,7 +29,7 @@ android {
applicationId "net.pokeranalytics.android" applicationId "net.pokeranalytics.android"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 28 targetSdkVersion 28
versionCode 53 versionCode 55
versionName "2.1.5" versionName "2.1.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
@ -59,6 +59,17 @@ android {
} }
} }
} }
flavorDimensions 'endOfUse'
productFlavors {
standard {
dimension = 'endOfUse'
}
august2020 {
dimension = 'endOfUse'
versionNameSuffix = '_august2020'
versionCode = 50000 + android.defaultConfig.versionCode
}
}
configurations { configurations {
release { release {

@ -60,7 +60,7 @@ class PokerAnalyticsApplication : Application() {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
Timber.d("UserPreferences.defaultCurrency: ${UserDefaults.currency.symbol}") Timber.d("UserPreferences.defaultCurrency: ${UserDefaults.currency.symbol}")
this.createFakeSessions() // this.createFakeSessions()
} }
Patcher.patchAll(this.applicationContext) Patcher.patchAll(this.applicationContext)

@ -301,11 +301,12 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
return return
} }
// Keep commented code for special versions AppGuard.endOfUse?.let { endDate ->
// if (Date().after(betaLimitDate)) { if (Date().after(endDate)) {
// this.showEndOfBetaMessage() this.showEndOfUseMessage()
// return return
// } }
}
SessionActivity.newInstanceforResult( SessionActivity.newInstanceforResult(
this, this,
@ -322,12 +323,14 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
*/ */
private fun createNewTransaction() { private fun createNewTransaction() {
// if (Date().after(betaLimitDate)) { AppGuard.endOfUse?.let { endDate ->
// this.showEndOfBetaMessage() if (Date().after(endDate)) {
// return this.showEndOfUseMessage()
// } return
EditableDataActivity.newInstanceForResult(this, LiveData.TRANSACTION, null, RequestCode.NEW_TRANSACTION.value) }
}
EditableDataActivity.newInstanceForResult(this, LiveData.TRANSACTION, null, RequestCode.NEW_TRANSACTION.value)
} }
/** /**
@ -344,10 +347,10 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
* Show end of beta message * Show end of beta message
* Keep for possible future uses * Keep for possible future uses
*/ */
private fun showEndOfBetaMessage() { private fun showEndOfUseMessage() {
Toast.makeText( Toast.makeText(
context, context,
"App version has ended. Thanks a lot for using it! Please update with the Google Play version to continue using the app.", "This version full use has ended. Thanks a lot for using it! Please update with the Google Play version to continue using the app.",
Toast.LENGTH_LONG Toast.LENGTH_LONG
).show() ).show()
} }

@ -88,31 +88,39 @@ class SessionRowView : FrameLayout {
rowSession.sessionInfoDurationValue.isVisible = state.hasStarted rowSession.sessionInfoDurationValue.isVisible = state.hasStarted
// State // State
if (state == SessionState.STARTED) { when (state) {
rowSession.gameResult.isVisible = false SessionState.STARTED -> {
rowSession.infoIcon.isVisible = true rowSession.gameResult.isVisible = false
rowSession.infoIcon.setImageResource(R.drawable.chip) rowSession.infoIcon.isVisible = true
rowSession.infoTitle.isVisible = true rowSession.infoIcon.setImageResource(R.drawable.chip)
rowSession.infoTitle.text = context.getString(R.string.running_session_state) rowSession.infoTitle.isVisible = true
} else if (state == SessionState.PLANNED) { rowSession.infoTitle.text = context.getString(R.string.running_session_state)
rowSession.gameResult.isVisible = false }
rowSession.infoIcon.isVisible = true SessionState.PLANNED -> {
rowSession.infoIcon.setImageResource(R.drawable.ic_planned) rowSession.gameResult.isVisible = false
rowSession.infoTitle.isVisible = true rowSession.infoIcon.isVisible = true
rowSession.infoTitle.text = session.startDate!!.shortTime() rowSession.infoIcon.setImageResource(R.drawable.ic_planned)
} else if (state == SessionState.PENDING) { rowSession.infoTitle.isVisible = true
rowSession.gameResult.isVisible = false rowSession.infoTitle.text = session.startDate!!.shortTime()
rowSession.infoIcon.isVisible = false }
rowSession.infoTitle.isVisible = false SessionState.PENDING -> {
rowSession.gameResult.isVisible = false
} else { rowSession.infoIcon.isVisible = false
rowSession.gameResult.isVisible = true rowSession.infoTitle.isVisible = false
rowSession.infoIcon.isVisible = false
rowSession.infoTitle.isVisible = false }
else -> {
val result = session.result?.net ?: 0.0 rowSession.gameResult.isVisible = true
val formattedStat = ComputedStat(Stat.NET_RESULT, result, currency = session.currency).format() rowSession.infoIcon.isVisible = false
rowSession.gameResult.setTextFormat(formattedStat, context) rowSession.infoTitle.isVisible = false
session.result?.net?.let { netResult ->
val stat = ComputedStat(Stat.NET_RESULT, netResult, currency = session.currency)
rowSession.gameResult.setTextFormat(stat.format(), context)
}
// val formattedStat = ComputedStat(Stat.NET_RESULT, result, currency = session.currency).format()
}
} }
} }

@ -9,6 +9,7 @@ import net.pokeranalytics.android.BuildConfig
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
import timber.log.Timber import timber.log.Timber
import java.io.IOException import java.io.IOException
import java.text.SimpleDateFormat
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
@ -54,6 +55,9 @@ object AppGuard : PurchasesUpdatedListener {
*/ */
val isProUser: Boolean val isProUser: Boolean
get() { get() {
if (this.endOfUse != null) return true
return if (BuildConfig.DEBUG) { return if (BuildConfig.DEBUG) {
true true
} else { } else {
@ -61,6 +65,21 @@ object AppGuard : PurchasesUpdatedListener {
} }
} }
val endOfUse: Date?
get() {
val stringFormat = when (BuildConfig.FLAVOR) {
"august2020" -> "01/8/2020"
else -> null
}
return if (stringFormat != null) {
val sdf = SimpleDateFormat("dd/M/yyyy", Locale.getDefault())
sdf.parse(stringFormat)
} else {
null
}
}
/** /**
* A delegate to notify when the purchase has succeeded * A delegate to notify when the purchase has succeeded
*/ */

Loading…
Cancel
Save