mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-28 09:38:14 +03:00
add dismiss button for edit votes mode
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
2ac1567f5d
commit
6b8c83f553
4 changed files with 33 additions and 4 deletions
|
@ -125,7 +125,7 @@ data class ChatMessage(
|
|||
var voiceMessageDownloadProgress: Int = 0,
|
||||
) : Parcelable, MessageContentType, MessageContentType.Image {
|
||||
|
||||
// TODO: messageTypesToIgnore is weird. must be deleted by refactoring!
|
||||
// messageTypesToIgnore is weird. must be deleted by refactoring!!!
|
||||
@JsonIgnore
|
||||
var messageTypesToIgnore = Arrays.asList(
|
||||
MessageType.REGULAR_TEXT_MESSAGE,
|
||||
|
|
|
@ -89,6 +89,7 @@ class PollVoteFragment : Fragment() {
|
|||
initPollOptions(state.poll)
|
||||
initEndPollButton(state.showEndPollButton)
|
||||
updateSubmitButton()
|
||||
updateDismissEditButton(state.showDismissEditButton)
|
||||
} else if (state is PollMainViewModel.PollVoteHiddenState) {
|
||||
initPollOptions(state.poll)
|
||||
initEndPollButton(state.showEndPollButton)
|
||||
|
@ -117,6 +118,18 @@ class PollVoteFragment : Fragment() {
|
|||
binding.pollVoteSubmitButton.setOnClickListener {
|
||||
viewModel.vote(roomToken, pollId)
|
||||
}
|
||||
|
||||
binding.pollVoteEditDismiss.setOnClickListener {
|
||||
parentViewModel.dismissEditVotes()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateDismissEditButton(showDismissEditButton: Boolean) {
|
||||
if (showDismissEditButton) {
|
||||
binding.pollVoteEditDismiss.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.pollVoteEditDismiss.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun initPollOptions(poll: Poll) {
|
||||
|
|
|
@ -61,7 +61,8 @@ class PollMainViewModel @Inject constructor(private val repository: PollReposito
|
|||
open class PollVoteState(
|
||||
val poll: Poll,
|
||||
val showVotersAmount: Boolean,
|
||||
val showEndPollButton: Boolean
|
||||
val showEndPollButton: Boolean,
|
||||
val showDismissEditButton: Boolean
|
||||
) : ViewState
|
||||
|
||||
open class PollVoteHiddenState(
|
||||
|
@ -99,6 +100,10 @@ class PollMainViewModel @Inject constructor(private val repository: PollReposito
|
|||
loadPoll()
|
||||
}
|
||||
|
||||
fun dismissEditVotes() {
|
||||
loadPoll()
|
||||
}
|
||||
|
||||
private fun loadPoll() {
|
||||
repository.getPoll(roomToken, pollId)
|
||||
?.doOnSubscribe { disposable = it }
|
||||
|
@ -141,13 +146,13 @@ class PollMainViewModel @Inject constructor(private val repository: PollReposito
|
|||
if (votedForOpenHiddenPoll(poll)) {
|
||||
_viewState.value = PollVoteHiddenState(poll, showVotersAmount, showEndPollButton)
|
||||
} else if (editVotes && poll.status == Poll.STATUS_OPEN) {
|
||||
_viewState.value = PollVoteState(poll, false, showEndPollButton)
|
||||
_viewState.value = PollVoteState(poll, false, showEndPollButton, true)
|
||||
editVotes = false
|
||||
} else if (poll.status == Poll.STATUS_CLOSED || poll.votedSelf?.isNotEmpty() == true) {
|
||||
val showEditButton = poll.status == Poll.STATUS_OPEN && poll.resultMode == Poll.RESULT_MODE_PUBLIC
|
||||
_viewState.value = PollResultState(poll, showVotersAmount, showEndPollButton, showEditButton)
|
||||
} else if (poll.votedSelf.isNullOrEmpty()) {
|
||||
_viewState.value = PollVoteState(poll, showVotersAmount, showEndPollButton)
|
||||
_viewState.value = PollVoteState(poll, showVotersAmount, showEndPollButton, false)
|
||||
} else {
|
||||
Log.w(TAG, "unknown poll state")
|
||||
}
|
||||
|
|
|
@ -66,6 +66,17 @@
|
|||
android:layout_marginEnd="@dimen/standard_margin"
|
||||
app:cornerRadius="@dimen/button_corner_radius" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/poll_vote_edit_dismiss"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/nc_common_dismiss"
|
||||
style="@style/OutlinedButton"
|
||||
android:layout_marginEnd="@dimen/standard_margin"
|
||||
android:visibility="gone"
|
||||
app:cornerRadius="@dimen/button_corner_radius"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/poll_vote_submit_button"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Loading…
Reference in a new issue