|
|
|
|
@ -3,11 +3,11 @@ package net.pokeranalytics.android.ui.view.keyboard |
|
|
|
|
import android.content.Context |
|
|
|
|
import android.util.AttributeSet |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.inputmethod.InputConnection |
|
|
|
|
import android.widget.FrameLayout |
|
|
|
|
import androidx.appcompat.widget.LinearLayoutCompat |
|
|
|
|
import kotlinx.android.synthetic.main.view_keyboard_stakes.view.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.databinding.ViewKeyboardStakesBinding |
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
|
import net.pokeranalytics.android.util.BLIND_SEPARATOR |
|
|
|
|
import java.text.DecimalFormatSymbols |
|
|
|
|
@ -16,6 +16,9 @@ class StakesKeyboardView : LinearLayoutCompat { |
|
|
|
|
|
|
|
|
|
var inputConnection: InputConnection? = null |
|
|
|
|
|
|
|
|
|
private var _binding: ViewKeyboardStakesBinding? = null |
|
|
|
|
private val binding get() = _binding!! |
|
|
|
|
|
|
|
|
|
constructor(context: Context) : super(context) { |
|
|
|
|
init(context, null) |
|
|
|
|
} |
|
|
|
|
@ -30,42 +33,51 @@ class StakesKeyboardView : LinearLayoutCompat { |
|
|
|
|
|
|
|
|
|
private fun init(context: Context, attrs: AttributeSet?) { |
|
|
|
|
val layoutInflater = LayoutInflater.from(context) |
|
|
|
|
val view = layoutInflater.inflate(R.layout.view_keyboard_stakes, this, false) |
|
|
|
|
|
|
|
|
|
view.value_0.text = "0" |
|
|
|
|
view.value_1.text = "1" |
|
|
|
|
view.value_2.text = "2" |
|
|
|
|
view.value_3.text = "3" |
|
|
|
|
view.value_4.text = "4" |
|
|
|
|
view.value_5.text = "5" |
|
|
|
|
view.value_6.text = "6" |
|
|
|
|
view.value_7.text = "7" |
|
|
|
|
view.value_8.text = "8" |
|
|
|
|
view.value_9.text = "9" |
|
|
|
|
view.value_decimal.text = DecimalFormatSymbols.getInstance().decimalSeparator.toString() |
|
|
|
|
view.value_back.text = "⌫" |
|
|
|
|
view.value_separator.text = "/" |
|
|
|
|
|
|
|
|
|
view.value_0.setOnClickListener { this.commitText("0") } |
|
|
|
|
view.value_1.setOnClickListener { this.commitText("1") } |
|
|
|
|
view.value_2.setOnClickListener { this.commitText("2") } |
|
|
|
|
view.value_3.setOnClickListener { this.commitText("3") } |
|
|
|
|
view.value_4.setOnClickListener { this.commitText("4") } |
|
|
|
|
view.value_5.setOnClickListener { this.commitText("5") } |
|
|
|
|
view.value_6.setOnClickListener { this.commitText("6") } |
|
|
|
|
view.value_7.setOnClickListener { this.commitText("7") } |
|
|
|
|
view.value_8.setOnClickListener { this.commitText("8") } |
|
|
|
|
view.value_9.setOnClickListener { this.commitText("9") } |
|
|
|
|
view.value_decimal.setOnClickListener { this.commitText(DecimalFormatSymbols.getInstance().decimalSeparator.toString()) } |
|
|
|
|
view.value_separator.setOnClickListener { this.commitText(BLIND_SEPARATOR) } |
|
|
|
|
view.value_back.setOnClickListener { this.deleteText() } |
|
|
|
|
// val view = layoutInflater.inflate(R.layout.view_keyboard_stakes, this, false) |
|
|
|
|
|
|
|
|
|
_binding = ViewKeyboardStakesBinding.inflate(layoutInflater, this, true) |
|
|
|
|
|
|
|
|
|
binding.value0.text = "0" |
|
|
|
|
binding.value1.text = "1" |
|
|
|
|
binding.value2.text = "2" |
|
|
|
|
binding.value3.text = "3" |
|
|
|
|
binding.value4.text = "4" |
|
|
|
|
binding.value5.text = "5" |
|
|
|
|
binding.value6.text = "6" |
|
|
|
|
binding.value7.text = "7" |
|
|
|
|
binding.value8.text = "8" |
|
|
|
|
binding.value9.text = "9" |
|
|
|
|
binding.valueDecimal.text = DecimalFormatSymbols.getInstance().decimalSeparator.toString() |
|
|
|
|
binding.valueBack.text = "⌫" |
|
|
|
|
binding.valueSeparator.text = "/" |
|
|
|
|
|
|
|
|
|
binding.value0.setOnClickListener { this.commitText("0") } |
|
|
|
|
binding.value1.setOnClickListener { this.commitText("1") } |
|
|
|
|
binding.value2.setOnClickListener { this.commitText("2") } |
|
|
|
|
binding.value3.setOnClickListener { this.commitText("3") } |
|
|
|
|
binding.value4.setOnClickListener { this.commitText("4") } |
|
|
|
|
binding.value5.setOnClickListener { this.commitText("5") } |
|
|
|
|
binding.value6.setOnClickListener { this.commitText("6") } |
|
|
|
|
binding.value7.setOnClickListener { this.commitText("7") } |
|
|
|
|
binding.value8.setOnClickListener { this.commitText("8") } |
|
|
|
|
binding.value9.setOnClickListener { this.commitText("9") } |
|
|
|
|
binding.valueDecimal.setOnClickListener { this.commitText(DecimalFormatSymbols.getInstance().decimalSeparator.toString()) } |
|
|
|
|
binding.valueSeparator.setOnClickListener { this.commitText(BLIND_SEPARATOR) } |
|
|
|
|
binding.valueBack.setOnClickListener { this.deleteText() } |
|
|
|
|
|
|
|
|
|
val layoutParams = FrameLayout.LayoutParams( |
|
|
|
|
FrameLayout.LayoutParams.MATCH_PARENT, |
|
|
|
|
FrameLayout.LayoutParams.WRAP_CONTENT |
|
|
|
|
) |
|
|
|
|
addView(view, layoutParams) |
|
|
|
|
// addView(binding, layoutParams) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// addView(view, layoutParams) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun setSeparatorVisibility(visible: Boolean) { |
|
|
|
|
binding.valueSeparator.visibility = if (visible) View.VISIBLE else View.GONE |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun commitText(string: String) { |
|
|
|
|
|