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:
commit
906fe8be76
|
@ -0,0 +1 @@
|
||||||
|
[Poll] - Add a description under undisclosed poll when not ended
|
|
@ -244,7 +244,7 @@ class MessageItemFactory @Inject constructor(
|
||||||
.eventId(informationData.eventId)
|
.eventId(informationData.eventId)
|
||||||
.pollQuestion(createPollQuestion(informationData, pollViewState.question, callback))
|
.pollQuestion(createPollQuestion(informationData, pollViewState.question, callback))
|
||||||
.canVote(pollViewState.canVote)
|
.canVote(pollViewState.canVote)
|
||||||
.totalVotesText(pollViewState.totalVotes)
|
.votesStatus(pollViewState.votesStatus)
|
||||||
.optionViewStates(pollViewState.optionViewStates)
|
.optionViewStates(pollViewState.optionViewStates)
|
||||||
.edited(informationData.hasBeenEdited)
|
.edited(informationData.hasBeenEdited)
|
||||||
.highlighted(highlight)
|
.highlighted(highlight)
|
||||||
|
|
|
@ -65,7 +65,7 @@ class PollItemViewStateFactory @Inject constructor(
|
||||||
private fun createSendingPollViewState(question: String, pollCreationInfo: PollCreationInfo?): PollViewState {
|
private fun createSendingPollViewState(question: String, pollCreationInfo: PollCreationInfo?): PollViewState {
|
||||||
return PollViewState(
|
return PollViewState(
|
||||||
question = question,
|
question = question,
|
||||||
totalVotes = stringProvider.getString(R.string.poll_no_votes_cast),
|
votesStatus = stringProvider.getString(R.string.poll_no_votes_cast),
|
||||||
canVote = false,
|
canVote = false,
|
||||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||||
PollOptionViewState.PollSending(
|
PollOptionViewState.PollSending(
|
||||||
|
@ -85,7 +85,7 @@ class PollItemViewStateFactory @Inject constructor(
|
||||||
): PollViewState {
|
): PollViewState {
|
||||||
return PollViewState(
|
return PollViewState(
|
||||||
question = question,
|
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,
|
canVote = false,
|
||||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||||
val voteSummary = pollResponseSummary?.getVoteSummaryOfAnOption(answer.id ?: "")
|
val voteSummary = pollResponseSummary?.getVoteSummaryOfAnOption(answer.id ?: "")
|
||||||
|
@ -107,7 +107,7 @@ class PollItemViewStateFactory @Inject constructor(
|
||||||
): PollViewState {
|
): PollViewState {
|
||||||
return PollViewState(
|
return PollViewState(
|
||||||
question = question,
|
question = question,
|
||||||
totalVotes = "",
|
votesStatus = stringProvider.getString(R.string.poll_undisclosed_not_ended),
|
||||||
canVote = true,
|
canVote = true,
|
||||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||||
val isMyVote = pollResponseSummary?.myVote == answer.id
|
val isMyVote = pollResponseSummary?.myVote == answer.id
|
||||||
|
@ -128,7 +128,7 @@ class PollItemViewStateFactory @Inject constructor(
|
||||||
): PollViewState {
|
): PollViewState {
|
||||||
return PollViewState(
|
return PollViewState(
|
||||||
question = question,
|
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,
|
canVote = true,
|
||||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||||
val isMyVote = pollResponseSummary?.myVote == answer.id
|
val isMyVote = pollResponseSummary?.myVote == answer.id
|
||||||
|
@ -152,7 +152,7 @@ class PollItemViewStateFactory @Inject constructor(
|
||||||
}
|
}
|
||||||
return PollViewState(
|
return PollViewState(
|
||||||
question = question,
|
question = question,
|
||||||
totalVotes = totalVotesText,
|
votesStatus = totalVotesText,
|
||||||
canVote = true,
|
canVote = true,
|
||||||
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
optionViewStates = pollCreationInfo?.answers?.map { answer ->
|
||||||
PollOptionViewState.PollReady(
|
PollOptionViewState.PollReady(
|
||||||
|
|
|
@ -42,7 +42,7 @@ abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
|
||||||
var canVote: Boolean = false
|
var canVote: Boolean = false
|
||||||
|
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var totalVotesText: String? = null
|
var votesStatus: String? = null
|
||||||
|
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var edited: Boolean = false
|
var edited: Boolean = false
|
||||||
|
@ -58,7 +58,7 @@ abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
|
||||||
renderSendState(holder.view, holder.questionTextView)
|
renderSendState(holder.view, holder.questionTextView)
|
||||||
|
|
||||||
holder.questionTextView.text = pollQuestion?.charSequence
|
holder.questionTextView.text = pollQuestion?.charSequence
|
||||||
holder.totalVotesTextView.text = totalVotesText
|
holder.votesStatusTextView.text = votesStatus
|
||||||
|
|
||||||
while (holder.optionsContainer.childCount < optionViewStates.size) {
|
while (holder.optionsContainer.childCount < optionViewStates.size) {
|
||||||
holder.optionsContainer.addView(PollOptionView(holder.view.context))
|
holder.optionsContainer.addView(PollOptionView(holder.view.context))
|
||||||
|
@ -88,7 +88,7 @@ abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
|
||||||
class Holder : AbsMessageItem.Holder(STUB_ID) {
|
class Holder : AbsMessageItem.Holder(STUB_ID) {
|
||||||
val questionTextView by bind<TextView>(R.id.questionTextView)
|
val questionTextView by bind<TextView>(R.id.questionTextView)
|
||||||
val optionsContainer by bind<LinearLayout>(R.id.optionsContainer)
|
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 {
|
companion object {
|
||||||
|
|
|
@ -19,8 +19,8 @@ package im.vector.app.features.poll
|
||||||
import im.vector.app.features.home.room.detail.timeline.item.PollOptionViewState
|
import im.vector.app.features.home.room.detail.timeline.item.PollOptionViewState
|
||||||
|
|
||||||
data class PollViewState(
|
data class PollViewState(
|
||||||
val question: String,
|
val question: String,
|
||||||
val totalVotes: String,
|
val votesStatus: String,
|
||||||
val canVote: Boolean,
|
val canVote: Boolean,
|
||||||
val optionViewStates: List<PollOptionViewState>?,
|
val optionViewStates: List<PollOptionViewState>?,
|
||||||
)
|
)
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/questionTextView" />
|
app:layout_constraintTop_toBottomOf="@id/questionTextView" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/optionsTotalVotesTextView"
|
android:id="@+id/optionsVotesStatusTextView"
|
||||||
style="@style/Widget.Vector.TextView.Caption"
|
style="@style/Widget.Vector.TextView.Caption"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -2983,6 +2983,7 @@
|
||||||
<item quantity="other">Based on %1$d votes</item>
|
<item quantity="other">Based on %1$d votes</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
<string name="poll_no_votes_cast">No votes cast</string>
|
<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">
|
<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="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>
|
<item quantity="other">%1$d votes cast. Vote to the see the results</item>
|
||||||
|
|
|
@ -91,7 +91,7 @@ class PollItemViewStateFactoryTest {
|
||||||
|
|
||||||
pollViewState shouldBeEqualTo PollViewState(
|
pollViewState shouldBeEqualTo PollViewState(
|
||||||
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
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,
|
canVote = false,
|
||||||
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
||||||
PollOptionViewState.PollSending(
|
PollOptionViewState.PollSending(
|
||||||
|
@ -117,7 +117,7 @@ class PollItemViewStateFactoryTest {
|
||||||
|
|
||||||
pollViewState shouldBeEqualTo PollViewState(
|
pollViewState shouldBeEqualTo PollViewState(
|
||||||
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
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,
|
canVote = false,
|
||||||
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
||||||
PollOptionViewState.PollEnded(
|
PollOptionViewState.PollEnded(
|
||||||
|
@ -143,7 +143,7 @@ class PollItemViewStateFactoryTest {
|
||||||
|
|
||||||
pollViewState shouldBeEqualTo PollViewState(
|
pollViewState shouldBeEqualTo PollViewState(
|
||||||
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
||||||
totalVotes = "",
|
votesStatus = stringProvider.instance.getString(R.string.poll_undisclosed_not_ended),
|
||||||
canVote = true,
|
canVote = true,
|
||||||
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
||||||
PollOptionViewState.PollUndisclosed(
|
PollOptionViewState.PollUndisclosed(
|
||||||
|
@ -179,7 +179,7 @@ class PollItemViewStateFactoryTest {
|
||||||
|
|
||||||
pollViewState shouldBeEqualTo PollViewState(
|
pollViewState shouldBeEqualTo PollViewState(
|
||||||
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
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,
|
canVote = true,
|
||||||
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.mapIndexed { index, answer ->
|
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.mapIndexed { index, answer ->
|
||||||
PollOptionViewState.PollVoted(
|
PollOptionViewState.PollVoted(
|
||||||
|
@ -210,7 +210,7 @@ class PollItemViewStateFactoryTest {
|
||||||
|
|
||||||
pollViewState shouldBeEqualTo PollViewState(
|
pollViewState shouldBeEqualTo PollViewState(
|
||||||
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
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,
|
canVote = true,
|
||||||
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
|
||||||
PollOptionViewState.PollReady(
|
PollOptionViewState.PollReady(
|
||||||
|
|
Loading…
Reference in New Issue