Adds ability to change result capture method inside the session

kmm
Laurent 5 years ago
parent 8dd74bf99e
commit 81d8f5d8d9
  1. 16
      app/src/main/java/net/pokeranalytics/android/model/realm/Bankroll.kt
  2. 9
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  3. 15
      app/src/main/java/net/pokeranalytics/android/ui/adapter/HomePagerAdapter.kt
  4. 25
      app/src/main/java/net/pokeranalytics/android/ui/modules/feed/FeedFragment.kt
  5. 2
      app/src/main/java/net/pokeranalytics/android/ui/modules/feed/NewDataMenuActivity.kt
  6. 11
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerFragment.kt
  7. 67
      app/src/main/java/net/pokeranalytics/android/ui/modules/session/ResultCaptureSelectionPopup.kt
  8. 148
      app/src/main/java/net/pokeranalytics/android/ui/modules/session/SessionFragment.kt
  9. 90
      app/src/main/java/net/pokeranalytics/android/ui/modules/session/SessionViewModel.kt
  10. 10
      app/src/main/java/net/pokeranalytics/android/ui/view/SessionRowView.kt
  11. 24
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/SessionRow.kt
  12. 9
      app/src/main/res/drawable/ic_pause_circle_outline.xml
  13. 9
      app/src/main/res/drawable/ic_play_circle_outline.xml
  14. 9
      app/src/main/res/drawable/ic_swap_vert.xml
  15. 2
      app/src/main/res/layout/activity_new_data.xml
  16. 12
      app/src/main/res/layout/view_replayer_settings.xml
  17. 79
      app/src/main/res/layout/view_result_capture_method.xml
  18. 10
      app/src/main/res/menu/toolbar_session.xml

@ -15,6 +15,7 @@ import net.pokeranalytics.android.model.interfaces.NameManageable
import net.pokeranalytics.android.model.interfaces.SaveValidityStatus
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.rowrepresentable.BankrollRow
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow
import net.pokeranalytics.android.ui.view.rowrepresentable.SimpleRow
import net.pokeranalytics.android.util.Preferences
import net.pokeranalytics.android.util.UserDefaults
@ -22,7 +23,20 @@ import java.util.*
enum class ResultCaptureType {
BUYIN_CASHEDOUT,
NET_RESULT
NET_RESULT;
companion object {
val buyinCashedOutFields = listOf(SessionRow.CASHED_OUT, SessionRow.BUY_IN, SessionRow.TIPS)
val netResultFields = listOf(SessionRow.NET_RESULT)
}
val rowRepresentables: List<RowRepresentable>
get() {
return when (this) {
BUYIN_CASHEDOUT -> buyinCashedOutFields
NET_RESULT -> netResultFields
}
}
}
open class Bankroll : RealmObject(), NameManageable, RowRepresentable {

@ -993,4 +993,13 @@ open class Session : RealmObject(), Savable, Editable, RowRepresentable, Timed,
}
}
fun clearBuyinCashedOut() {
this.result?.buyin = null
this.result?.cashout = null
}
fun clearNetResult() {
this.result?.netResult = null
}
}

@ -4,6 +4,7 @@ import android.util.SparseArray
import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.ui.modules.calendar.CalendarFragment
import net.pokeranalytics.android.ui.fragment.ReportsFragment
import net.pokeranalytics.android.ui.fragment.SettingsFragment
@ -27,7 +28,7 @@ class HomePagerAdapter(fragmentManager: FragmentManager) :
2 -> CalendarFragment.newInstance()
3 -> ReportsFragment.newInstance()
4 -> SettingsFragment.newInstance()
else -> FeedFragment.newInstance()
else -> throw PAIllegalStateException("Should not happen")
}
}
@ -53,7 +54,7 @@ class HomePagerAdapter(fragmentManager: FragmentManager) :
CalendarFragment::class.java -> 2
ReportsFragment::class.java -> 3
SettingsFragment::class.java -> 4
else -> -1
else -> throw PAIllegalStateException("Should not happen")
}
}
@ -64,14 +65,4 @@ class HomePagerAdapter(fragmentManager: FragmentManager) :
}
}
// /**
// * Return the fragment at the position key
// */
// fun getFragment(key: Int): BaseFragment? {
// if (this.weakReferences.get(key) != null) {
// return this.weakReferences.get(key).get()
// }
// return null
// }
}

@ -54,8 +54,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis
companion object {
fun newInstance(): FeedFragment {
val fragment =
FeedFragment()
val fragment = FeedFragment()
val bundle = Bundle()
fragment.arguments = bundle
return fragment
@ -65,8 +64,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis
private var menuPosition: Int = 0
private var currentTab =
Tab.SESSIONS
private var currentTab = Tab.SESSIONS
private lateinit var sessionAdapter: FeedSessionRowRepresentableAdapter
private lateinit var transactionAdapter: FeedTransactionRowRepresentableAdapter
@ -249,11 +247,7 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis
*/
private fun initUI() {
this.sessionAdapter =
FeedSessionRowRepresentableAdapter(
getRealm(),
this
)
this.sessionAdapter = FeedSessionRowRepresentableAdapter(getRealm(), this)
registerForContextMenu(this.menuRecyclerView)
@ -284,6 +278,12 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis
messageBox.isVisible = false
}
val viewManager = SmoothScrollLinearLayoutManager(requireContext())
menuRecyclerView.apply {
setHasFixedSize(true)
layoutManager = viewManager
}
// Add button
addButton.setOnClickListener {
activity?.let {
@ -347,13 +347,6 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate, PurchaseLis
private fun initData() {
this.currentFilterable = FilterableType.SESSION
val viewManager = SmoothScrollLinearLayoutManager(requireContext())
menuRecyclerView.apply {
setHasFixedSize(true)
layoutManager = viewManager
}
applyFilter()
}

@ -79,7 +79,7 @@ class NewDataMenuActivity : BaseActivity() {
finishWithResult(2)
}
newHandHistory.setOnClickListener {
new_hand_history.setOnClickListener {
finishWithResult(3)
}

@ -225,8 +225,6 @@ class ReplayerFragment : RealmFragment() {
private fun openSettings() {
// val builder = AlertDialog.Builder(requireContext())
// Get the layout inflater
val inflater = requireActivity().layoutInflater
@ -247,15 +245,6 @@ class ReplayerFragment : RealmFragment() {
popupWindow.isFocusable = true
popupWindow.showAsDropDown(this.settings, 0, -300)
// builder.setView(view).setNegativeButton(R.string.ok) { dialog, _ ->
// dialog.cancel()
// }
//
// val dialog = builder.create()
// dialog.show()
}
}

@ -0,0 +1,67 @@
package net.pokeranalytics.android.ui.modules.session
import android.app.Activity
import android.widget.Button
import android.widget.PopupWindow
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup
import net.pokeranalytics.android.R
import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.model.realm.ResultCaptureType
interface ResultCaptureTypeDelegate {
fun resultCaptureTypeSelected(resultCaptureType: ResultCaptureType, applyBankroll: Boolean)
}
class ResultCaptureSelectionPopup(
private var delegate: ResultCaptureTypeDelegate,
var type: ResultCaptureType?,
activity: Activity
) : PopupWindow(activity) {
init {
// Get the layout inflater
val inflater = activity.layoutInflater
val view = inflater.inflate(R.layout.view_result_capture_method, null)
this.contentView = view
this.isFocusable = true
val netResultChip = view.findViewById<Chip>(R.id.chip_net_result)
netResultChip.isChecked = type == ResultCaptureType.NET_RESULT
netResultChip.isCheckedIconVisible = true
val buyinCashoutChip = view.findViewById<Chip>(R.id.chip_buyin_cashout)
buyinCashoutChip.isChecked = type == ResultCaptureType.BUYIN_CASHEDOUT
buyinCashoutChip.isCheckedIconVisible = true
val buttonSessionOnly = view.findViewById<Button>(R.id.button_session_only)
buttonSessionOnly.setOnClickListener {
validate(false)
dismiss()
}
val buttonSessionBankroll = view.findViewById<Button>(R.id.button_session_bankroll)
buttonSessionBankroll.setOnClickListener {
validate(true)
dismiss()
}
view.findViewById<Button>(R.id.cancel).setOnClickListener {
dismiss()
}
}
fun validate(applyBankroll: Boolean) {
val chipGroup = this.contentView.findViewById<ChipGroup>(R.id.result_capture_method)
val rct = when (chipGroup.checkedChipId) {
R.id.chip_net_result -> ResultCaptureType.NET_RESULT
R.id.chip_buyin_cashout -> ResultCaptureType.BUYIN_CASHEDOUT
else -> throw PAIllegalStateException("cannot happen / not managed")
}
this.delegate.resultCaptureTypeSelected(rct, applyBankroll)
}
}

@ -11,14 +11,11 @@ import androidx.interpolator.view.animation.FastOutSlowInInterpolator
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.DiffUtil
import com.crashlytics.android.Crashlytics
import io.realm.annotations.Ignore
import kotlinx.android.synthetic.main.fragment_session.*
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import net.pokeranalytics.android.R
import net.pokeranalytics.android.calculus.ComputedStat
import net.pokeranalytics.android.calculus.Stat
import net.pokeranalytics.android.calculus.bankroll.BankrollReportManager
import net.pokeranalytics.android.calculus.optimalduration.CashGameOptimalDurationCalculator
import net.pokeranalytics.android.exceptions.PAIllegalStateException
@ -39,17 +36,15 @@ import net.pokeranalytics.android.ui.modules.data.EditableDataActivity
import net.pokeranalytics.android.ui.modules.datalist.DataListActivity
import net.pokeranalytics.android.ui.modules.handhistory.HandHistoryActivity
import net.pokeranalytics.android.ui.view.*
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable
import net.pokeranalytics.android.ui.view.rowrepresentable.SeparatorRow
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow
import net.pokeranalytics.android.util.Preferences
import net.pokeranalytics.android.util.extensions.*
import timber.log.Timber
import java.util.*
class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepresentableDataSource {
class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepresentableDataSource, ResultCaptureTypeDelegate {
private lateinit var viewModel: SessionViewModel
private lateinit var model: SessionViewModel
companion object {
const val TIMER_DELAY = 60000L
@ -91,7 +86,7 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.viewModel = activity?.run {
this.model = activity?.run {
ViewModelProvider(this).get(SessionViewModel::class.java)
} ?: throw Exception("Invalid Activity")
@ -158,9 +153,10 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.stop -> stopSession()
R.id.newHandHistory -> addHandHistory()
R.id.newCustomField -> addNewCustomField()
R.id.new_hand_history -> addHandHistory()
R.id.new_custom_field -> addNewCustomField()
R.id.restart -> restartTimer()
R.id.change_result_capture_method -> changeResultCaptureMethod()
R.id.delete -> deleteSession()
}
return true
@ -170,13 +166,13 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
val realm = getRealm()
val sessionId = this.viewModel.sessionId
val sessionId = this.model.sessionId
if (sessionId != null) {
val sessionRealm = realm.findById<Session>(sessionId)
if (sessionRealm != null) {
if (this.viewModel.duplicate) { // duplicate session
if (this.model.duplicate) { // duplicate session
realm.executeTransaction {
val session = sessionRealm.duplicate()
currentSession = session
@ -191,7 +187,7 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
}
} else { // create new session
realm.executeTransaction { executeRealm ->
currentSession = Session.newInstance(executeRealm, this.viewModel.isTournament)
currentSession = Session.newInstance(executeRealm, this.model.isTournament)
FavoriteSessionFinder.copyParametersFromFavoriteSession(currentSession, null, requireContext())
}
// Find the nearest location around the user
@ -261,7 +257,11 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
when (row) {
SessionRow.CASHED_OUT, SessionRow.PRIZE, SessionRow.NET_RESULT,
SessionRow.BUY_IN, SessionRow.TIPS, SessionRow.START_DATE,
SessionRow.END_DATE, SessionRow.BANKROLL, SessionRow.BREAK_TIME -> updateSessionUI()
SessionRow.END_DATE, SessionRow.BREAK_TIME -> updateSessionUI()
SessionRow.BANKROLL -> {
updateSessionUI()
updateMenuUI() // result capture method
}
}
}
@ -322,6 +322,7 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
* Update Menu UI
*/
private fun updateMenuUI() {
when (currentSession.getState()) {
SessionState.PENDING, SessionState.PLANNED -> {
sessionMenu?.findItem(R.id.restart)?.isVisible = false
@ -336,6 +337,7 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
sessionMenu?.findItem(R.id.stop)?.isVisible = false
}
}
sessionMenu?.findItem(R.id.change_result_capture_method)?.isVisible = !this.currentSession.isLive
}
/**
@ -439,6 +441,15 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
updateSessionUI()
}
/***
* Shows result capture method popup
*/
private fun changeResultCaptureMethod() {
val currentMethod = this.model.resultCaptureType ?: this.currentSession.bankroll?.resultCaptureType(requireContext())
val resultCaptureSelectionPopup = ResultCaptureSelectionPopup(this, currentMethod, requireActivity())
resultCaptureSelectionPopup.showAtLocation(this.view, Gravity.CENTER, 0, 0)
}
/**
* Delete a session
*/
@ -462,12 +473,11 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
}
}
// Static Data Source
//// Static Data Source
// Override to surcharge custom field viewType
override fun viewTypeForPosition(position: Int): Int {
rowRepresentationForCurrentState[position].let {
this.model.rowForPosition(position).let {
if (it is CustomField) {
return RowViewType.TITLE_VALUE.ordinal
}
@ -475,87 +485,14 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
return super.viewTypeForPosition(position)
}
@Ignore
private var rowRepresentationForCurrentState: List<RowRepresentable> = mutableListOf()
private fun updatedRowRepresentationForCurrentState(context: Context): List<RowRepresentable> {
val rows = ArrayList<RowRepresentable>()
val session = this.currentSession
val result = session.result
val currency = session.currency
// Headers
when (this.currentSession.getState()) {
SessionState.STARTED -> {
rows.add(
CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT_BIG,
title = session.getFormattedDuration(),
valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = session.currency).textFormat
)
)
rows.add(SeparatorRow())
}
SessionState.PAUSED -> {
rows.add(
CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT_BIG,
resId = R.string.pause,
valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency).textFormat
)
)
rows.add(SeparatorRow())
}
SessionState.FINISHED -> {
rows.add(
CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT_BIG,
title = session.getFormattedDuration(),
valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency).textFormat
)
)
rows.add(
CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT,
resId = R.string.hour_rate_without_pauses,
valueTextFormat = ComputedStat(Stat.HOURLY_RATE, session.hourlyRate, currency = currency).textFormat
)
)
// if (!isTournament()) {
// rows.add(
// CustomizableRowRepresentable(
// RowViewType.HEADER_TITLE_VALUE,
// resId = R.string.bankroll_variation,
// computedStat = ComputedStat(Stat.HOURLY_RATE, 0.0, CurrencyUtils.getCurrency(bankroll))
// )
// )
// }
rows.add(SeparatorRow())
}
else -> {
}
}
// Rows
rows.addAll(SessionRow.getRows(this.currentSession, requireContext()))
// Add custom fields
getRealm().let {
rows.add(SeparatorRow())
rows.addAll(it.sorted<CustomField>())
}
return rows
}
fun updateRowRepresentation() {
this.rowRepresentationForCurrentState = this.updatedRowRepresentationForCurrentState(requireContext())
private fun updateRowRepresentation() {
this.model.updatedRowRepresentationForCurrentState(this.currentSession, getRealm(), requireContext())
this.sessionAdapter.notifyDataSetChanged()
// this.rowRepresentationForCurrentState = this.updatedRowRepresentationForCurrentState(requireContext())
}
override fun adapterRows(): List<RowRepresentable>? {
return this.rowRepresentationForCurrentState
return this.model.rows
}
override fun boolForRow(row: RowRepresentable): Boolean {
@ -688,5 +625,26 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate, StaticRowRepr
}
}
override fun resultCaptureTypeSelected(resultCaptureType: ResultCaptureType, applyBankroll: Boolean) {
getRealm().executeTransaction { // cleanup existing results
when (resultCaptureType) {
ResultCaptureType.NET_RESULT -> {
this.currentSession.clearBuyinCashedOut()
}
ResultCaptureType.BUYIN_CASHEDOUT -> {
this.currentSession.clearNetResult()
}
}
}
this.model.resultCaptureType = resultCaptureType
if (applyBankroll) {
this.currentSession.bankroll?.let { bankroll ->
Preferences.setResultCaptureType(bankroll, resultCaptureType, requireContext())
}
}
this.updateRowRepresentation()
}
}

@ -1,6 +1,23 @@
package net.pokeranalytics.android.ui.modules.session
import android.content.Context
import androidx.lifecycle.ViewModel
import io.realm.Realm
import net.pokeranalytics.android.R
import net.pokeranalytics.android.calculus.ComputedStat
import net.pokeranalytics.android.calculus.Stat
import net.pokeranalytics.android.model.extensions.SessionState
import net.pokeranalytics.android.model.extensions.getState
import net.pokeranalytics.android.model.realm.CustomField
import net.pokeranalytics.android.model.realm.ResultCaptureType
import net.pokeranalytics.android.model.realm.Session
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable
import net.pokeranalytics.android.ui.view.rowrepresentable.SeparatorRow
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow
import net.pokeranalytics.android.util.extensions.sorted
import java.util.ArrayList
class SessionViewModel : ViewModel() {
@ -19,4 +36,77 @@ class SessionViewModel : ViewModel() {
*/
var duplicate: Boolean = false
/***
* Overridden result capture type
*/
var resultCaptureType: ResultCaptureType? = null
/***
* The list
*/
var rows: List<RowRepresentable> = mutableListOf()
fun rowForPosition(position: Int): RowRepresentable {
return this.rows[position]
}
fun updatedRowRepresentationForCurrentState(session: Session, realm: Realm, context: Context) {
val rows = ArrayList<RowRepresentable>()
val result = session.result
val currency = session.currency
// Headers
when (session.getState()) {
SessionState.STARTED -> {
rows.add(
CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT_BIG,
title = session.getFormattedDuration(),
valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = session.currency).textFormat
)
)
rows.add(SeparatorRow())
}
SessionState.PAUSED -> {
rows.add(
CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT_BIG,
resId = R.string.pause,
valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency).textFormat
)
)
rows.add(SeparatorRow())
}
SessionState.FINISHED -> {
rows.add(
CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT_BIG,
title = session.getFormattedDuration(),
valueTextFormat = ComputedStat(Stat.NET_RESULT, result?.net ?: 0.0, currency = currency).textFormat
)
)
rows.add(
CustomizableRowRepresentable(
RowViewType.HEADER_TITLE_AMOUNT,
resId = R.string.hour_rate_without_pauses,
valueTextFormat = ComputedStat(Stat.HOURLY_RATE, session.hourlyRate, currency = currency).textFormat
)
)
rows.add(SeparatorRow())
}
else -> {
}
}
// Rows
rows.addAll(SessionRow.getRows(session, this.resultCaptureType, context))
// Add custom fields
rows.add(SeparatorRow())
rows.addAll(realm.sorted<CustomField>())
this.rows = rows
}
}

@ -92,10 +92,17 @@ class SessionRowView : FrameLayout {
SessionState.STARTED -> {
rowSession.gameResult.isVisible = false
rowSession.infoIcon.isVisible = true
rowSession.infoIcon.setImageResource(R.drawable.chip)
rowSession.infoIcon.setImageResource(R.drawable.ic_play_circle_outline)
rowSession.infoTitle.isVisible = true
rowSession.infoTitle.text = context.getString(R.string.running_session_state)
}
SessionState.PAUSED -> {
rowSession.gameResult.isVisible = false
rowSession.infoIcon.isVisible = true
rowSession.infoIcon.setImageResource(R.drawable.ic_pause_circle_outline)
rowSession.infoTitle.isVisible = true
rowSession.infoTitle.text = context.getString(R.string.paused_session_state)
}
SessionState.PLANNED -> {
rowSession.gameResult.isVisible = false
rowSession.infoIcon.isVisible = true
@ -107,7 +114,6 @@ class SessionRowView : FrameLayout {
rowSession.gameResult.isVisible = false
rowSession.infoIcon.isVisible = false
rowSession.infoTitle.isVisible = false
}
else -> {
rowSession.gameResult.isVisible = true

@ -46,7 +46,7 @@ enum class SessionRow : RowRepresentable {
/**
* Return the rows to display for the current session state
*/
fun getRows(session: Session, context: Context): List<RowRepresentable> {
fun getRows(session: Session, resultCaptureType: ResultCaptureType?, context: Context): List<RowRepresentable> {
when (session.type) {
Session.Type.TOURNAMENT.ordinal -> {
return when (session.getState()) {
@ -105,18 +105,22 @@ enum class SessionRow : RowRepresentable {
val fields = mutableListOf<RowRepresentable>()
when {
session.hasBuyin -> fields.addAll(listOf(CASHED_OUT, BUY_IN, TIPS))
session.hasNetResult -> fields.add(NET_RESULT)
else -> {
when (session.bankroll?.resultCaptureType(context)) {
ResultCaptureType.BUYIN_CASHEDOUT -> fields.addAll(listOf(CASHED_OUT, BUY_IN, TIPS))
ResultCaptureType.NET_RESULT -> fields.add(NET_RESULT)
else -> fields.add(NET_RESULT)
// RESULT
val resultFields = resultCaptureType?.rowRepresentables // #1 user overridden
?: when { // #2 already entered results
session.hasBuyin -> ResultCaptureType.buyinCashedOutFields
session.hasNetResult -> ResultCaptureType.netResultFields
else -> { // #3 bankroll defaults
when (session.bankroll?.resultCaptureType(context)) {
ResultCaptureType.BUYIN_CASHEDOUT -> ResultCaptureType.buyinCashedOutFields
ResultCaptureType.NET_RESULT -> ResultCaptureType.netResultFields
else -> ResultCaptureType.netResultFields
}
}
}
}
fields.addAll(resultFields)
// PROPERTIES
fields.add(SeparatorRow())
fields.add(COMMENT)
if (session.handHistories?.isNotEmpty() == true) {

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M9,16h2L11,8L9,8v8zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM13,16h2L15,8h-2v8z"
android:fillColor="#ffffff"/>
</vector>

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M10,16.5l6,-4.5 -6,-4.5v9zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"
android:fillColor="#ffffff"/>
</vector>

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M16,17.01V10h-2v7.01h-3L15,21l4,-3.99h-3zM9,3L5,6.99h3V14h2V6.99h3L9,3z"
android:fillColor="#ffffff"/>
</vector>

@ -49,7 +49,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/newHandHistory"
android:id="@+id/new_hand_history"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginBottom="8dp"

@ -1,19 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:padding="16dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- <TextView-->
<!-- android:text="@string/show_villain_cards"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toStartOf="@+id/show_villain_cards"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- />-->
<Switch
android:id="@+id/show_villain_cards"
android:layout_width="wrap_content"

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<TextView
android:id="@+id/message"
style="@style/PokerAnalyticsTheme.DefaultText"
android:text="@string/change_result_capture_method"
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"/>
<com.google.android.material.chip.ChipGroup
android:id="@+id/result_capture_method"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
app:chipSpacing="8dp"
app:singleSelection="true"
app:layout_constraintTop_toBottomOf="@+id/message"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<com.google.android.material.chip.Chip
android:id="@+id/chip_net_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/net_result_only" />
<com.google.android.material.chip.Chip
android:id="@+id/chip_buyin_cashout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/stack_buy_in" />
</com.google.android.material.chip.ChipGroup>
<LinearLayout
android:orientation="vertical"
android:id="@+id/action_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/result_capture_method"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<com.google.android.material.button.MaterialButton
android:id="@+id/button_session_only"
android:text="@string/use_for_this_session"
android:paddingHorizontal="8dp"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.material.button.MaterialButton
android:id="@+id/button_session_bankroll"
android:text="@string/use_apply_for_bankroll"
android:paddingHorizontal="8dp"
style="@style/PokerAnalyticsTheme.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.material.button.MaterialButton
android:id="@+id/cancel"
android:text="@string/cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -8,17 +8,23 @@
app:showAsAction="always" />
<item
android:id="@+id/newHandHistory"
android:id="@+id/new_hand_history"
android:title="@string/new_hand"
android:icon="@drawable/ic_add"
app:showAsAction="never" />
<item
android:id="@+id/newCustomField"
android:id="@+id/new_custom_field"
android:title="@string/new_custom_field"
android:icon="@drawable/ic_add"
app:showAsAction="never" />
<item
android:id="@+id/change_result_capture_method"
android:title="@string/change_result_capture_method"
android:icon="@drawable/ic_swap_vert"
app:showAsAction="never" />
<item
android:id="@+id/restart"
android:title="@string/restart_timer"

Loading…
Cancel
Save