From 26aaf8480601a663a2c6ff01a8065fcd9d79bcbb Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 4 Jul 2022 10:14:15 +0200 Subject: [PATCH] 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(