Modificado customDialog para modificar inputText dinámicamente

This commit is contained in:
Sergio De la torre 2023-07-05 13:12:57 +02:00
parent ad4910948d
commit ea63ddc24d
7 changed files with 30 additions and 27 deletions

View File

@ -7,13 +7,12 @@ import android.view.View
import com.google.android.material.textfield.TextInputEditText
import es.verdnatura.R
import es.verdnatura.databinding.ComponentCustomEditDialogBinding
import es.verdnatura.presentation.common.showKeyboard
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
class CustomDialogInput (context: Context) : Dialog(context, R.style.DialogTheme) {
class CustomDialogInput(context: Context) : Dialog(context, R.style.DialogTheme) {
private var binding: ComponentCustomEditDialogBinding = ComponentCustomEditDialogBinding.inflate(layoutInflater)
private var binding: ComponentCustomEditDialogBinding =
ComponentCustomEditDialogBinding.inflate(layoutInflater)
init {
@ -22,23 +21,23 @@ class CustomDialogInput (context: Context) : Dialog(context, R.style.DialogTheme
//setContentView(R.layout.component_custom_edit_dialog)
}
fun getEditText() : TextInputEditText {
fun getEditText(): TextInputEditText {
return binding.customDialogValue
//return custom_dialog_value
}
fun getValue() : String {
fun getValue(): String {
return binding.customDialogValue.text.toString()
//return custom_dialog_value.text.toString()
}
fun setValue(value : String): CustomDialogInput{
fun setValue(value: String): CustomDialogInput {
binding.customDialogValue.setText(value)
binding.customDialogValue.visibility= View.VISIBLE
binding.customDialogValue.visibility = View.VISIBLE
// custom_dialog_value.setText(value)
// custom_dialog_value.visibility = View.VISIBLE
@ -47,8 +46,8 @@ class CustomDialogInput (context: Context) : Dialog(context, R.style.DialogTheme
fun setTitle(title: String): CustomDialogInput {
binding.customDialogTitle.visibility=View.VISIBLE
binding.customDialogTitle.text=title
binding.customDialogTitle.visibility = View.VISIBLE
binding.customDialogTitle.text = title
// custom_dialog_title.visibility = View.VISIBLE
// custom_dialog_title.text = title
return this
@ -67,19 +66,19 @@ class CustomDialogInput (context: Context) : Dialog(context, R.style.DialogTheme
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogInput {
binding.customDialogButtonOk.visibility = View.VISIBLE
binding.customDialogButtonOk.text =text
binding.customDialogButtonOk.text = text
binding.customDialogButtonOk.setOnClickListener { onButtonClicked() }
/* custom_dialog_button_ok.visibility = View.VISIBLE
custom_dialog_button_ok.text = text
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }*/
/* custom_dialog_button_ok.visibility = View.VISIBLE
custom_dialog_button_ok.text = text
custom_dialog_button_ok.setOnClickListener { onButtonClicked() }*/
return this
}
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogInput {
binding.customDialogButtonKo.visibility = View.VISIBLE
binding.customDialogButtonKo.text =text
binding.customDialogButtonKo.text = text
binding.customDialogButtonKo.setOnClickListener { onButtonClicked() }
/*custom_dialog_button_ko.visibility = View.VISIBLE
@ -89,10 +88,11 @@ class CustomDialogInput (context: Context) : Dialog(context, R.style.DialogTheme
return this
}
fun setInputText(){
binding.customDialogValue.inputType= InputType.TYPE_CLASS_NUMBER
fun setInputText(typeClassNumber: Int = InputType.TYPE_CLASS_NUMBER) {
binding.customDialogValue.inputType = typeClassNumber
}
fun setFocusText(){
fun setFocusText() {
binding.customDialogValue.requestFocus()
}
}

View File

@ -2291,7 +2291,7 @@ class CollectionFragment(
showKeyboards()
}.setValue("").show()
customDialogInput.setInputText()
customDialogInput.setInputText(TYPE_CLASS_NUMBER)
// customDialogInput.currentFocus
customDialogInput.setFocusText()
showKeyboards()
@ -2351,7 +2351,7 @@ class CollectionFragment(
showKeyboards()
}.setValue("").show()
customDialogInput.setInputText()
customDialogInput.setInputText(TYPE_CLASS_NUMBER)
customDialogInput.currentFocus
customDialogInput.setFocusText()
showKeyboards()

View File

@ -2390,7 +2390,7 @@ import org.json.JSONObject
showKeyboards()
}.setValue("").show()
customDialogInput.setInputText()
customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER)
// customDialogInput.currentFocus
customDialogInput.setFocusText()
showKeyboards()
@ -2450,7 +2450,7 @@ import org.json.JSONObject
showKeyboards()
}.setValue("").show()
customDialogInput.setInputText()
customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER)
customDialogInput.currentFocus
customDialogInput.setFocusText()
showKeyboards()

View File

@ -2365,7 +2365,7 @@ class CollectionFragmentPreChecker(
showKeyboards()
}.setValue("").show()
customDialogInput.setInputText()
customDialogInput.setInputText(TYPE_CLASS_NUMBER)
// customDialogInput.currentFocus
customDialogInput.setFocusText()
showKeyboards()
@ -2425,7 +2425,7 @@ class CollectionFragmentPreChecker(
showKeyboards()
}.setValue("").show()
customDialogInput.setInputText()
customDialogInput.setInputText(TYPE_CLASS_NUMBER)
customDialogInput.currentFocus
customDialogInput.setFocusText()
showKeyboards()

View File

@ -1,5 +1,6 @@
package es.verdnatura.presentation.view.feature.packingHolland.fragment
import android.text.InputType
import android.view.View.*
import android.view.inputmethod.EditorInfo
import es.verdnatura.R
@ -84,7 +85,7 @@ class PackingHollandFragment(var entrypoint: String) :
private fun showQuantityPacking() {
customDialogInput.setInputText()
customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER)
customDialogInput.setTitle(getString(R.string.titlePackingHolland))
customDialogInput.setDescription(getString(R.string.packingQuantity) + shelvingScaned)
.setValue("")

View File

@ -3,6 +3,7 @@ package es.verdnatura.presentation.view.feature.presacador.fragment
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Build
import android.text.InputType
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.ImageView
@ -127,7 +128,7 @@ class InitPreSacadorFragment(
private fun showPrintPrevious() {
customDialogInput.setInputText()
customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER)
customDialogInput.setTitle(getString(R.string.printTicket))
customDialogInput.setDescription(getString(R.string.printPreviousGroup))
.setValue("")

View File

@ -3,6 +3,7 @@ package es.verdnatura.presentation.view.feature.sacador.fragment
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Build
import android.text.InputType
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.ImageView
@ -139,7 +140,7 @@ class SacadorFragment(
private fun showPrintPrevious() {
customDialogInput.setInputText()
customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER)
customDialogInput.setTitle(getString(R.string.printTicket))
customDialogInput.setDescription(getString(R.string.printPreviousGroup))
.setValue("")