Merge pull request #6425 from vector-im/fix/mna/undisclosed-poll-description

[Poll] - Add a description under undisclosed poll when not ended (PSB-134)
This commit is contained in:
Maxime NATUREL 2022-07-04 11:20:59 +02:00 committed by GitHub
commit 906fe8be76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 20 deletions

1
changelog.d/6423.misc Normal file
View File

@ -0,0 +1 @@
[Poll] - Add a description under undisclosed poll when not ended

View File

@ -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)

View File

@ -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 = "",
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(

View File

@ -42,7 +42,7 @@ abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
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<PollItem.Holder>() {
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<PollItem.Holder>() {
class Holder : AbsMessageItem.Holder(STUB_ID) {
val questionTextView by bind<TextView>(R.id.questionTextView)
val optionsContainer by bind<LinearLayout>(R.id.optionsContainer)
val totalVotesTextView by bind<TextView>(R.id.optionsTotalVotesTextView)
val votesStatusTextView by bind<TextView>(R.id.optionsVotesStatusTextView)
}
companion object {

View File

@ -20,7 +20,7 @@ import im.vector.app.features.home.room.detail.timeline.item.PollOptionViewState
data class PollViewState(
val question: String,
val totalVotes: String,
val votesStatus: String,
val canVote: Boolean,
val optionViewStates: List<PollOptionViewState>?,
)

View File

@ -33,7 +33,7 @@
app:layout_constraintTop_toBottomOf="@id/questionTextView" />
<TextView
android:id="@+id/optionsTotalVotesTextView"
android:id="@+id/optionsVotesStatusTextView"
style="@style/Widget.Vector.TextView.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@ -2983,6 +2983,7 @@
<item quantity="other">Based on %1$d votes</item>
</plurals>
<string name="poll_no_votes_cast">No votes cast</string>
<string name="poll_undisclosed_not_ended">Results will be visible when the poll is ended</string>
<plurals name="poll_total_vote_count_before_ended_and_not_voted">
<item quantity="one">%1$d vote cast. Vote to the see the results</item>
<item quantity="other">%1$d votes cast. Vote to the see the results</item>

View File

@ -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 = "",
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(