parent
d095a8c5af
commit
b20bb4815d
@ -0,0 +1,7 @@ |
||||
package net.pokeranalytics.android.model |
||||
|
||||
data class Stakes(var blinds: String?, var ante: Double?) { |
||||
|
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,108 @@ |
||||
package net.pokeranalytics.android.ui.fragment.components.bottomsheet |
||||
|
||||
import android.os.Bundle |
||||
import android.text.InputType |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import android.view.inputmethod.EditorInfo |
||||
import androidx.core.widget.addTextChangedListener |
||||
import net.pokeranalytics.android.databinding.BottomSheetStakesBinding |
||||
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
||||
import net.pokeranalytics.android.exceptions.RowRepresentableEditDescriptorException |
||||
|
||||
class BottomSheetStakesFragment : BottomSheetFragment() { |
||||
|
||||
private var _binding: BottomSheetStakesBinding? = null |
||||
private val binding get() = _binding!! |
||||
|
||||
override fun inflateContentView(inflater: LayoutInflater, container: ViewGroup): View { |
||||
_binding = BottomSheetStakesBinding.inflate(inflater, container, true) |
||||
return binding.root |
||||
} |
||||
|
||||
override fun onDestroyView() { |
||||
super.onDestroyView() |
||||
_binding = null |
||||
} |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
initData() |
||||
initUI() |
||||
} |
||||
|
||||
override fun onStart() { |
||||
super.onStart() |
||||
// binding.editText2.requestFocus() |
||||
} |
||||
|
||||
/** |
||||
* Init data |
||||
*/ |
||||
private fun initData() { |
||||
// this.viewModel.isEditingBlinds = this.viewModel.row == SessionRow.BLINDS |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
|
||||
val data = getDescriptors()?:throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor not found") |
||||
if (data.size != 2) { |
||||
throw RowRepresentableEditDescriptorException("RowRepresentableEditDescriptor inconsistency") |
||||
} |
||||
|
||||
data[0].hintResId?.let { binding.editText.hint = getString(it) } |
||||
binding.editText.inputType = data[0].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
||||
data[1].hintResId?.let { binding.editText2.hint = getString(it) } |
||||
|
||||
// binding.editText2.setRawInputType(InputType.TYPE_CLASS_TEXT) //= InputType.TYPE_NULL // data[1].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
||||
// binding.editText2.inputType = InputType.TYPE_NULL |
||||
binding.editText2.setTextIsSelectable(true) |
||||
|
||||
binding.editText2.onCreateInputConnection(EditorInfo())?.let { |
||||
binding.stakesKeyboard.inputConnection = it |
||||
} ?: throw PAIllegalStateException("No connection for editText") |
||||
|
||||
if (this.model.valueAsHint) { |
||||
|
||||
this.model.stringValue?.let { |
||||
if (it.isNotBlank()) { |
||||
binding.editText.hint = it |
||||
} |
||||
} |
||||
this.model.secondStringValue?.let { |
||||
if (it.isNotBlank()) { |
||||
binding.editText2.hint = it |
||||
} |
||||
} |
||||
// if (this.viewModel.stringValue?.isNotBlank()) { editText.hint = values[0] } |
||||
// if (values[1].isNotBlank()) { editText2.hint = values[1] } |
||||
} else { |
||||
binding.editText.setText(this.model.stringValue) |
||||
binding.editText2.setText(this.model.secondStringValue) |
||||
} |
||||
|
||||
binding.editText.addTextChangedListener { |
||||
this.model.stringValue = it?.toString() |
||||
} |
||||
|
||||
binding.editText2.addTextChangedListener { |
||||
this.model.secondStringValue = it?.toString() |
||||
} |
||||
|
||||
binding.editText2.setOnEditorActionListener { _, actionId, _ -> |
||||
if (actionId == EditorInfo.IME_ACTION_DONE) { |
||||
this.onRowValueChanged() |
||||
// this.delegate.onRowValueChanged(values, row) |
||||
dismiss() |
||||
true |
||||
} else { |
||||
false |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,79 @@ |
||||
package net.pokeranalytics.android.ui.view.keyboard |
||||
|
||||
import android.content.Context |
||||
import android.util.AttributeSet |
||||
import android.view.LayoutInflater |
||||
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.exceptions.PAIllegalStateException |
||||
import net.pokeranalytics.android.util.BLIND_SEPARATOR |
||||
|
||||
class StakesKeyboardView : LinearLayoutCompat { |
||||
|
||||
var inputConnection: InputConnection? = null |
||||
|
||||
/** |
||||
* Constructors |
||||
*/ |
||||
constructor(context: Context) : super(context) { |
||||
// init() |
||||
} |
||||
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { |
||||
init(context, attrs) |
||||
} |
||||
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { |
||||
init(context, attrs) |
||||
} |
||||
|
||||
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_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_separator.setOnClickListener { this.commitText(BLIND_SEPARATOR) } |
||||
view.value_back.setOnClickListener { this.deleteText() } |
||||
|
||||
val layoutParams = FrameLayout.LayoutParams( |
||||
FrameLayout.LayoutParams.MATCH_PARENT, |
||||
FrameLayout.LayoutParams.WRAP_CONTENT |
||||
) |
||||
addView(view, layoutParams) |
||||
|
||||
} |
||||
|
||||
private fun commitText(string: String) { |
||||
this.inputConnection?.commitText(string, 1) ?: throw PAIllegalStateException("No input connection") |
||||
} |
||||
|
||||
private fun deleteText() { |
||||
this.inputConnection?.deleteSurroundingText(1, 0) ?: throw PAIllegalStateException("No input connection") |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,66 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
tools:background="@color/grey_darkest"> |
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout |
||||
android:id="@+id/top_container" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText |
||||
android:id="@+id/editText" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginEnd="16dp" |
||||
android:layout_marginBottom="16dp" |
||||
android:gravity="center" |
||||
android:imeOptions="actionNext" |
||||
android:lines="1" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toStartOf="@+id/editText2" |
||||
app:layout_constraintHorizontal_bias="0.5" |
||||
app:layout_constraintHorizontal_chainStyle="packed" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="10" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText |
||||
android:id="@+id/editText2" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginEnd="16dp" |
||||
android:layout_marginBottom="16dp" |
||||
android:gravity="center" |
||||
android:imeOptions="actionDone" |
||||
android:lines="1" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintHorizontal_bias="0.5" |
||||
app:layout_constraintStart_toEndOf="@+id/editText" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
app:layout_constraintVertical_bias="0.0" |
||||
tools:text="20" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
|
||||
<net.pokeranalytics.android.ui.view.keyboard.StakesKeyboardView |
||||
android:id="@+id/stakes_keyboard" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
app:layout_constraintTop_toBottomOf="@id/top_container" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintBottom_toBottomOf="parent" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
@ -0,0 +1,116 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.appcompat.widget.LinearLayoutCompat android:layout_width="match_parent" |
||||
android:layout_height="216dp" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:orientation="horizontal" |
||||
xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
|
||||
<!-- use 0dp and layout weight --> |
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical"> |
||||
|
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_1" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_marginVertical="2dp" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_4" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_marginVertical="2dp" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_7" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_marginVertical="2dp" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_decimal" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_marginVertical="2dp" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat> |
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical"> |
||||
|
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_2" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_5" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_8" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_0" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat> |
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical"> |
||||
|
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_3" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_6" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_9" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_back" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="0dp" |
||||
android:layout_weight="1" /> |
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat> |
||||
|
||||
<com.google.android.material.button.MaterialButton |
||||
android:id="@+id/value_separator" |
||||
style="@style/PokerAnalyticsTheme.Button" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"/> |
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat> |
||||
Loading…
Reference in new issue