From 9fb19af39c7f6d6f083b37d5d4a43433efc39d58 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 30 Jun 2022 09:58:00 +0200 Subject: [PATCH 1/3] Adding a description under undisclosed poll when not yet ended --- .../room/detail/timeline/factory/PollItemViewStateFactory.kt | 2 +- vector/src/main/res/values/strings.xml | 1 + .../detail/timeline/factory/PollItemViewStateFactoryTest.kt | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactory.kt index 8da0f2d279..1d8bae6d5c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactory.kt @@ -107,7 +107,7 @@ class PollItemViewStateFactory @Inject constructor( ): PollViewState { return PollViewState( question = question, - totalVotes = "", + totalVotes = stringProvider.getString(R.string.poll_undisclosed_not_ended), canVote = true, optionViewStates = pollCreationInfo?.answers?.map { answer -> val isMyVote = pollResponseSummary?.myVote == answer.id diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index dc5ea0fa8c..0c067a175f 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -2980,6 +2980,7 @@ Based on %1$d votes No votes cast + Results will be visible when the poll is ended %1$d vote cast. Vote to the see the results %1$d votes cast. Vote to the see the results diff --git a/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt b/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt index 64ad03a019..4af33657f5 100644 --- a/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt +++ b/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt @@ -143,7 +143,7 @@ class PollItemViewStateFactoryTest { pollViewState shouldBeEqualTo PollViewState( question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "", - totalVotes = "", + totalVotes = stringProvider.instance.getString(R.string.poll_undisclosed_not_ended), canVote = true, optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer -> PollOptionViewState.PollUndisclosed( From 55bb6fa21a7c1041b5882bfc17331a79966981c4 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 30 Jun 2022 10:13:17 +0200 Subject: [PATCH 2/3] Adding changelog entry --- changelog.d/6423.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6423.misc diff --git a/changelog.d/6423.misc b/changelog.d/6423.misc new file mode 100644 index 0000000000..26c1e84830 --- /dev/null +++ b/changelog.d/6423.misc @@ -0,0 +1 @@ +[Poll] - Add a description under undisclosed poll when not ended From 26aaf8480601a663a2c6ff01a8065fcd9d79bcbb Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 4 Jul 2022 10:14:15 +0200 Subject: [PATCH 3/3] Renaming field to votesStatus --- .../room/detail/timeline/factory/MessageItemFactory.kt | 2 +- .../timeline/factory/PollItemViewStateFactory.kt | 10 +++++----- .../home/room/detail/timeline/item/PollItem.kt | 6 +++--- .../java/im/vector/app/features/poll/PollViewState.kt | 8 ++++---- .../src/main/res/layout/item_timeline_event_poll.xml | 4 ++-- .../timeline/factory/PollItemViewStateFactoryTest.kt | 10 +++++----- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt index 853fef8bc8..28e256c064 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -244,7 +244,7 @@ class MessageItemFactory @Inject constructor( .eventId(informationData.eventId) .pollQuestion(createPollQuestion(informationData, pollViewState.question, callback)) .canVote(pollViewState.canVote) - .totalVotesText(pollViewState.totalVotes) + .votesStatus(pollViewState.votesStatus) .optionViewStates(pollViewState.optionViewStates) .edited(informationData.hasBeenEdited) .highlighted(highlight) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactory.kt index 1d8bae6d5c..13f63e86c4 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactory.kt @@ -65,7 +65,7 @@ class PollItemViewStateFactory @Inject constructor( private fun createSendingPollViewState(question: String, pollCreationInfo: PollCreationInfo?): PollViewState { return PollViewState( question = question, - totalVotes = stringProvider.getString(R.string.poll_no_votes_cast), + votesStatus = stringProvider.getString(R.string.poll_no_votes_cast), canVote = false, optionViewStates = pollCreationInfo?.answers?.map { answer -> PollOptionViewState.PollSending( @@ -85,7 +85,7 @@ class PollItemViewStateFactory @Inject constructor( ): PollViewState { return PollViewState( question = question, - totalVotes = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, totalVotes, totalVotes), + votesStatus = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, totalVotes, totalVotes), canVote = false, optionViewStates = pollCreationInfo?.answers?.map { answer -> val voteSummary = pollResponseSummary?.getVoteSummaryOfAnOption(answer.id ?: "") @@ -107,7 +107,7 @@ class PollItemViewStateFactory @Inject constructor( ): PollViewState { return PollViewState( question = question, - totalVotes = stringProvider.getString(R.string.poll_undisclosed_not_ended), + votesStatus = stringProvider.getString(R.string.poll_undisclosed_not_ended), canVote = true, optionViewStates = pollCreationInfo?.answers?.map { answer -> val isMyVote = pollResponseSummary?.myVote == answer.id @@ -128,7 +128,7 @@ class PollItemViewStateFactory @Inject constructor( ): PollViewState { return PollViewState( question = question, - totalVotes = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, totalVotes, totalVotes), + votesStatus = stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, totalVotes, totalVotes), canVote = true, optionViewStates = pollCreationInfo?.answers?.map { answer -> val isMyVote = pollResponseSummary?.myVote == answer.id @@ -152,7 +152,7 @@ class PollItemViewStateFactory @Inject constructor( } return PollViewState( question = question, - totalVotes = totalVotesText, + votesStatus = totalVotesText, canVote = true, optionViewStates = pollCreationInfo?.answers?.map { answer -> PollOptionViewState.PollReady( diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollItem.kt index 273dd0299a..85f10f1cc1 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollItem.kt @@ -42,7 +42,7 @@ abstract class PollItem : AbsMessageItem() { var canVote: Boolean = false @EpoxyAttribute - var totalVotesText: String? = null + var votesStatus: String? = null @EpoxyAttribute var edited: Boolean = false @@ -58,7 +58,7 @@ abstract class PollItem : AbsMessageItem() { renderSendState(holder.view, holder.questionTextView) holder.questionTextView.text = pollQuestion?.charSequence - holder.totalVotesTextView.text = totalVotesText + holder.votesStatusTextView.text = votesStatus while (holder.optionsContainer.childCount < optionViewStates.size) { holder.optionsContainer.addView(PollOptionView(holder.view.context)) @@ -88,7 +88,7 @@ abstract class PollItem : AbsMessageItem() { class Holder : AbsMessageItem.Holder(STUB_ID) { val questionTextView by bind(R.id.questionTextView) val optionsContainer by bind(R.id.optionsContainer) - val totalVotesTextView by bind(R.id.optionsTotalVotesTextView) + val votesStatusTextView by bind(R.id.optionsVotesStatusTextView) } companion object { diff --git a/vector/src/main/java/im/vector/app/features/poll/PollViewState.kt b/vector/src/main/java/im/vector/app/features/poll/PollViewState.kt index 0f01d58c96..ecbee7438a 100644 --- a/vector/src/main/java/im/vector/app/features/poll/PollViewState.kt +++ b/vector/src/main/java/im/vector/app/features/poll/PollViewState.kt @@ -19,8 +19,8 @@ package im.vector.app.features.poll import im.vector.app.features.home.room.detail.timeline.item.PollOptionViewState data class PollViewState( - val question: String, - val totalVotes: String, - val canVote: Boolean, - val optionViewStates: List?, + val question: String, + val votesStatus: String, + val canVote: Boolean, + val optionViewStates: List?, ) diff --git a/vector/src/main/res/layout/item_timeline_event_poll.xml b/vector/src/main/res/layout/item_timeline_event_poll.xml index 64444e2c69..393b736260 100644 --- a/vector/src/main/res/layout/item_timeline_event_poll.xml +++ b/vector/src/main/res/layout/item_timeline_event_poll.xml @@ -33,7 +33,7 @@ app:layout_constraintTop_toBottomOf="@id/questionTextView" /> - \ No newline at end of file + diff --git a/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt b/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt index 4af33657f5..78e544f79d 100644 --- a/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt +++ b/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt @@ -91,7 +91,7 @@ class PollItemViewStateFactoryTest { pollViewState shouldBeEqualTo PollViewState( question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "", - totalVotes = stringProvider.instance.getString(R.string.poll_no_votes_cast), + votesStatus = stringProvider.instance.getString(R.string.poll_no_votes_cast), canVote = false, optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer -> PollOptionViewState.PollSending( @@ -117,7 +117,7 @@ class PollItemViewStateFactoryTest { pollViewState shouldBeEqualTo PollViewState( question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "", - totalVotes = stringProvider.instance.getQuantityString(R.plurals.poll_total_vote_count_after_ended, 0, 0), + votesStatus = stringProvider.instance.getQuantityString(R.plurals.poll_total_vote_count_after_ended, 0, 0), canVote = false, optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer -> PollOptionViewState.PollEnded( @@ -143,7 +143,7 @@ class PollItemViewStateFactoryTest { pollViewState shouldBeEqualTo PollViewState( question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "", - totalVotes = stringProvider.instance.getString(R.string.poll_undisclosed_not_ended), + votesStatus = stringProvider.instance.getString(R.string.poll_undisclosed_not_ended), canVote = true, optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer -> PollOptionViewState.PollUndisclosed( @@ -179,7 +179,7 @@ class PollItemViewStateFactoryTest { pollViewState shouldBeEqualTo PollViewState( question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "", - totalVotes = stringProvider.instance.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, 1, 1), + votesStatus = stringProvider.instance.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, 1, 1), canVote = true, optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.mapIndexed { index, answer -> PollOptionViewState.PollVoted( @@ -210,7 +210,7 @@ class PollItemViewStateFactoryTest { pollViewState shouldBeEqualTo PollViewState( question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "", - totalVotes = stringProvider.instance.getString(R.string.poll_no_votes_cast), + votesStatus = stringProvider.instance.getString(R.string.poll_no_votes_cast), canVote = true, optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer -> PollOptionViewState.PollReady(