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. 22
      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"
minSdkVersion 23
targetSdkVersion 28
versionCode 53
versionCode 55
versionName "2.1.5"
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 {
release {

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

@ -301,11 +301,12 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
return
}
// Keep commented code for special versions
// if (Date().after(betaLimitDate)) {
// this.showEndOfBetaMessage()
// return
// }
AppGuard.endOfUse?.let { endDate ->
if (Date().after(endDate)) {
this.showEndOfUseMessage()
return
}
}
SessionActivity.newInstanceforResult(
this,
@ -322,12 +323,14 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
*/
private fun createNewTransaction() {
// if (Date().after(betaLimitDate)) {
// this.showEndOfBetaMessage()
// return
// }
EditableDataActivity.newInstanceForResult(this, LiveData.TRANSACTION, null, RequestCode.NEW_TRANSACTION.value)
AppGuard.endOfUse?.let { endDate ->
if (Date().after(endDate)) {
this.showEndOfUseMessage()
return
}
}
EditableDataActivity.newInstanceForResult(this, LiveData.TRANSACTION, null, RequestCode.NEW_TRANSACTION.value)
}
/**
@ -344,10 +347,10 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
* Show end of beta message
* Keep for possible future uses
*/
private fun showEndOfBetaMessage() {
private fun showEndOfUseMessage() {
Toast.makeText(
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
).show()
}

@ -88,31 +88,39 @@ class SessionRowView : FrameLayout {
rowSession.sessionInfoDurationValue.isVisible = state.hasStarted
// State
if (state == SessionState.STARTED) {
when (state) {
SessionState.STARTED -> {
rowSession.gameResult.isVisible = false
rowSession.infoIcon.isVisible = true
rowSession.infoIcon.setImageResource(R.drawable.chip)
rowSession.infoTitle.isVisible = true
rowSession.infoTitle.text = context.getString(R.string.running_session_state)
} else if (state == SessionState.PLANNED) {
}
SessionState.PLANNED -> {
rowSession.gameResult.isVisible = false
rowSession.infoIcon.isVisible = true
rowSession.infoIcon.setImageResource(R.drawable.ic_planned)
rowSession.infoTitle.isVisible = true
rowSession.infoTitle.text = session.startDate!!.shortTime()
} else if (state == SessionState.PENDING) {
}
SessionState.PENDING -> {
rowSession.gameResult.isVisible = false
rowSession.infoIcon.isVisible = false
rowSession.infoTitle.isVisible = false
} else {
}
else -> {
rowSession.gameResult.isVisible = true
rowSession.infoIcon.isVisible = false
rowSession.infoTitle.isVisible = false
val result = session.result?.net ?: 0.0
val formattedStat = ComputedStat(Stat.NET_RESULT, result, currency = session.currency).format()
rowSession.gameResult.setTextFormat(formattedStat, context)
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 timber.log.Timber
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*
import kotlin.collections.ArrayList
@ -54,6 +55,9 @@ object AppGuard : PurchasesUpdatedListener {
*/
val isProUser: Boolean
get() {
if (this.endOfUse != null) return true
return if (BuildConfig.DEBUG) {
true
} 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
*/

Loading…
Cancel
Save