diff --git a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt index c47293fd6..1d68ce625 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt @@ -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, diff --git a/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt b/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt index c26290720..c8adb9448 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt @@ -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) { diff --git a/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollMainViewModel.kt b/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollMainViewModel.kt index 44c2c8ffe..2cca1ac87 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollMainViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollMainViewModel.kt @@ -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") } diff --git a/app/src/main/res/layout/dialog_poll_vote.xml b/app/src/main/res/layout/dialog_poll_vote.xml index 1ab4c2c9a..b3cc0ddb4 100644 --- a/app/src/main/res/layout/dialog_poll_vote.xml +++ b/app/src/main/res/layout/dialog_poll_vote.xml @@ -66,6 +66,17 @@ android:layout_marginEnd="@dimen/standard_margin" app:cornerRadius="@dimen/button_corner_radius" /> + +