Keyboard improvement + doc

hh
Laurent 6 years ago
parent edc9b5d6b4
commit b98c0c3a38
  1. 18
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardAmountView.kt
  2. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/views/KeyboardContainer.kt

@ -17,6 +17,7 @@ import net.pokeranalytics.android.ui.view.GridSpacingItemDecoration
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType import net.pokeranalytics.android.ui.view.RowViewType
import net.pokeranalytics.android.util.extensions.noGroupingFormatted import net.pokeranalytics.android.util.extensions.noGroupingFormatted
import timber.log.Timber
import java.text.DecimalFormatSymbols import java.text.DecimalFormatSymbols
class NumericKey : RowRepresentable { class NumericKey : RowRepresentable {
@ -64,10 +65,16 @@ class NumericKey : RowRepresentable {
class KeyboardAmountView(context: Context) : AbstractKeyboardView(context), class KeyboardAmountView(context: Context) : AbstractKeyboardView(context),
StaticRowRepresentableDataSource, RowRepresentableDelegate { StaticRowRepresentableDataSource, RowRepresentableDelegate {
/***
* The adapter managing the grid displayed keyboard
*/
private var dataAdapter: RowRepresentableAdapter private var dataAdapter: RowRepresentableAdapter
private lateinit var editText: EditText private lateinit var editText: EditText
/***
* The interface linking the keyboard to the EditText
*/
private var inputConnection: InputConnection? = null private var inputConnection: InputConnection? = null
init { init {
@ -94,7 +101,7 @@ class KeyboardAmountView(context: Context) : AbstractKeyboardView(context),
this.clearButton.setOnClickListener { this.clearButton.setOnClickListener {
this.editText.text = null this.editText.text = null
this.keyboardListener?.clearAmount() this.keyboardListener?.amountCleared()
} }
this.closeButton.setOnClickListener { this.closeButton.setOnClickListener {
@ -103,11 +110,18 @@ class KeyboardAmountView(context: Context) : AbstractKeyboardView(context),
} }
fun setEditText(editText: EditText, amount: Double?) { fun setEditText(editText: EditText, amount: Double?) {
Timber.d("edit text = $editText")
this.editText = editText this.editText = editText
editText.setText(amount?.noGroupingFormatted) editText.setText(amount?.noGroupingFormatted)
// editText.requestFocus()
editText.onCreateInputConnection(EditorInfo())?.let {
this.inputConnection = it
} ?: run { throw PAIllegalStateException("EditText did not return an input Connection") }
this.inputConnection = editText.onCreateInputConnection(EditorInfo())
} }

@ -8,17 +8,17 @@ import android.widget.FrameLayout
import androidx.core.view.isVisible import androidx.core.view.isVisible
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
import net.pokeranalytics.android.exceptions.PAIllegalStateException import net.pokeranalytics.android.exceptions.PAIllegalStateException
import net.pokeranalytics.android.ui.modules.handhistory.HHKeyboard
import net.pokeranalytics.android.model.handhistory.Position import net.pokeranalytics.android.model.handhistory.Position
import net.pokeranalytics.android.model.realm.handhistory.Action import net.pokeranalytics.android.model.realm.handhistory.Action
import net.pokeranalytics.android.model.realm.handhistory.Card import net.pokeranalytics.android.model.realm.handhistory.Card
import net.pokeranalytics.android.ui.modules.handhistory.HHKeyboard
interface KeyboardListener { interface KeyboardListener {
fun actionSelected(action: Action.Type) fun actionSelected(action: Action.Type)
fun amountChanged(amount: String?) fun amountChanged(amount: String?)
fun amountValidated() fun amountValidated()
fun clearAmount() fun amountCleared()
fun cardValueSelected(value: Card.Value) fun cardValueSelected(value: Card.Value)
fun cardSuitSelected(suit: Card.Suit) fun cardSuitSelected(suit: Card.Suit)
fun clearCards() fun clearCards()

Loading…
Cancel
Save