Handle even more instance defaults (#2612)
* handle media size instance limits * remove unused attributes from Instance entity * support max_media_attachments * support pleroma field limits, remove max_bio_chars support * improve field input margin * fix tests * MAX_ACCOUNT_FIELDS -> DEFAULT_MAX_ACCOUNT_FIELDS * improve "add field" button behavior * fix copy paste mistake in AccountFieldEditAdapter * refactor sendStatus to be a suspending function
This commit is contained in:
parent
25f637f0a8
commit
1b6a0908f6
16 changed files with 1219 additions and 308 deletions
|
|
@ -27,6 +27,8 @@ import com.keylesspalace.tusky.util.BindingHolder
|
|||
class AccountFieldEditAdapter : RecyclerView.Adapter<BindingHolder<ItemEditFieldBinding>>() {
|
||||
|
||||
private val fieldData = mutableListOf<MutableStringPair>()
|
||||
private var maxNameLength: Int? = null
|
||||
private var maxValueLength: Int? = null
|
||||
|
||||
fun setFields(fields: List<StringField>) {
|
||||
fieldData.clear()
|
||||
|
|
@ -41,6 +43,12 @@ class AccountFieldEditAdapter : RecyclerView.Adapter<BindingHolder<ItemEditField
|
|||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun setFieldLimits(maxNameLength: Int?, maxValueLength: Int?) {
|
||||
this.maxNameLength = maxNameLength
|
||||
this.maxValueLength = maxValueLength
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun getFieldData(): List<StringField> {
|
||||
return fieldData.map {
|
||||
StringField(it.first, it.second)
|
||||
|
|
@ -60,10 +68,20 @@ class AccountFieldEditAdapter : RecyclerView.Adapter<BindingHolder<ItemEditField
|
|||
}
|
||||
|
||||
override fun onBindViewHolder(holder: BindingHolder<ItemEditFieldBinding>, position: Int) {
|
||||
holder.binding.accountFieldName.setText(fieldData[position].first)
|
||||
holder.binding.accountFieldValue.setText(fieldData[position].second)
|
||||
holder.binding.accountFieldNameText.setText(fieldData[position].first)
|
||||
holder.binding.accountFieldValueText.setText(fieldData[position].second)
|
||||
|
||||
holder.binding.accountFieldName.addTextChangedListener(object : TextWatcher {
|
||||
holder.binding.accountFieldNameTextLayout.isCounterEnabled = maxNameLength != null
|
||||
maxNameLength?.let {
|
||||
holder.binding.accountFieldNameTextLayout.counterMaxLength = it
|
||||
}
|
||||
|
||||
holder.binding.accountFieldValueTextLayout.isCounterEnabled = maxValueLength != null
|
||||
maxValueLength?.let {
|
||||
holder.binding.accountFieldValueTextLayout.counterMaxLength = it
|
||||
}
|
||||
|
||||
holder.binding.accountFieldNameText.addTextChangedListener(object : TextWatcher {
|
||||
override fun afterTextChanged(newText: Editable) {
|
||||
fieldData[holder.bindingAdapterPosition].first = newText.toString()
|
||||
}
|
||||
|
|
@ -73,7 +91,7 @@ class AccountFieldEditAdapter : RecyclerView.Adapter<BindingHolder<ItemEditField
|
|||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
||||
})
|
||||
|
||||
holder.binding.accountFieldValue.addTextChangedListener(object : TextWatcher {
|
||||
holder.binding.accountFieldValueText.addTextChangedListener(object : TextWatcher {
|
||||
override fun afterTextChanged(newText: Editable) {
|
||||
fieldData[holder.bindingAdapterPosition].second = newText.toString()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue