|
|
|
|
@ -216,38 +216,6 @@ class HandHistoryAdapter( |
|
|
|
|
this.configureEditTexts(index..index, position, row, adapter) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected fun setClickListener(editText: EditText) { |
|
|
|
|
|
|
|
|
|
editText.isFocusableInTouchMode = true |
|
|
|
|
|
|
|
|
|
// editText.setOnClickListener { |
|
|
|
|
// |
|
|
|
|
// itemView.context.hideKeyboard(it) |
|
|
|
|
// |
|
|
|
|
// editText.isFocusable = true |
|
|
|
|
// editText.isFocusableInTouchMode = true |
|
|
|
|
// |
|
|
|
|
// editText.requestFocus() |
|
|
|
|
// |
|
|
|
|
// editTextSelected(editText, true, editText.tag as Int) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
editText.setOnTouchListener { _, event -> |
|
|
|
|
|
|
|
|
|
if (event.action == MotionEvent.ACTION_UP) { |
|
|
|
|
// Both are required, otherwise requestFocus() fails |
|
|
|
|
editText.isFocusable = true |
|
|
|
|
editText.isFocusableInTouchMode = true |
|
|
|
|
|
|
|
|
|
editText.requestFocus() |
|
|
|
|
|
|
|
|
|
editTextSelected(editText, true, editText.tag as Int) |
|
|
|
|
} |
|
|
|
|
return@setOnTouchListener true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected fun configureEditTexts(tagRange: IntRange, position: Int, row: RowRepresentable, adapter: RecyclerAdapter) { |
|
|
|
|
|
|
|
|
|
tagRange.forEach { tag -> |
|
|
|
|
@ -270,6 +238,11 @@ class HandHistoryAdapter( |
|
|
|
|
editText.isFocusable = adapter.dataSource.isFocusable(position, row, tag) |
|
|
|
|
editText.isFocusableInTouchMode = adapter.dataSource.isFocusable(position, row, tag) |
|
|
|
|
|
|
|
|
|
// Put cursor at the end |
|
|
|
|
if (focused) { |
|
|
|
|
editText.setSelection(editText.text.length) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Background |
|
|
|
|
editText.setBackgroundColor(color(focused)) |
|
|
|
|
|
|
|
|
|
@ -277,6 +250,26 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected fun setClickListener(editText: EditText) { |
|
|
|
|
|
|
|
|
|
editText.isFocusableInTouchMode = true |
|
|
|
|
|
|
|
|
|
editText.setOnTouchListener { _, event -> |
|
|
|
|
|
|
|
|
|
if (event.action == MotionEvent.ACTION_UP) { |
|
|
|
|
// Both are required, otherwise requestFocus() fails |
|
|
|
|
editText.isFocusable = true |
|
|
|
|
editText.isFocusableInTouchMode = true |
|
|
|
|
|
|
|
|
|
editText.requestFocus() |
|
|
|
|
|
|
|
|
|
editTextSelected(editText, true, editText.tag as Int) |
|
|
|
|
} |
|
|
|
|
return@setOnTouchListener true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun toggleFocus(editText: EditText, focused: Boolean) { |
|
|
|
|
if (focused) { |
|
|
|
|
editText.requestFocus() |
|
|
|
|
@ -326,7 +319,6 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
val chip = Chip(itemView.context) |
|
|
|
|
chip.id = View.generateViewId() |
|
|
|
|
// chip.tag = filter.id |
|
|
|
|
chip.text = pos.shortValue |
|
|
|
|
chip.chipStartPadding = 4f.px |
|
|
|
|
chip.chipEndPadding = 4f.px |
|
|
|
|
@ -402,7 +394,6 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
// Action |
|
|
|
|
itemView.findViewById<Button>(R.id.actionButton)?.let { actionButton -> |
|
|
|
|
// actionButton.isEnabled = computedAction.actionTypeCanBeEdited |
|
|
|
|
actionButton.isEnabled = adapter.dataSource.isEnabled(row, actionButton.tag as Int) |
|
|
|
|
|
|
|
|
|
val selected = adapter.dataSource.isSelected(position, row, actionButton.tag as Int) |
|
|
|
|
@ -418,27 +409,8 @@ class HandHistoryAdapter( |
|
|
|
|
|
|
|
|
|
// Amount |
|
|
|
|
itemView.findViewById<EditText>(R.id.amountEditText)?.let { amountEditText -> |
|
|
|
|
// amountEditText.isEnabled = computedAction.amountCanBeEdited |
|
|
|
|
|
|
|
|
|
val tag = amountEditText.tag as Int |
|
|
|
|
configureEditTexts(tag, position, row, adapter) |
|
|
|
|
|
|
|
|
|
// val selected = adapter.dataSource.isSelected(position, row, tag) |
|
|
|
|
// amountEditText.setBackgroundColor(color(selected)) |
|
|
|
|
|
|
|
|
|
// Useful to have the cursor disappear when the keyboard is closed |
|
|
|
|
// amountEditText.isFocusable = selected && computedAction.amountCanBeEdited |
|
|
|
|
// amountEditText.isFocusableInTouchMode = selected && computedAction.amountCanBeEdited |
|
|
|
|
|
|
|
|
|
// amountEditText.setText(computedAction.action.formattedAmount) |
|
|
|
|
// |
|
|
|
|
// if (selected) { |
|
|
|
|
// amountEditText.requestFocus() |
|
|
|
|
// } else { |
|
|
|
|
// amountEditText.clearFocus() |
|
|
|
|
// } |
|
|
|
|
// Timber.d("Amount at $position is selected: $selected, focusable = ${amountEditText.isFocusable}, isFocusableInTouchMode = ${amountEditText.isFocusableInTouchMode}, hasFocus = ${amountEditText.hasFocus()}, enabled = ${amountEditText.isEnabled}") |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -456,11 +428,6 @@ class HandHistoryAdapter( |
|
|
|
|
itemView.turnEditText.tag = Street.TURN.ordinal |
|
|
|
|
itemView.riverEditText.tag = Street.RIVER.ordinal |
|
|
|
|
|
|
|
|
|
// hides soft input view |
|
|
|
|
// itemView.flopEditText.setTextIsSelectable(true) |
|
|
|
|
// itemView.turnEditText.setTextIsSelectable(true) |
|
|
|
|
// itemView.riverEditText.setTextIsSelectable(true) |
|
|
|
|
|
|
|
|
|
setClickListener(itemView.flopEditText) |
|
|
|
|
setClickListener(itemView.turnEditText) |
|
|
|
|
setClickListener(itemView.riverEditText) |
|
|
|
|
|