background for amount edittext

hh
Laurent 6 years ago
parent d004781edb
commit 024ea38b52
  1. 6
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt
  2. 33
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/HandHistoryAdapter.kt
  3. 6
      app/src/main/res/drawable/rounded_kaki_darker_rect.xml
  4. 6
      app/src/main/res/drawable/rounded_kaki_darkest_rect.xml
  5. 1
      app/src/main/res/drawable/rounded_kaki_medium_rect.xml
  6. 2
      app/src/main/res/layout/row_hand_action.xml
  7. 1
      app/src/main/res/values/colors.xml

@ -431,8 +431,8 @@ open class HandHistory : RealmObject(), Deletable, RowRepresentable, Filterable,
// Board
cardSets.add(this.board)
// Try to add cards while we haven't reach at least 4
while (views.size < 5 && cardSets.isNotEmpty()) {
// Try to add cards but not too much
while (views.size < 6 && cardSets.isNotEmpty()) {
val cardSet = cardSets.removeAt(0)
@ -448,7 +448,7 @@ open class HandHistory : RealmObject(), Deletable, RowRepresentable, Filterable,
val blankCard = Card()
(1..5).forEach { _ ->
val view = blankCard.view(context, layoutInflater, viewGroup, true)
view.setBackgroundResource(R.drawable.rounded_card_back_background)
view.setBackgroundResource(R.drawable.rounded_kaki_medium_rect)
views.add(view)
}
}

@ -160,14 +160,15 @@ class HandHistoryAdapter(
return itemView.context.getColor(color)
}
fun editTextSelected(editText: EditText, selected: Boolean) {
fun editTextSelected(editText: EditText) {
editText.setBackgroundColor(color(selected))
// editText.setBackgroundColor(color(selected))
val row = dataSource.rowRepresentableForPosition(this.currentPosition)
?: throw PAIllegalStateException("Row Representable not found at index: $currentPosition")
delegate?.onRowSelected(this.currentPosition, row, editText.tag as Int)
setEditTextBackground(editText, true, true)
}
override fun onBind(position: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
@ -188,30 +189,40 @@ class HandHistoryAdapter(
editText.setTextIsSelectable(true)
// Enabled
editText.isEnabled = adapter.dataSource.isEnabled(row, tag)
val isEnabled = adapter.dataSource.isEnabled(row, tag)
editText.isEnabled = isEnabled
// Text
val string = adapter.dataSource.charSequenceForRow(row, itemView.context, tag)
editText.setText(string)
// Focus
val focused = adapter.dataSource.isSelected(position, row, tag)
toggleFocus(editText, focused)
val isFocused = adapter.dataSource.isSelected(position, row, tag)
toggleFocus(editText, isFocused)
editText.isFocusable = adapter.dataSource.isFocusable(position, row, tag)
editText.isFocusableInTouchMode = adapter.dataSource.isFocusable(position, row, tag)
// Put cursor at the end
if (focused) {
if (isFocused) {
editText.setSelection(editText.text.length)
}
// Background
editText.setBackgroundColor(color(focused))
setEditTextBackground(editText, isEnabled, isFocused)
}
}
private fun setEditTextBackground(editText: EditText, isEnabled: Boolean, isFocused: Boolean) {
val background = when {
!isEnabled -> R.drawable.rounded_kaki_darkest_rect // disabled
isFocused -> R.drawable.rounded_kaki_medium_rect // focused
else -> R.drawable.rounded_kaki_darker_rect // default
}
editText.background = itemView.context.getDrawable(background)
}
protected fun configureTextView(tag: Int, row: RowRepresentable, adapter: RecyclerAdapter) {
val textView = itemView.findViewWithTag<TextView>(tag) ?: throw PAIllegalStateException("TextView not found for tag: $tag, class: $this")
textView.text = adapter.dataSource.charSequenceForRow(row, itemView.context, tag)
@ -230,7 +241,7 @@ class HandHistoryAdapter(
editText.requestFocus()
editTextSelected(editText, true)
editTextSelected(editText)
}
return@setOnTouchListener true
}
@ -447,7 +458,7 @@ class HandHistoryAdapter(
amountEditText.requestFocus()
editTextSelected(amountEditText, true)
editTextSelected(amountEditText)
}
return@setOnTouchListener true
}
@ -551,13 +562,9 @@ class HandHistoryAdapter(
this.delegate = adapter.delegate
// Position Button
itemView.position_button.text = adapter.dataSource.charSequenceForRow(row, itemView.context, PlayerSetupRow.Tag.POSITION.ordinal)
// val positionSelected = adapter.dataSource.isSelected(position, row, PlayerSetupRow.Tag.POSITION.ordinal)
// itemView.position_button.backgroundTintList = ColorStateList.valueOf(color(positionSelected))
val positionalRow = row as PositionalRow
itemView.position_button.backgroundTintList = ColorStateList.valueOf(color(positionalRow.isHero))

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/kaki_darker"/>
<!-- <stroke android:width="3dp" android:color="#B1BCBE" />-->
<corners android:radius="6dp"/>
</shape>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/kaki_darkest"/>
<!-- <stroke android:width="1dp" android:color="@color/kaki_darker" />-->
<corners android:radius="6dp"/>
</shape>

@ -3,5 +3,4 @@
<solid android:color="@color/kaki_medium"/>
<!-- <stroke android:width="3dp" android:color="#B1BCBE" />-->
<corners android:radius="6dp"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>

@ -32,7 +32,7 @@
style="@style/PokerAnalyticsTheme.HHEditText"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="44dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:paddingEnd="4dp"

@ -34,6 +34,7 @@
<color name="kaki_light">#657d60</color>
<color name="kaki_lighter">#9bae8d</color>
<color name="kaki_darker">#283227</color>
<color name="kaki_darkest">#1E231E</color>
<color name="red">#FF5F57</color>

Loading…
Cancel
Save