Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:pantasystem/Milktea into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pantasystem committed Sep 14, 2023
2 parents 57a6536 + 9ce7052 commit b372947
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 10 deletions.
1 change: 1 addition & 0 deletions modules/common_resource/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<string name="reacted_by">%sさんにリアクションされました</string>
<string name="renoted_by">%sさんにリノートされました</string>
<string name="follow_requested_by">%sさんにフォローリクエストされました。</string>
<string name="total_vote_count">計%s票</string>
<string name="poll_ended">投票が終了</string>

<string name="input_message">相手に思いを伝えてください</string>
Expand Down
1 change: 1 addition & 0 deletions modules/common_resource/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<string name="renoted_by">被 %s 转帖</string>
<string name="follow_requested_by">来自 %s 的关注请求</string>
<string name="poll_ended">投票结束</string>
<string name="total_vote_count">总票数 %s</string>

<string name="input_message">有什么新鲜事?</string>

Expand Down
1 change: 1 addition & 0 deletions modules/common_resource/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<string name="replied_by">Reply from %s</string>
<string name="quoted_by">Quoted by %s</string>
<string name="voted_by">poll voted in by %s</string>
<string name="total_vote_count">%s votes in total</string>
<string name="mention_by">mentioned by %s</string>
<string name="reacted_by">reaction sent by %s</string>
<string name="renoted_by">renoted by %s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ object PollHelper {
this.visibility = View.VISIBLE
}
PollListLinearLayoutBinder.bindPollChoices(this, noteId, poll, noteCardActionListenerAdapter)
PollListLinearLayoutBinder.bindVoteResult(this, poll.totalVoteCount)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import android.view.LayoutInflater
import android.widget.LinearLayout
import net.pantasystem.milktea.model.note.Note
import net.pantasystem.milktea.model.note.poll.Poll
import net.pantasystem.milktea.note.R
import net.pantasystem.milktea.note.databinding.ItemChoiceBinding
import net.pantasystem.milktea.note.databinding.ItemVoteResultBinding
import net.pantasystem.milktea.note.view.NoteCardActionListenerAdapter

object PollListLinearLayoutBinder {
Expand Down Expand Up @@ -37,16 +39,32 @@ object PollListLinearLayoutBinder {
}
}

private fun bindItem(binding: ItemChoiceBinding, choice: Poll.Choice, noteId: Note.Id, poll: Poll, onVoteSelected: (OnVoted) -> Unit) {
binding.radioChoice.setOnClickListener {
onVoteSelected(OnVoted(noteId, choice, poll))
}
fun bindVoteResult(
layout: LinearLayout,
totalVoteCount: Int
) {
val binding = ItemVoteResultBinding.inflate(LayoutInflater.from(layout.context), layout, false)

binding.radioChoice.text = choice.text
binding.radioChoice.isEnabled = poll.canVote
binding.radioChoice.isChecked = choice.isVoted
binding.voteResult.text = layout.context.getString(R.string.total_vote_count, totalVoteCount.toString())
layout.addView(binding.root)
}
}

binding.progressBar.max = poll.totalVoteCount
binding.progressBar.progress = choice.votes
private fun bindItem(
binding: ItemChoiceBinding,
choice: Poll.Choice,
noteId: Note.Id,
poll: Poll,
onVoteSelected: (OnVoted) -> Unit
) {
binding.radioChoice.setOnClickListener {
onVoteSelected(OnVoted(noteId, choice, poll))
}
}

binding.radioChoice.text = choice.text
binding.radioChoice.isEnabled = poll.canVote
binding.radioChoice.isChecked = choice.isVoted

binding.progressBar.max = poll.totalVoteCount
binding.progressBar.progress = choice.votes
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/voteResult"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
/>

0 comments on commit b372947

Please sign in to comment.