From a95c0d997b1cb4caae83e782d9a003586ac78275 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Thu, 23 Jun 2022 16:01:16 +0200 Subject: [PATCH] make own votes bold in voting screen Signed-off-by: Marcel Hibbe --- .../nextcloud/talk/polls/ui/PollVoteFragment.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt b/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt index 9ad98d822..ed7b0461b 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt +++ b/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