Add confirmation dialog to end poll.

This commit is contained in:
Onuray Sahin 2021-12-03 15:11:23 +03:00
parent c62028df68
commit 0a7df44a12
4 changed files with 17 additions and 4 deletions

View file

@ -2018,11 +2018,22 @@ class RoomDetailFragment @Inject constructor(
}
}
is EventSharedAction.EndPoll -> {
roomDetailViewModel.handle(RoomDetailAction.EndPoll(action.eventId))
askConfirmationToEndPoll(action.eventId)
}
}
}
private fun askConfirmationToEndPoll(eventId: String) {
MaterialAlertDialogBuilder(requireContext(), R.style.ThemeOverlay_Vector_MaterialAlertDialog)
.setTitle(R.string.end_poll_confirmation_title)
.setMessage(R.string.end_poll_confirmation_description)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.end_poll_confirmation_approve_button) { _, _ ->
roomDetailViewModel.handle(RoomDetailAction.EndPoll(eventId))
}
.show()
}
private fun askConfirmationToIgnoreUser(senderId: String) {
MaterialAlertDialogBuilder(requireContext(), R.style.ThemeOverlay_Vector_MaterialAlertDialog_Destructive)
.setTitle(R.string.room_participants_action_ignore_title)

View file

@ -23,7 +23,6 @@ import android.text.style.AbsoluteSizeSpan
import android.text.style.ClickableSpan
import android.text.style.ForegroundColorSpan
import android.view.View
import com.airbnb.epoxy.EpoxyModel
import dagger.Lazy
import im.vector.app.R
import im.vector.app.core.epoxy.ClickListener
@ -123,7 +122,7 @@ class MessageItemFactory @Inject constructor(
pillsPostProcessorFactory.create(roomId)
}
fun create(params: TimelineItemFactoryParams): EpoxyModel<*>? {
fun create(params: TimelineItemFactoryParams): VectorEpoxyModel<*>? {
val event = params.event
val highlight = params.isHighlighted
val callback = params.callback

View file

@ -55,7 +55,7 @@ abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
val didUserVoted = pollResponseSummary?.myVote?.isNotEmpty().orFalse()
val showVotes = didUserVoted || isEnded
val totalVotes = pollResponseSummary?.votes?.map { it.value }?.sum() ?: 0
val winnerVoteCount = pollResponseSummary?.votes?.map { it.value }?.maxOrNull() ?: 0
val winnerVoteCount = pollResponseSummary?.votes?.map { it.value }?.maxOrNull() ?: -1
pollContent?.pollCreationInfo?.answers?.forEach { option ->
val isMyVote = pollResponseSummary?.myVote?.let { option.id == it }.orFalse()

View file

@ -3667,4 +3667,7 @@
</plurals>
<string name="poll_end_action">End poll</string>
<string name="a11y_poll_winner_option">winner option</string>
<string name="end_poll_confirmation_title">End poll</string>
<string name="end_poll_confirmation_description">Are you sure you want to end this poll? This will stop people from being able to vote and will display the final results of the poll.</string>
<string name="end_poll_confirmation_approve_button">End poll</string>
</resources>