diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/RoomPollItem.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/RoomPollItem.kt index fd4e36159e..da00fedddb 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/RoomPollItem.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/RoomPollItem.kt @@ -18,6 +18,7 @@ package im.vector.app.features.roomprofile.polls.list import android.widget.LinearLayout import android.widget.TextView +import androidx.core.view.isVisible import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass import im.vector.app.R @@ -25,6 +26,7 @@ import im.vector.app.core.epoxy.ClickListener import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel import im.vector.app.core.epoxy.onClick +import im.vector.app.core.extensions.setTextOrHide import im.vector.app.features.home.room.detail.timeline.item.PollOptionView import im.vector.app.features.home.room.detail.timeline.item.PollOptionViewState @@ -40,6 +42,9 @@ abstract class RoomPollItem : VectorEpoxyModel(R.layout.ite @EpoxyAttribute var winnerOptions: List = emptyList() + @EpoxyAttribute + var totalVotesStatus: String? = null + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var clickListener: ClickListener? = null @@ -49,16 +54,19 @@ abstract class RoomPollItem : VectorEpoxyModel(R.layout.ite holder.date.text = formattedDate holder.title.text = title holder.winnerOptions.removeAllViews() + holder.winnerOptions.isVisible = winnerOptions.isNotEmpty() for (winnerOption in winnerOptions) { val optionView = PollOptionView(holder.view.context) holder.winnerOptions.addView(optionView) optionView.render(winnerOption) } + holder.totalVotes.setTextOrHide(totalVotesStatus) } class Holder : VectorEpoxyHolder() { val date by bind(R.id.pollDate) val title by bind(R.id.pollTitle) val winnerOptions by bind(R.id.pollWinnerOptionsContainer) + val totalVotes by bind(R.id.pollTotalVotes) } } diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/RoomPollsController.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/RoomPollsController.kt index c6288aac8b..f0e3b6b9a4 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/RoomPollsController.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/RoomPollsController.kt @@ -17,13 +17,16 @@ package im.vector.app.features.roomprofile.polls.list import com.airbnb.epoxy.TypedEpoxyController +import im.vector.app.R import im.vector.app.core.date.DateFormatKind import im.vector.app.core.date.VectorDateFormatter +import im.vector.app.core.resources.StringProvider import im.vector.app.features.roomprofile.polls.PollSummary import javax.inject.Inject class RoomPollsController @Inject constructor( val dateFormatter: VectorDateFormatter, + val stringProvider: StringProvider, ) : TypedEpoxyController>() { interface Listener { @@ -64,6 +67,7 @@ class RoomPollsController @Inject constructor( formattedDate(host.dateFormatter.format(poll.creationTimestamp, DateFormatKind.TIMELINE_DAY_DIVIDER)) title(poll.title) winnerOptions(poll.winnerOptions) + totalVotesStatus(host.stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, poll.totalVotes, poll.totalVotes)) clickListener { host.listener?.onPollClicked(poll.id) } diff --git a/vector/src/main/res/layout/item_poll.xml b/vector/src/main/res/layout/item_poll.xml index 9563f3d52a..17f3b5abf5 100644 --- a/vector/src/main/res/layout/item_poll.xml +++ b/vector/src/main/res/layout/item_poll.xml @@ -54,4 +54,16 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/pollTitle" /> + +