initially add 2 option fields and focus question field

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-07-20 13:10:20 +02:00 committed by Andy Scherzinger (Rebase PR Action)
parent ca0c045e8d
commit ba6cc7170b
5 changed files with 22 additions and 4 deletions

View File

@ -49,7 +49,7 @@ class PollCreateOptionViewHolder(
binding.pollOptionText.setText(pollCreateOptionItem.pollOption)
if (focus) {
binding.pollOptionText.requestFocus()
itemsListener.requestFocus(binding.pollOptionText)
}
binding.pollOptionDelete.setOnClickListener {

View File

@ -20,9 +20,13 @@
package com.nextcloud.talk.polls.adapters
import android.widget.EditText
interface PollCreateOptionsItemListener {
fun onRemoveOptionsItemClick(pollCreateOptionItem: PollCreateOptionItem, position: Int)
fun onOptionsItemTextChanged(pollCreateOptionItem: PollCreateOptionItem)
fun requestFocus(textField: EditText)
}

View File

@ -29,6 +29,7 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
@ -89,6 +90,9 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
setupListeners()
setupStateObserver()
viewModel.addOption()
viewModel.addOption()
}
private fun setupListeners() {
@ -159,6 +163,14 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
viewModel.optionsItemTextChanged()
}
override fun requestFocus(textField: EditText) {
if (binding.pollCreateQuestion.text.isBlank()) {
binding.pollCreateQuestion.requestFocus()
} else {
textField.requestFocus()
}
}
/**
* Fragment creator
*/

View File

@ -113,7 +113,7 @@ class PollCreateViewModel @Inject constructor(private val repository: PollReposi
roomToken, _question, _options.value!!.map { it.pollOption }, resultMode,
maxVotes
)
?.doOnSubscribe { disposable = it }
.doOnSubscribe { disposable = it }
?.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
?.subscribe(PollObserver())

View File

@ -33,10 +33,12 @@
android:textStyle="bold"
android:text="@string/polls_question" />
<com.nextcloud.talk.utils.EmojiTextInputEditText
<EditText
android:id="@+id/poll_create_question"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:inputType="text"
tools:ignore="Autofill,LabelFor"/>
<TextView
android:layout_width="match_parent"