HH settings are now hidden by default

hh
Laurent 6 years ago
parent 4c122dbd6c
commit 76264ddabb
  1. 4
      app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt
  2. 8
      app/src/main/java/net/pokeranalytics/android/ui/adapter/RowRepresentableDataSource.kt
  3. 8
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  4. 9
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryFragment.kt
  5. 43
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/model/HandHistoryViewModel.kt
  6. 23
      app/src/main/java/net/pokeranalytics/android/ui/view/holder/RowViewHolder.kt
  7. 9
      app/src/main/res/drawable/ic_arrow_down.xml
  8. 3
      app/src/main/res/drawable/ic_arrow_right.xml
  9. 9
      app/src/main/res/drawable/ic_arrow_up.xml
  10. 2
      app/src/main/res/layout/row_hand_history_view.xml
  11. 1
      app/src/main/res/layout/row_hhsettings_straddle.xml

@ -236,12 +236,12 @@ enum class Stat(override var uniqueIdentifier: Int) : IntIdentifiable, RowRepres
get() { get() {
return when (this) { return when (this) {
HOURLY_DURATION, AVERAGE_HOURLY_DURATION, HOURLY_DURATION, AVERAGE_HOURLY_DURATION,
STANDARD_DEVIATION, STANDARD_DEVIATION_HOURLY, STANDARD_DEVIATION_BB_PER_100_HANDS -> false STANDARD_DEVIATION, STANDARD_DEVIATION_HOURLY,
STANDARD_DEVIATION_BB_PER_100_HANDS -> false
else -> true else -> true
} }
} }
val legendHideRightValue: Boolean val legendHideRightValue: Boolean
get() { get() {
return when (this) { return when (this) {

@ -1,6 +1,7 @@
package net.pokeranalytics.android.ui.adapter package net.pokeranalytics.android.ui.adapter
import android.content.Context import android.content.Context
import net.pokeranalytics.android.R
import net.pokeranalytics.android.exceptions.PAIllegalStateException import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
@ -144,6 +145,13 @@ interface DisplayableDataSource {
return 0 return 0
} }
/***
* Returns an arrowIcon
*/
fun arrowIcon(position: Int, row: RowRepresentable): Int? {
return R.drawable.ic_arrow_right
}
/** /**
* Returns whether the row, or its component, should be enabled * Returns whether the row, or its component, should be enabled
*/ */

@ -44,6 +44,7 @@ import net.pokeranalytics.android.util.extensions.formatted
enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable { enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable {
DEFAULT(R.layout.row_title), DEFAULT(R.layout.row_title),
HEADER(R.layout.row_header_value), HEADER(R.layout.row_header_value),
SETTINGS_HEADER(R.layout.row_title_icon_arrow),
ACTION(R.layout.row_hand_action), ACTION(R.layout.row_hand_action),
PLAYER_SUMMARY(R.layout.row_hand_player_summary), PLAYER_SUMMARY(R.layout.row_hand_player_summary),
STREET(R.layout.row_hand_cards), STREET(R.layout.row_hand_cards),
@ -82,6 +83,7 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable {
COMMENT -> R.string.comment COMMENT -> R.string.comment
ANTE -> R.string.ante ANTE -> R.string.ante
BIG_BLIND_ANTE, BIG_BLIND_ANTE_READ -> R.string.bb_ante_option BIG_BLIND_ANTE, BIG_BLIND_ANTE_READ -> R.string.bb_ante_option
SETTINGS_HEADER -> R.string.settings
else -> null else -> null
} }
} }
@ -90,6 +92,7 @@ enum class HandRowType(var layoutRes: Int) : ViewIdentifier, RowRepresentable {
get() { get() {
return when(this) { return when(this) {
COMMENT -> R.drawable.picto_comment COMMENT -> R.drawable.picto_comment
SETTINGS_HEADER -> R.drawable.picto_gear
else -> null else -> null
} }
} }
@ -115,6 +118,7 @@ class HandHistoryAdapter(
return when (rowType) { return when (rowType) {
HandRowType.DEFAULT -> RowViewHolder(layout) HandRowType.DEFAULT -> RowViewHolder(layout)
HandRowType.HEADER -> RowViewHolder(layout) HandRowType.HEADER -> RowViewHolder(layout)
HandRowType.SETTINGS_HEADER -> RowViewHolder(layout)
HandRowType.ACTION -> RowActionHolder(layout) HandRowType.ACTION -> RowActionHolder(layout)
HandRowType.STREET -> RowStreetHolder(layout) HandRowType.STREET -> RowStreetHolder(layout)
HandRowType.PLAYER_SUMMARY -> RowPlayerSummaryHolder(layout) HandRowType.PLAYER_SUMMARY -> RowPlayerSummaryHolder(layout)
@ -350,6 +354,10 @@ class HandHistoryAdapter(
val straddleRow = row as StraddleRowRepresentable val straddleRow = row as StraddleRowRepresentable
adapter.dataSource.backgroundColor(position, row)?.let { color ->
itemView.findViewById<ViewGroup>(R.id.container)?.setBackgroundColor(itemView.context.getColor(color))
}
itemView.positionsChipGroup.removeAllViews() itemView.positionsChipGroup.removeAllViews()
straddleRow.positions.forEach { pos -> straddleRow.positions.forEach { pos ->

@ -308,6 +308,11 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
super.onRowSelected(position, row, tag) super.onRowSelected(position, row, tag)
Timber.d("onRowSelected: $position, tag = $tag, row = $row") Timber.d("onRowSelected: $position, tag = $tag, row = $row")
if (row == HandRowType.SETTINGS_HEADER) {
val ru = this.model.toggleSettingsRows()
this.handHistoryAdapter.notifyDataSetChanged()
return
}
val alreadySelected = this.model.isSelected(position, row, tag) val alreadySelected = this.model.isSelected(position, row, tag)
if (alreadySelected || !this.model.isEdited) { if (alreadySelected || !this.model.isEdited) {
@ -333,6 +338,8 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
} }
} }
if (row is HandHistoryRow) {
this.model.selectionLiveData.value?.index?.let { oldIndex -> this.model.selectionLiveData.value?.index?.let { oldIndex ->
refreshRowAtIndexAndCurrent(oldIndex) refreshRowAtIndexAndCurrent(oldIndex)
} }
@ -341,6 +348,8 @@ class HandHistoryFragment : RealmFragment(), RowRepresentableDelegate, KeyboardL
} }
}
override fun onRowDeselected(position: Int, row: RowRepresentable) { override fun onRowDeselected(position: Int, row: RowRepresentable) {
this.model.selectionLiveData.value = null this.model.selectionLiveData.value = null
this.model.currentAmount = null this.model.currentAmount = null

@ -24,6 +24,7 @@ import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable
import net.pokeranalytics.android.util.extensions.formatted import net.pokeranalytics.android.util.extensions.formatted
import timber.log.Timber import timber.log.Timber
import kotlin.math.abs
import kotlin.reflect.KClass import kotlin.reflect.KClass
enum class HHKeyboard { enum class HHKeyboard {
@ -56,6 +57,11 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
*/ */
private var isNew: Boolean = true private var isNew: Boolean = true
/***
* Indicates if the settings are expanded
*/
private var settingsExpanded = false
/*** /***
* Indicates whether the hand history is being edited or not * Indicates whether the hand history is being edited or not
*/ */
@ -146,6 +152,11 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
*/ */
private var straddlePositions: LinkedHashSet<Position> = linkedSetOf() private var straddlePositions: LinkedHashSet<Position> = linkedSetOf()
/***
* Number of settings rows
*/
private var settingsRowCount: Int = 1
/*** /***
* Creates and configures a new HandHistory object using a [handSetup] * Creates and configures a new HandHistory object using a [handSetup]
*/ */
@ -265,15 +276,25 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
return rows return rows
} }
private fun editionRowRepresentation(): MutableList<RowRepresentable> { override fun backgroundColor(position: Int, row: RowRepresentable): Int? {
return if (position < this.settingsRowCount) R.color.gray_darker else R.color.transparent
}
val rows: MutableList<RowRepresentable> = mutableListOf() override fun arrowIcon(position: Int, row: RowRepresentable): Int? {
return when (row) {
HandRowType.SETTINGS_HEADER -> {
if (this.settingsExpanded) R.drawable.ic_arrow_up else R.drawable.ic_arrow_down
}
else -> null
}
}
rows.add(HandRowType.COMMENT) private fun editionRowRepresentation(): MutableList<RowRepresentable> {
// rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.settings, value = "")) val rows: MutableList<RowRepresentable> = mutableListOf()
rows.add(HandRowType.PLAYER_NUMBER) rows.add(HandRowType.SETTINGS_HEADER)
if (this.settingsExpanded) {
rows.add(HandRowType.ANTE) rows.add(HandRowType.ANTE)
if (this.handSetup.type != Session.Type.CASH_GAME) { if (this.handSetup.type != Session.Type.CASH_GAME) {
@ -289,6 +310,13 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
positions.remove(Position.BB) positions.remove(Position.BB)
rows.add(StraddleRowRepresentable(positions, this.straddlePositions)) rows.add(StraddleRowRepresentable(positions, this.straddlePositions))
} }
}
// Updates the settings row count to set the proper background
this.settingsRowCount = rows.size
rows.add(HandRowType.COMMENT)
rows.add(HandRowType.PLAYER_NUMBER)
// Used to set the hero position // Used to set the hero position
rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.set_hero_position, value = "")) rows.add(CustomizableRowRepresentable(customViewType = HandRowType.HEADER, resId = R.string.set_hero_position, value = ""))
@ -946,4 +974,9 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra
this.createRowRepresentation() // refresh this.createRowRepresentation() // refresh
} }
fun toggleSettingsRows() {
this.settingsExpanded = !this.settingsExpanded
this.createRowRepresentation()
}
} }

@ -1,5 +1,6 @@
package net.pokeranalytics.android.ui.view.holder package net.pokeranalytics.android.ui.view.holder
import android.content.res.ColorStateList
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatImageView
@ -86,6 +87,10 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl
} }
} }
adapter.dataSource.backgroundColor(position, row)?.let { color ->
itemView.findViewById<ViewGroup>(R.id.container)?.setBackgroundColor(itemView.context.getColor(color))
}
} }
else -> { // Standard row else -> { // Standard row
@ -129,6 +134,24 @@ class RowViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Bindabl
} }
} }
// Arrow Icon
itemView.findViewById<AppCompatImageView?>(R.id.nextArrow)?.let { imageView ->
imageView.setImageDrawable(null)
val arrow = adapter.dataSource.arrowIcon(position, row) ?: row.imageRes
arrow?.let {
imageView.setImageResource(it)
}
// adapter.dataSource.arrowIcon(position, row)?.let {
// imageView.setImageResource(it)
// } ?: run {
// row.imageRes?.let { imageRes ->
// imageView.setImageResource(imageRes)
// }
// }
}
// Action // Action
itemView.findViewById<AppCompatImageView>(R.id.action)?.let { imageView -> itemView.findViewById<AppCompatImageView>(R.id.action)?.let { imageView ->
imageView.setImageDrawable(null) imageView.setImageDrawable(null)

@ -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="M7.41,8.59L12,13.17l4.59,-4.58L18,10l-6,6 -6,-6 1.41,-1.41z"
android:fillColor="@color/gray_light"/>
</vector>

@ -1,5 +1,6 @@
<vector android:height="24dp" android:tint="#FFFFFF" <vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0" android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M8.59,16.34l4.58,-4.59 -4.58,-4.59L10,5.75l6,6 -6,6z"/> <path android:fillColor="@color/gray_light"
android:pathData="M8.59,16.34l4.58,-4.59 -4.58,-4.59L10,5.75l6,6 -6,6z"/>
</vector> </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="M7.41,15.41L12,10.83l4.59,4.58L18,14l-6,-6 -6,6z"
android:fillColor="@color/gray_light"/>
</vector>

@ -59,8 +59,6 @@
android:id="@+id/nextArrow" android:id="@+id/nextArrow"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:src="@drawable/ic_arrow_right"
android:tint="@color/gray_light"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/guidelineEnd" app:layout_constraintEnd_toEndOf="@+id/guidelineEnd"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">

Loading…
Cancel
Save