Browse Source

make own votes bold in voting screen

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 3 years ago
parent
commit
a95c0d997b
1 changed files with 16 additions and 0 deletions
  1. 16 0
      app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt

+ 16 - 0
app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt

@@ -21,12 +21,14 @@
 
 package com.nextcloud.talk.polls.ui
 
+import android.graphics.Typeface
 import android.os.Bundle
 import android.util.Log
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import android.widget.CheckBox
+import android.widget.CompoundButton
 import android.widget.RadioButton
 import android.widget.Toast
 import androidx.fragment.app.Fragment
@@ -113,6 +115,10 @@ class PollVoteFragment(
                 RadioButton(context).apply { text = option }
             }?.forEachIndexed { index, radioButton ->
                 radioButton.id = index
+                // if (poll.votedSelf?.contains(index) == true) {
+                //     radioButton.setTypeface(null, Typeface.BOLD)
+                // }
+                makeOptionBoldIfSelfVoted(radioButton, poll, index)
                 binding.pollVoteRadioGroup.addView(radioButton)
 
                 radioButton.isChecked = viewModel.selectedOptions.contains(index) == true
@@ -123,6 +129,10 @@ class PollVoteFragment(
                 CheckBox(context).apply { text = option }
             }?.forEachIndexed { index, checkBox ->
                 checkBox.id = index
+                // if (poll.votedSelf?.contains(index) == true) {
+                //     checkBox.setTypeface(null, Typeface.BOLD)
+                // }
+                makeOptionBoldIfSelfVoted(checkBox, poll, index)
                 binding.voteOptionsCheckboxesWrapper.addView(checkBox)
 
                 checkBox.isChecked = viewModel.selectedOptions.contains(index) == true
@@ -142,6 +152,12 @@ class PollVoteFragment(
         }
     }
 
+    private fun makeOptionBoldIfSelfVoted(button: CompoundButton, poll: Poll, index: Int) {
+        if (poll.votedSelf?.contains(index) == true) {
+            button.setTypeface(null, Typeface.BOLD)
+        }
+    }
+
     private fun initCloseButton(showCloseButton: Boolean) {
         if (showCloseButton) {
             _binding?.pollVoteClosePollButton?.visibility = View.VISIBLE