Complex blinds first commit

blinds
Laurent 3 years ago
parent d095a8c5af
commit b20bb4815d
  1. 4
      app/build.gradle
  2. 2
      app/src/main/java/net/pokeranalytics/android/PokerAnalyticsApplication.kt
  3. 5
      app/src/main/java/net/pokeranalytics/android/model/Criteria.kt
  4. 7
      app/src/main/java/net/pokeranalytics/android/model/Stakes.kt
  5. 2
      app/src/main/java/net/pokeranalytics/android/model/extensions/SessionExtensions.kt
  6. 17
      app/src/main/java/net/pokeranalytics/android/model/migrations/Patcher.kt
  7. 13
      app/src/main/java/net/pokeranalytics/android/model/migrations/PokerAnalyticsMigration.kt
  8. 191
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  9. 2
      app/src/main/java/net/pokeranalytics/android/model/utils/FavoriteSessionFinder.kt
  10. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetDoubleEditTextFragment.kt
  11. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetEditTextFragment.kt
  12. 1
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetFragment.kt
  13. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetListFragment.kt
  14. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetListGameFragment.kt
  15. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetNumericTextFragment.kt
  16. 108
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetStakesFragment.kt
  17. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetStaticListFragment.kt
  18. 2
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetSumFragment.kt
  19. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetTableSizeGridFragment.kt
  20. 5
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetType.kt
  21. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/session/SessionFragment.kt
  22. 79
      app/src/main/java/net/pokeranalytics/android/ui/view/keyboard/StakesKeyboardView.kt
  23. 23
      app/src/main/java/net/pokeranalytics/android/ui/view/rows/SessionPropertiesRow.kt
  24. 2
      app/src/main/java/net/pokeranalytics/android/ui/viewmodel/BottomSheetViewModel.kt
  25. 3
      app/src/main/java/net/pokeranalytics/android/util/Global.kt
  26. 6
      app/src/main/java/net/pokeranalytics/android/util/Preferences.kt
  27. 1
      app/src/main/res/layout/activity_color_picker.xml
  28. 66
      app/src/main/res/layout/bottom_sheet_stakes.xml
  29. 116
      app/src/main/res/layout/view_keyboard_stakes.xml

@ -35,8 +35,8 @@ android {
applicationId "net.pokeranalytics.android"
minSdkVersion 23
targetSdkVersion 30
versionCode 133
versionName "5.4.9"
versionCode 134
versionName "5.4.10"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

@ -47,7 +47,7 @@ class PokerAnalyticsApplication : Application() {
Realm.init(this)
val realmConfiguration = RealmConfiguration.Builder()
.name(Realm.DEFAULT_REALM_NAME)
.schemaVersion(11)
.schemaVersion(12)
.allowWritesOnUiThread(true)
.migration(PokerAnalyticsMigration())
.initialData(Seed(this))

@ -108,7 +108,6 @@ sealed class Criteria(override var uniqueIdentifier: Int) : IntIdentifiable, Row
return objects.map { Query(it) }
}
QueryCondition.distinct<Session, T, S>()?.let {
val values = it.mapNotNull { session ->
when (this) {
@ -124,8 +123,8 @@ sealed class Criteria(override var uniqueIdentifier: Int) : IntIdentifiable, Row
is TournamentFees -> if (session.tournamentEntryFee is S) {
session.tournamentEntryFee as S
} else throw PokerAnalyticsException.QueryValueMapUnexpectedValue
is Blinds -> if (session.blinds is S) {
session.blinds as S
is Blinds -> if (session.cgStakes is S) {
session.cgStakes as S
} else throw PokerAnalyticsException.QueryValueMapUnexpectedValue
else -> null
}

@ -0,0 +1,7 @@
package net.pokeranalytics.android.model
data class Stakes(var blinds: String?, var ante: Double?) {
}

@ -76,7 +76,7 @@ fun Session.getFormattedGameType(context: Context): String {
}
} else {
if (cgSmallBlind != null && cgBigBlind != null) {
parameters.add(getFormattedBlinds())
parameters.add(getFormattedStakes())
}
game?.let {
parameters.add(getFormattedGame())

@ -7,7 +7,9 @@ import net.pokeranalytics.android.model.filter.QueryCondition
import net.pokeranalytics.android.model.realm.*
import net.pokeranalytics.android.model.utils.Seed
import net.pokeranalytics.android.model.utils.SessionSetManager
import net.pokeranalytics.android.util.BLIND_SEPARATOR
import net.pokeranalytics.android.util.Preferences
import java.text.NumberFormat
class Patcher {
@ -32,8 +34,8 @@ class Patcher {
Preferences.executeOnce(Preferences.Keys.PATCH_TRANSACTION_TYPES_NAMES, context) {
patchDefaultTransactionTypes(context)
}
Preferences.executeOnce(Preferences.Keys.PATCH_BLINDS_FORMAT, context) {
patchBlindFormat()
Preferences.executeOnce(Preferences.Keys.PATCH_STAKES, context) {
patchStakes()
}
Preferences.executeOnce(Preferences.Keys.ADD_NEW_TRANSACTION_TYPES, context) {
@ -95,7 +97,8 @@ class Patcher {
it.computeStats()
}
sessions.forEach {
it.formatBlinds()
it.generateStakes()
it.defineHighestBet()
}
results.forEach {
it.computeNumberOfRebuy()
@ -120,12 +123,16 @@ class Patcher {
realm.close()
}
private fun patchBlindFormat() {
private fun patchStakes() {
val realm = Realm.getDefaultInstance()
realm.executeTransaction {
val sessions = realm.where(Session::class.java).findAll()
sessions.forEach { session ->
session.formatBlinds()
val blinds = arrayListOf(session.cgSmallBlind, session.cgBigBlind).filterNotNull()
val blindsFormatted = blinds.map { NumberFormat.getInstance().format(it) }
if (blindsFormatted.isNotEmpty()) {
session.cgBlinds = blindsFormatted.joinToString(BLIND_SEPARATOR)
}
}
}
realm.close()

@ -252,6 +252,19 @@ class PokerAnalyticsMigration : RealmMigration {
currentVersion++
}
// Migrate to version 12
if (currentVersion == 11) {
schema.get("Session")?.addField("cgAnte", Double::class.java)
?.setNullable("cgAnte", true)
schema.get("Session")?.addField("cgBiggestBet", Double::class.java)
?.setNullable("cgBiggestBet", true)
schema.get("Session")?.addField("cgStakes", String::class.java)
schema.get("Session")?.addField("cgBlinds", String::class.java)
schema.get("Session")?.removeField("blinds")
currentVersion++
}
}
override fun equals(other: Any?): Boolean {

@ -16,6 +16,7 @@ import net.pokeranalytics.android.calculus.StatFormattingException
import net.pokeranalytics.android.exceptions.ModelException
import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.model.Limit
import net.pokeranalytics.android.model.Stakes
import net.pokeranalytics.android.model.TableSize
import net.pokeranalytics.android.model.TournamentType
import net.pokeranalytics.android.model.extensions.SessionState
@ -26,17 +27,16 @@ import net.pokeranalytics.android.model.filter.QueryCondition
import net.pokeranalytics.android.model.filter.QueryCondition.*
import net.pokeranalytics.android.model.interfaces.*
import net.pokeranalytics.android.model.realm.handhistory.HandHistory
import net.pokeranalytics.android.util.CrashLogging
import net.pokeranalytics.android.model.utils.SessionSetManager
import net.pokeranalytics.android.ui.adapter.UnmanagedRowRepresentableException
import net.pokeranalytics.android.ui.graph.Graph
import net.pokeranalytics.android.ui.view.*
import net.pokeranalytics.android.ui.view.rows.SessionPropertiesRow
import net.pokeranalytics.android.util.NULL_TEXT
import net.pokeranalytics.android.util.TextFormat
import net.pokeranalytics.android.util.UserDefaults
import net.pokeranalytics.android.util.*
import net.pokeranalytics.android.util.extensions.*
import java.text.DateFormat
import java.text.NumberFormat
import java.text.ParseException
import java.util.*
import java.util.Currency
@ -64,6 +64,11 @@ open class Session : RealmObject(), Savable, RowUpdatable, RowRepresentable, Tim
companion object {
private val cbSeparator = ";"
private val cbAnte = "A="
private val cbBlinds = "B="
private val cbCode = "C="
fun newInstance(realm: Realm, isTournament: Boolean, bankroll: Bankroll? = null, managed: Boolean = true): Session {
val session = Session()
session.result = Result()
@ -264,7 +269,7 @@ open class Session : RealmObject(), Savable, RowUpdatable, RowRepresentable, Tim
override var bankroll: Bankroll? = null
set(value) {
field = value
this.formatBlinds()
this.generateStakes()
this.computeStats()
// this.updateRowRepresentation()
}
@ -300,20 +305,44 @@ open class Session : RealmObject(), Savable, RowUpdatable, RowRepresentable, Tim
var cgSmallBlind: Double? = null
set(value) {
field = value
formatBlinds()
// formatBlinds()
}
// The big blind value
var cgBigBlind: Double? = null
set(value) {
field = value
// formatBlinds()
this.computeStats()
this.result?.computeNumberOfRebuy()
}
// var blinds: String? = null
// private set
var cgAnte: Double? = null
set(value) {
field = value
this.generateStakes()
this.defineHighestBet()
this.computeStats()
this.result?.computeNumberOfRebuy()
}
var cgBlinds: String? = null
set(value) {
field = value
this.generateStakes()
this.defineHighestBet()
this.computeStats()
formatBlinds()
this.result?.computeNumberOfRebuy()
}
var blinds: String? = null
private set
var cgBiggestBet: Double? = null
var cgStakes: String? = null
// Tournament
@ -347,7 +376,7 @@ open class Session : RealmObject(), Savable, RowUpdatable, RowRepresentable, Tim
}
fun bankrollHasBeenUpdated() {
formatBlinds()
this.generateStakes()
}
/**
@ -639,24 +668,53 @@ open class Session : RealmObject(), Savable, RowUpdatable, RowRepresentable, Tim
return if (gameTitle.isNotBlank()) gameTitle else NULL_TEXT
}
fun getFormattedBlinds(): String {
return blinds ?: NULL_TEXT
}
fun getFormattedStakes(): String {
val components = arrayListOf<String>()
this.formattedBlinds?.let { components.add(it) }
this.formattedAnte?.let { components.add("($it)") }
fun formatBlinds() {
blinds = null
if (cgBigBlind == null) return
cgBigBlind?.let { bb ->
val sb = cgSmallBlind ?: bb / 2.0
val preFormattedBlinds = "${sb.formatted}/${bb.round()}"
println("<<<<<< bb.toCurrency(currency) : ${bb.toCurrency(currency)}")
println("<<<<<< preFormattedBlinds : $preFormattedBlinds")
val regex = Regex("-?\\d+(\\.\\d+)?")
blinds = bb.toCurrency(currency).replace(regex, preFormattedBlinds)
println("<<<<<< blinds = $blinds")
return if (components.isNotEmpty()) {
components.joinToString(" ")
} else {
NULL_TEXT
}
}
private val formattedBlinds: String?
get() {
this.cgBlinds?.let { blinds ->
val placeholder = 1.0
val regex = Regex("-?\\d+(\\.\\d+)?")
return placeholder.toCurrency(this.currency).replace(regex, blinds)
}
return null
}
private val formattedAnte: String?
get() {
this.cgAnte?.let { ante ->
return ante.toCurrency(this.currency)
}
return null
}
// fun formatBlinds() {
// blinds = null
// if (cgBigBlind == null) return
// cgBigBlind?.let { bb ->
// val sb = cgSmallBlind ?: bb / 2.0
// val preFormattedBlinds = "${sb.formatted}/${bb.round()}"
// println("<<<<<< bb.toCurrency(currency) : ${bb.toCurrency(currency)}")
// println("<<<<<< preFormattedBlinds : $preFormattedBlinds")
// val regex = Regex("-?\\d+(\\.\\d+)?")
// blinds = bb.toCurrency(currency).replace(regex, preFormattedBlinds)
// println("<<<<<< blinds = $blinds")
// }
// }
// LifeCycle
/**
@ -719,24 +777,28 @@ open class Session : RealmObject(), Savable, RowUpdatable, RowRepresentable, Tim
when (row) {
SessionPropertiesRow.BANKROLL -> bankroll = value as Bankroll?
SessionPropertiesRow.BLINDS -> if (value is ArrayList<*>) {
cgSmallBlind = try {
(value[0] as String? ?: "0").toDouble()
} catch (e: Exception) {
null
}
cgBigBlind = try {
(value[1] as String? ?: "0").toDouble()
} catch (e: Exception) {
null
}
cgBigBlind?.let {
if (cgSmallBlind == null || cgSmallBlind == 0.0) {
cgSmallBlind = it / 2.0
}
}
SessionPropertiesRow.STAKES -> if (value is Stakes) {
this.cgAnte = value.ante
this.cgBlinds = value.blinds
// cgSmallBlind = try {
// (value[0] as String? ?: "0").toDouble()
// } catch (e: Exception) {
// null
// }
//
// cgBigBlind = try {
// (value[1] as String? ?: "0").toDouble()
// } catch (e: Exception) {
// null
// }
//
// cgBigBlind?.let {
// if (cgSmallBlind == null || cgSmallBlind == 0.0) {
// cgSmallBlind = it / 2.0
// }
// }
} else if (value == null) {
cgSmallBlind = null
cgBigBlind = null
@ -957,7 +1019,7 @@ open class Session : RealmObject(), Savable, RowUpdatable, RowRepresentable, Tim
return when (row) {
SessionPropertiesRow.BANKROLL -> bankroll?.name ?: NULL_TEXT
SessionPropertiesRow.BLINDS -> getFormattedBlinds()
SessionPropertiesRow.STAKES -> getFormattedStakes()
SessionPropertiesRow.BREAK_TIME -> if (this.breakDuration > 0.0) this.breakDuration.toMinutes() else NULL_TEXT
SessionPropertiesRow.BUY_IN -> this.result?.buyin?.toCurrency(currency) ?: NULL_TEXT
SessionPropertiesRow.CASHED_OUT, SessionPropertiesRow.PRIZE -> this.result?.cashout?.toCurrency(currency) ?: NULL_TEXT
@ -1019,4 +1081,47 @@ open class Session : RealmObject(), Savable, RowUpdatable, RowRepresentable, Tim
this.result?.netResult = null
}
/// Stakes
fun generateStakes() {
if (this.cgAnte == null && this.cgAnte == null) {
this.cgStakes = null
return
}
val components = arrayListOf<String>()
this.cgBlinds?.let { components.add("${cbBlinds}${it}") }
this.cgAnte?.let { components.add("${cbAnte}${it.formatted}") }
val code = this.bankroll?.currency?.code ?: UserDefaults.currency.currencyCode
components.add("${cbCode}${code}")
this.cgStakes = components.joinToString(cbSeparator)
}
fun defineHighestBet() {
val bets = arrayListOf<Double>()
this.cgAnte?.let { bets.add(it) }
bets.addAll(this.blindValues)
this.cgBiggestBet = bets.maxOrNull()
}
private val blindValues: List<Double>
get() {
this.cgBlinds?.let { blinds ->
val blindsSplit = blinds.split(BLIND_SEPARATOR)
return blindsSplit.mapNotNull {
try {
NumberFormat.getInstance().parse(it)?.toDouble()
} catch (e: ParseException) {
null
}
}
}
return listOf()
}
}

@ -39,7 +39,7 @@ private fun Session.significantFields(): List<SessionPropertiesRow> {
Session.Type.CASH_GAME.ordinal -> {
return listOf(
SessionPropertiesRow.GAME,
SessionPropertiesRow.BLINDS,
SessionPropertiesRow.STAKES,
SessionPropertiesRow.BANKROLL,
SessionPropertiesRow.TABLE_SIZE
)

@ -12,12 +12,12 @@ import net.pokeranalytics.android.exceptions.RowRepresentableEditDescriptorExcep
import net.pokeranalytics.android.util.extensions.round
class BottomSheetDoubleEditTextFragment : BottomSheetFragment() {
open class BottomSheetDoubleEditTextFragment : BottomSheetFragment() {
private var _binding: BottomSheetDoubleEditTextBinding? = null
private val binding get() = _binding!!
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View? {
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View {
_binding = BottomSheetDoubleEditTextBinding.inflate(inflater, container, true)
return binding.root
}

@ -16,7 +16,7 @@ class BottomSheetEditTextFragment : BottomSheetFragment() {
private var _binding: BottomSheetEditTextBinding? = null
private val binding get() = _binding!!
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View? {
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View {
_binding = BottomSheetEditTextBinding.inflate(inflater, container, true)
return binding.root
}

@ -86,6 +86,7 @@ open class BottomSheetFragment : BottomSheetDialogFragment() {
BottomSheetType.DOUBLE_EDIT_TEXT -> BottomSheetDoubleEditTextFragment()
BottomSheetType.NUMERIC_TEXT -> BottomSheetNumericTextFragment()
BottomSheetType.SUM -> BottomSheetSumFragment()
BottomSheetType.CASH_GAME_STAKES -> BottomSheetStakesFragment()
}
}

@ -18,7 +18,7 @@ open class BottomSheetListFragment : BottomSheetFragment(), LiveRowRepresentable
private var _binding: BottomSheetListBinding? = null
private val binding get() = _binding!!
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View? {
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View {
_binding = BottomSheetListBinding.inflate(inflater, container, true)
return binding.root
}

@ -22,7 +22,7 @@ class BottomSheetListGameFragment : BottomSheetListFragment() {
private var _binding: BottomSheetGameListBinding? = null
private val binding get() = _binding!!
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View? {
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View {
_binding = BottomSheetGameListBinding.inflate(inflater, container, true)
return binding.root
}

@ -17,7 +17,7 @@ class BottomSheetNumericTextFragment : BottomSheetFragment() {
private var _binding: BottomSheetEditTextBinding? = null
private val binding get() = _binding!!
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View? {
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View {
_binding = BottomSheetEditTextBinding.inflate(inflater, container, true)
return binding.root
}

@ -0,0 +1,108 @@
package net.pokeranalytics.android.ui.fragment.components.bottomsheet
import android.os.Bundle
import android.text.InputType
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import androidx.core.widget.addTextChangedListener
import net.pokeranalytics.android.databinding.BottomSheetStakesBinding
import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.exceptions.RowRepresentableEditDescriptorException
class BottomSheetStakesFragment : BottomSheetFragment() {
private var _binding: BottomSheetStakesBinding? = null
private val binding get() = _binding!!
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View {
_binding = BottomSheetStakesBinding.inflate(inflater, container, true)
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initData()
initUI()
}
override fun onStart() {
super.onStart()
// binding.editText2.requestFocus()
}
/**
* Init data
*/
private fun initData() {
// this.viewModel.isEditingBlinds = this.viewModel.row == SessionRow.BLINDS
}
/**
* Init UI
*/
private fun initUI() {
val data = getDescriptors()?:throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor not found")
if (data.size != 2) {
throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency")
}
data[0].hintResId?.let { binding.editText.hint = getString(it) }
binding.editText.inputType = data[0].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
data[1].hintResId?.let { binding.editText2.hint = getString(it) }
// binding.editText2.setRawInputType(InputType.TYPE_CLASS_TEXT) //= InputType.TYPE_NULL // data[1].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
// binding.editText2.inputType = InputType.TYPE_NULL
binding.editText2.setTextIsSelectable(true)
binding.editText2.onCreateInputConnection(EditorInfo())?.let {
binding.stakesKeyboard.inputConnection = it
} ?: throw PAIllegalStateException("No connection for editText")
if (this.model.valueAsHint) {
this.model.stringValue?.let {
if (it.isNotBlank()) {
binding.editText.hint = it
}
}
this.model.secondStringValue?.let {
if (it.isNotBlank()) {
binding.editText2.hint = it
}
}
// if (this.viewModel.stringValue?.isNotBlank()) { editText.hint = values[0] }
// if (values[1].isNotBlank()) { editText2.hint = values[1] }
} else {
binding.editText.setText(this.model.stringValue)
binding.editText2.setText(this.model.secondStringValue)
}
binding.editText.addTextChangedListener {
this.model.stringValue = it?.toString()
}
binding.editText2.addTextChangedListener {
this.model.secondStringValue = it?.toString()
}
binding.editText2.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
this.onRowValueChanged()
// this.delegate.onRowValueChanged(values, row)
dismiss()
true
} else {
false
}
}
}
}

@ -17,7 +17,7 @@ class BottomSheetStaticListFragment : BottomSheetFragment(), StaticRowRepresenta
private var _binding: BottomSheetListBinding? = null
private val binding get() = _binding!!
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View? {
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View {
_binding = BottomSheetListBinding.inflate(inflater, container, true)
return binding.root
}

@ -19,7 +19,7 @@ class BottomSheetSumFragment : BottomSheetFragment() {
private var _binding: BottomSheetSumBinding? = null
private val binding get() = _binding!!
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View? {
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View {
_binding = BottomSheetSumBinding.inflate(inflater, container, true)
return binding.root
}

@ -19,7 +19,7 @@ class BottomSheetTableSizeGridFragment : BottomSheetFragment(), StaticRowReprese
private var _binding: BottomSheetGridBinding? = null
private val binding get() = _binding!!
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View? {
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View {
_binding = BottomSheetGridBinding.inflate(inflater, container, true)
return binding.root
}
@ -61,7 +61,7 @@ class BottomSheetTableSizeGridFragment : BottomSheetFragment(), StaticRowReprese
}
}
override fun adapterRows(): List<RowRepresentable>? {
override fun adapterRows(): List<RowRepresentable> {
return TableSize.all(this.model.alternativeLabels)
}

@ -12,7 +12,8 @@ enum class BottomSheetType {
EDIT_TEXT_MULTI_LINES,
DOUBLE_EDIT_TEXT,
NUMERIC_TEXT,
SUM;
SUM,
CASH_GAME_STAKES;
val validationRequired: Boolean
get() = when (this) {
@ -25,7 +26,7 @@ enum class BottomSheetType {
val addRequired: Boolean
get() = when (this) {
EDIT_TEXT, NUMERIC_TEXT, DOUBLE_EDIT_TEXT, EDIT_TEXT_MULTI_LINES, GRID, LIST_STATIC, SUM -> false
EDIT_TEXT, NUMERIC_TEXT, DOUBLE_EDIT_TEXT, EDIT_TEXT_MULTI_LINES, GRID, LIST_STATIC, SUM, CASH_GAME_STAKES -> false
else -> true
}
}

@ -577,10 +577,10 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
"defaultValue" to session.tableSize
)
)
SessionPropertiesRow.BLINDS -> row.editingDescriptors(
SessionPropertiesRow.STAKES -> row.editingDescriptors(
mapOf(
"sb" to session.cgSmallBlind?.round(),
"bb" to session.cgBigBlind?.round()
"blinds" to session.cgBlinds,
"ante" to session.cgAnte?.round()
)
)
SessionPropertiesRow.BUY_IN -> row.editingDescriptors(

@ -0,0 +1,79 @@
package net.pokeranalytics.android.ui.view.keyboard
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.inputmethod.InputConnection
import android.widget.FrameLayout
import androidx.appcompat.widget.LinearLayoutCompat
import kotlinx.android.synthetic.main.view_keyboard_stakes.view.*
import net.pokeranalytics.android.R
import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.util.BLIND_SEPARATOR
class StakesKeyboardView : LinearLayoutCompat {
var inputConnection: InputConnection? = null
/**
* Constructors
*/
constructor(context: Context) : super(context) {
// init()
}
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
init(context, attrs)
}
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context, attrs)
}
private fun init(context: Context, attrs: AttributeSet?) {
val layoutInflater = LayoutInflater.from(context)
val view = layoutInflater.inflate(R.layout.view_keyboard_stakes, this, false)
view.value_0.text = "0"
view.value_1.text = "1"
view.value_2.text = "2"
view.value_3.text = "3"
view.value_4.text = "4"
view.value_5.text = "5"
view.value_6.text = "6"
view.value_7.text = "7"
view.value_8.text = "8"
view.value_9.text = "9"
view.value_back.text = ""
view.value_separator.text = "/"
view.value_0.setOnClickListener { this.commitText("0") }
view.value_1.setOnClickListener { this.commitText("1") }
view.value_2.setOnClickListener { this.commitText("2") }
view.value_3.setOnClickListener { this.commitText("3") }
view.value_4.setOnClickListener { this.commitText("4") }
view.value_5.setOnClickListener { this.commitText("5") }
view.value_6.setOnClickListener { this.commitText("6") }
view.value_7.setOnClickListener { this.commitText("7") }
view.value_8.setOnClickListener { this.commitText("8") }
view.value_9.setOnClickListener { this.commitText("9") }
view.value_separator.setOnClickListener { this.commitText(BLIND_SEPARATOR) }
view.value_back.setOnClickListener { this.deleteText() }
val layoutParams = FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT
)
addView(view, layoutParams)
}
private fun commitText(string: String) {
this.inputConnection?.commitText(string, 1) ?: throw PAIllegalStateException("No input connection")
}
private fun deleteText() {
this.inputConnection?.deleteSurroundingText(1, 0) ?: throw PAIllegalStateException("No input connection")
}
}

@ -28,7 +28,7 @@ enum class SessionPropertiesRow : RowRepresentable {
TIPS,
GAME,
BLINDS,
STAKES,
LOCATION,
BANKROLL,
TABLE_SIZE,
@ -104,7 +104,7 @@ enum class SessionPropertiesRow : RowRepresentable {
Session.Type.CASH_GAME.ordinal -> {
when (state) {
SessionState.PENDING, SessionState.PLANNED -> {
return arrayListOf(GAME, BLINDS, LOCATION, BANKROLL, TABLE_SIZE, START_DATE, END_DATE)
return arrayListOf(GAME, STAKES, LOCATION, BANKROLL, TABLE_SIZE, START_DATE, END_DATE)
}
SessionState.STARTED, SessionState.PAUSED, SessionState.FINISHED -> {
@ -134,7 +134,7 @@ enum class SessionPropertiesRow : RowRepresentable {
fields.add(SeparatorRow())
fields.addAll(listOf(
GAME,
BLINDS,
STAKES,
LOCATION,
BANKROLL,
TABLE_SIZE,
@ -168,7 +168,7 @@ enum class SessionPropertiesRow : RowRepresentable {
BUY_IN -> R.string.buyin
TIPS -> R.string.tips
GAME -> R.string.game
BLINDS -> R.string.blinds
STAKES -> R.string.stakes
LOCATION -> R.string.location
BANKROLL -> R.string.bankroll
TABLE_SIZE -> R.string.table_size
@ -188,7 +188,7 @@ enum class SessionPropertiesRow : RowRepresentable {
get() {
return when (this) {
NET_RESULT, PRIZE, POSITION, PLAYERS, CASHED_OUT, INITIAL_BUY_IN, BUY_IN, TIPS,
GAME, BLINDS, LOCATION, BANKROLL, TABLE_SIZE, COMMENT,
GAME, STAKES, LOCATION, BANKROLL, TABLE_SIZE, COMMENT,
TOURNAMENT_TYPE, TOURNAMENT_NAME, TOURNAMENT_FEATURE, HANDS,
START_DATE, END_DATE, BREAK_TIME, HANDS_COUNT -> RowViewType.TITLE_VALUE.ordinal
}
@ -200,7 +200,7 @@ enum class SessionPropertiesRow : RowRepresentable {
NET_RESULT, CASHED_OUT, INITIAL_BUY_IN, BREAK_TIME, POSITION, PLAYERS,
PRIZE, HANDS_COUNT -> BottomSheetType.NUMERIC_TEXT
BUY_IN, TIPS -> BottomSheetType.SUM
BLINDS -> BottomSheetType.DOUBLE_EDIT_TEXT
STAKES -> BottomSheetType.CASH_GAME_STAKES
GAME -> BottomSheetType.LIST_GAME
TOURNAMENT_TYPE -> BottomSheetType.LIST_STATIC
LOCATION, BANKROLL, TOURNAMENT_NAME -> BottomSheetType.LIST
@ -214,17 +214,16 @@ enum class SessionPropertiesRow : RowRepresentable {
override fun editingDescriptors(map: Map<String, Any?>): ArrayList<RowRepresentableEditDescriptor>? {
return when (this) {
BLINDS -> {
val sb: String? by map
val bb: String? by map
STAKES -> {
val ante: Double? by map
val blinds: String? by map
arrayListOf(
RowRepresentableEditDescriptor(
sb, R.string.smallblind, InputType.TYPE_CLASS_NUMBER
ante, R.string.ante, InputType.TYPE_CLASS_NUMBER
or InputType.TYPE_NUMBER_FLAG_DECIMAL
),
RowRepresentableEditDescriptor(
bb, R.string.bigblind, InputType.TYPE_CLASS_NUMBER
or InputType.TYPE_NUMBER_FLAG_DECIMAL
blinds, R.string.blinds, InputType.TYPE_CLASS_TEXT
)
)
}

@ -102,7 +102,7 @@ class BottomSheetViewModel(var row: RowRepresentable) : ViewModel() {
throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency")
}
this.isEditingBlinds = this.row == SessionPropertiesRow.BLINDS
this.isEditingBlinds = this.row == SessionPropertiesRow.STAKES
this.stringValue = descriptors[0].defaultValue as? String
this.secondStringValue = descriptors[1].defaultValue as? String

@ -2,4 +2,5 @@ package net.pokeranalytics.android.util
const val NULL_TEXT: String = "--"
const val RANDOM_PLAYER: String = ""
const val FFMPEG_DESCRIPTOR_FILE = "descriptor.txt"
const val FFMPEG_DESCRIPTOR_FILE = "descriptor.txt"
const val BLIND_SEPARATOR: String = "/"

@ -32,7 +32,7 @@ class Preferences {
PATCH_BREAK("patchBreaks"),
PATCH_SESSION_SETS("patchSessionSet"),
PATCH_TRANSACTION_TYPES_NAMES("patchTransactionTypesNames"),
PATCH_BLINDS_FORMAT("patchBlindFormat"),
// PATCH_BLINDS_FORMAT("patchBlindFormat"),
PATCH_COMPUTABLE_RESULTS("patchPositiveSessions"),
SHOW_STOP_NOTIFICATIONS("showStopNotifications"),
ADD_NEW_TRANSACTION_TYPES("addNewTransactionTypes"),
@ -42,7 +42,9 @@ class Preferences {
LATEST_BLOG_POST_ID_DISPLAYED("latestBlogPostIdDisplayed"),
LAST_BLOG_TIPS_RETRIEVAL("lastBlogTipsRetrieval"),
SHOW_BLOG_TIPS("showBlogTips"),
LAST_REVIEW_REQUEST_DATE("lastReviewRequestDate")
LAST_REVIEW_REQUEST_DATE("lastReviewRequestDate"),
PATCH_STAKES("patchStakes"),
}
enum class FeedMessage {

@ -87,7 +87,6 @@
app:layout_constraintStart_toEndOf="@+id/color5"
app:layout_constraintTop_toBottomOf="@+id/color2" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/color7"
android:layout_width="@dimen/color_picker_circle_size"

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:background="@color/grey_darkest">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/top_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:gravity="center"
android:imeOptions="actionNext"
android:lines="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/editText2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="10" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/editText2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:gravity="center"
android:imeOptions="actionDone"
android:lines="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/editText"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:text="20" />
</androidx.constraintlayout.widget.ConstraintLayout>
<net.pokeranalytics.android.ui.view.keyboard.StakesKeyboardView
android:id="@+id/stakes_keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/top_container"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat android:layout_width="match_parent"
android:layout_height="216dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- use 0dp and layout weight -->
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.button.MaterialButton
android:id="@+id/value_1"
style="@style/PokerAnalyticsTheme.Button"
android:layout_marginVertical="2dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="@+id/value_4"
style="@style/PokerAnalyticsTheme.Button"
android:layout_marginVertical="2dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="@+id/value_7"
style="@style/PokerAnalyticsTheme.Button"
android:layout_marginVertical="2dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="@+id/value_decimal"
style="@style/PokerAnalyticsTheme.Button"
android:layout_marginVertical="2dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.button.MaterialButton
android:id="@+id/value_2"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="@+id/value_5"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="@+id/value_8"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="@+id/value_0"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.button.MaterialButton
android:id="@+id/value_3"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="@+id/value_6"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="@+id/value_9"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="@+id/value_back"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.button.MaterialButton
android:id="@+id/value_separator"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.appcompat.widget.LinearLayoutCompat>
Loading…
Cancel
Save