Set max length for poll options.
This commit is contained in:
parent
71d7270da5
commit
566f6332bc
@ -17,6 +17,7 @@
|
|||||||
package im.vector.app.features.form
|
package im.vector.app.features.form
|
||||||
|
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
|
import android.text.InputFilter
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import com.airbnb.epoxy.EpoxyAttribute
|
import com.airbnb.epoxy.EpoxyAttribute
|
||||||
@ -51,6 +52,9 @@ abstract class FormEditTextWithDeleteItem : VectorEpoxyModel<FormEditTextWithDel
|
|||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var imeOptions: Int? = null
|
var imeOptions: Int? = null
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var maxLength: Int? = null
|
||||||
|
|
||||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||||
var onTextChange: TextListener? = null
|
var onTextChange: TextListener? = null
|
||||||
|
|
||||||
@ -68,6 +72,12 @@ abstract class FormEditTextWithDeleteItem : VectorEpoxyModel<FormEditTextWithDel
|
|||||||
holder.textInputLayout.isEnabled = enabled
|
holder.textInputLayout.isEnabled = enabled
|
||||||
holder.textInputLayout.hint = hint
|
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.setTextIfDifferent(value)
|
||||||
|
|
||||||
holder.textInputEditText.isEnabled = enabled
|
holder.textInputEditText.isEnabled = enabled
|
||||||
|
@ -60,7 +60,7 @@ class CreatePollController @Inject constructor(
|
|||||||
hint(host.stringProvider.getString(R.string.create_poll_question_hint))
|
hint(host.stringProvider.getString(R.string.create_poll_question_hint))
|
||||||
singleLine(true)
|
singleLine(true)
|
||||||
imeOptions(questionImeAction)
|
imeOptions(questionImeAction)
|
||||||
maxLength(500)
|
maxLength(340)
|
||||||
onTextChange {
|
onTextChange {
|
||||||
host.callback?.onQuestionChanged(it)
|
host.callback?.onQuestionChanged(it)
|
||||||
}
|
}
|
||||||
@ -80,6 +80,7 @@ class CreatePollController @Inject constructor(
|
|||||||
hint(host.stringProvider.getString(R.string.create_poll_options_hint, (index + 1)))
|
hint(host.stringProvider.getString(R.string.create_poll_options_hint, (index + 1)))
|
||||||
singleLine(true)
|
singleLine(true)
|
||||||
imeOptions(imeOptions)
|
imeOptions(imeOptions)
|
||||||
|
maxLength(340)
|
||||||
onTextChange {
|
onTextChange {
|
||||||
host.callback?.onOptionChanged(index, it)
|
host.callback?.onOptionChanged(index, it)
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,13 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/optionBorderImageView"
|
android:id="@+id/optionBorderImageView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="0dp"
|
||||||
android:minHeight="64dp"
|
|
||||||
android:src="@drawable/bg_poll_option"
|
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" />
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -72,7 +75,9 @@
|
|||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
android:progressDrawable="@drawable/poll_option_progressbar_checked"
|
android:progressDrawable="@drawable/poll_option_progressbar_checked"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/optionBorderImageView"
|
||||||
app:layout_constraintEnd_toStartOf="@id/optionVoteCountTextView"
|
app:layout_constraintEnd_toStartOf="@id/optionVoteCountTextView"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/optionNameTextView"
|
app:layout_constraintTop_toBottomOf="@id/optionNameTextView"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user