Set max length for poll options.

This commit is contained in:
Onuray Sahin 2021-12-07 14:43:27 +03:00
parent 71d7270da5
commit 566f6332bc
3 changed files with 20 additions and 4 deletions

View File

@ -17,6 +17,7 @@
package im.vector.app.features.form
import android.text.Editable
import android.text.InputFilter
import android.view.inputmethod.EditorInfo
import android.widget.ImageButton
import com.airbnb.epoxy.EpoxyAttribute
@ -51,6 +52,9 @@ abstract class FormEditTextWithDeleteItem : VectorEpoxyModel<FormEditTextWithDel
@EpoxyAttribute
var imeOptions: Int? = null
@EpoxyAttribute
var maxLength: Int? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var onTextChange: TextListener? = null
@ -68,6 +72,12 @@ abstract class FormEditTextWithDeleteItem : VectorEpoxyModel<FormEditTextWithDel
holder.textInputLayout.isEnabled = enabled
holder.textInputLayout.hint = hint
if (maxLength != null) {
holder.textInputEditText.filters = arrayOf(InputFilter.LengthFilter(maxLength!!))
holder.textInputLayout.counterMaxLength = maxLength!!
} else {
holder.textInputEditText.filters = arrayOf()
}
holder.textInputEditText.setTextIfDifferent(value)
holder.textInputEditText.isEnabled = enabled

View File

@ -60,7 +60,7 @@ class CreatePollController @Inject constructor(
hint(host.stringProvider.getString(R.string.create_poll_question_hint))
singleLine(true)
imeOptions(questionImeAction)
maxLength(500)
maxLength(340)
onTextChange {
host.callback?.onQuestionChanged(it)
}
@ -80,6 +80,7 @@ class CreatePollController @Inject constructor(
hint(host.stringProvider.getString(R.string.create_poll_options_hint, (index + 1)))
singleLine(true)
imeOptions(imeOptions)
maxLength(340)
onTextChange {
host.callback?.onOptionChanged(index, it)
}

View File

@ -8,10 +8,13 @@
<ImageView
android:id="@+id/optionBorderImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="64dp"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/bg_poll_option"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
@ -72,7 +75,9 @@
android:layout_marginStart="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:progressDrawable="@drawable/poll_option_progressbar_checked"
app:layout_constraintBottom_toBottomOf="@id/optionBorderImageView"
app:layout_constraintEnd_toStartOf="@id/optionVoteCountTextView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/optionNameTextView"