Skip to content

Commit

Permalink
FIX: LabelInputElement is only one line
Browse files Browse the repository at this point in the history
  • Loading branch information
balakz committed Aug 27, 2021
1 parent f69b8ee commit e9bb2f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class MainActivity : AppCompatActivity() {

private lateinit var form: Form

private lateinit var toast: Toast


private val charPool: List<Char> = ('a'..'z') + ('A'..'Z')
private val INPUTS_ID = "INPUTS_ID"
private val stringValues = arrayOf(
Expand All @@ -64,58 +67,52 @@ class MainActivity : AppCompatActivity() {

private val validateActionCallback = object : ActionCallback, Form.Callback {
override fun successCallback() {
Toast.makeText(this@MainActivity, "Validate OK", Toast.LENGTH_SHORT).show()
showMessage("Validate OK")
}

override fun errorCallback(message: String?) {
Toast.makeText(this@MainActivity, "Validate not ok $message", Toast.LENGTH_SHORT).show()
showMessage("Validate not ok $message")
}

override fun callback() {
form.sendForm(this)
}
}

private fun showMessage(message: String) {
toast.setText(message)
toast.show()
}

private val showToastActionCallback = object : ActionCallback {
override fun callback() {
Toast.makeText(this@MainActivity, "Action performed", Toast.LENGTH_SHORT).show()
showMessage("Action performed")
}
}

private val showToastCheckboxCallback = object : CheckboxCallback {
private var toast: Toast? = null
override fun callback(checked: Boolean) {
toast?.cancel()
toast = Toast.makeText(this@MainActivity, "Selected: $checked", Toast.LENGTH_SHORT)
toast?.show()
showMessage("Selected: $checked")
}
}

private val showToastStringValueCallback = object : ValueCallback<String> {
private var toast: Toast? = null
override fun callback(value: String) {
toast?.cancel()
toast = Toast.makeText(this@MainActivity, value, Toast.LENGTH_SHORT)
toast?.show()
showMessage(value)
}
}
private val showToastDateTimeValueCallback = object : ValueCallback<Date> {
private var toast: Toast? = null
override fun callback(value: Date) {
toast?.cancel()
toast = Toast.makeText(
this@MainActivity,
SimpleDateFormat("dd.MM.yyyy - HH:mm", Locale.getDefault()).format(value),
Toast.LENGTH_SHORT
)
toast?.show()
showMessage(SimpleDateFormat("dd.MM.yyyy - HH:mm", Locale.getDefault()).format(value))

}
}


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
toast = Toast.makeText(this, "Toast", Toast.LENGTH_SHORT)
form = buildForm()
form.draw()
//how to get inout data??
Expand Down Expand Up @@ -217,7 +214,7 @@ class MainActivity : AppCompatActivity() {
"Edit text element text",
valueChangeListener = object : ValueCallback<String> {
override fun callback(value: String) {
Toast.makeText(applicationContext, value, Toast.LENGTH_SHORT).show()
showMessage(value)
}
},
password = false,
Expand All @@ -232,7 +229,7 @@ class MainActivity : AppCompatActivity() {
fewStringValues,
valueCallback = object : ValueCallback<String> {
override fun callback(value: String) {
Toast.makeText(applicationContext, value, Toast.LENGTH_SHORT).show()
showMessage(value)
}
}
), true,
Expand All @@ -250,7 +247,7 @@ class MainActivity : AppCompatActivity() {
"Edit text element text",
valueChangeListener = object : ValueCallback<String> {
override fun callback(value: String) {
Toast.makeText(applicationContext, value, Toast.LENGTH_SHORT).show()
showMessage(value)
}
},
password = false,
Expand All @@ -262,15 +259,15 @@ class MainActivity : AppCompatActivity() {
"Password", "password",
valueChangeListener = object : ValueCallback<String> {
override fun callback(value: String) {
Toast.makeText(applicationContext, value, Toast.LENGTH_SHORT).show()
showMessage(value)
}
}, password = true, formValidators = arrayListOf(notEmptyValidator)
), true
)

addElement(LabelInputElement("Email", "[email protected]", "", object : ValueCallback<String> {
override fun callback(value: String) {
Toast.makeText(applicationContext, value, Toast.LENGTH_SHORT).show()
showMessage(value)
}
}, arrayListOf(emailValidator)), true)
addElement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cz.qase.android.formbuilderlibrary.element

import android.content.Context
import android.text.Editable
import android.text.InputType
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -77,6 +78,8 @@ class LabelInputElement(
textInputLayout.addView(textInputEditText)
textInputEditText?.setTextColorResourceId(context, formStyleBundle.secondaryTextColor)
textInputEditText?.setText(value)
textInputEditText?.maxLines = 1
textInputEditText?.inputType = InputType.TYPE_CLASS_TEXT
textInputEditText?.addTextChangedListener(
object : TextWatcher {
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
Expand Down

0 comments on commit e9bb2f7

Please sign in to comment.