mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 14:54:09 +01:00
initially add 2 option fields and focus question field
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
ca0c045e8d
commit
ba6cc7170b
@ -49,7 +49,7 @@ class PollCreateOptionViewHolder(
|
|||||||
binding.pollOptionText.setText(pollCreateOptionItem.pollOption)
|
binding.pollOptionText.setText(pollCreateOptionItem.pollOption)
|
||||||
|
|
||||||
if (focus) {
|
if (focus) {
|
||||||
binding.pollOptionText.requestFocus()
|
itemsListener.requestFocus(binding.pollOptionText)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.pollOptionDelete.setOnClickListener {
|
binding.pollOptionDelete.setOnClickListener {
|
||||||
|
@ -20,9 +20,13 @@
|
|||||||
|
|
||||||
package com.nextcloud.talk.polls.adapters
|
package com.nextcloud.talk.polls.adapters
|
||||||
|
|
||||||
|
import android.widget.EditText
|
||||||
|
|
||||||
interface PollCreateOptionsItemListener {
|
interface PollCreateOptionsItemListener {
|
||||||
|
|
||||||
fun onRemoveOptionsItemClick(pollCreateOptionItem: PollCreateOptionItem, position: Int)
|
fun onRemoveOptionsItemClick(pollCreateOptionItem: PollCreateOptionItem, position: Int)
|
||||||
|
|
||||||
fun onOptionsItemTextChanged(pollCreateOptionItem: PollCreateOptionItem)
|
fun onOptionsItemTextChanged(pollCreateOptionItem: PollCreateOptionItem)
|
||||||
|
|
||||||
|
fun requestFocus(textField: EditText)
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import android.util.Log
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.EditText
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
@ -89,6 +90,9 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
|
|||||||
|
|
||||||
setupListeners()
|
setupListeners()
|
||||||
setupStateObserver()
|
setupStateObserver()
|
||||||
|
|
||||||
|
viewModel.addOption()
|
||||||
|
viewModel.addOption()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListeners() {
|
private fun setupListeners() {
|
||||||
@ -159,6 +163,14 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
|
|||||||
viewModel.optionsItemTextChanged()
|
viewModel.optionsItemTextChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun requestFocus(textField: EditText) {
|
||||||
|
if (binding.pollCreateQuestion.text.isBlank()) {
|
||||||
|
binding.pollCreateQuestion.requestFocus()
|
||||||
|
} else {
|
||||||
|
textField.requestFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment creator
|
* Fragment creator
|
||||||
*/
|
*/
|
||||||
|
@ -113,7 +113,7 @@ class PollCreateViewModel @Inject constructor(private val repository: PollReposi
|
|||||||
roomToken, _question, _options.value!!.map { it.pollOption }, resultMode,
|
roomToken, _question, _options.value!!.map { it.pollOption }, resultMode,
|
||||||
maxVotes
|
maxVotes
|
||||||
)
|
)
|
||||||
?.doOnSubscribe { disposable = it }
|
.doOnSubscribe { disposable = it }
|
||||||
?.subscribeOn(Schedulers.io())
|
?.subscribeOn(Schedulers.io())
|
||||||
?.observeOn(AndroidSchedulers.mainThread())
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
?.subscribe(PollObserver())
|
?.subscribe(PollObserver())
|
||||||
|
@ -33,10 +33,12 @@
|
|||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:text="@string/polls_question" />
|
android:text="@string/polls_question" />
|
||||||
|
|
||||||
<com.nextcloud.talk.utils.EmojiTextInputEditText
|
<EditText
|
||||||
android:id="@+id/poll_create_question"
|
android:id="@+id/poll_create_question"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="text"
|
||||||
|
tools:ignore="Autofill,LabelFor"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user