CheckmarkDialog: Always set up all buttons

pull/1103/head
Alinson S. Xavier 4 years ago
parent c331f34fa9
commit c98cb50baa
No known key found for this signature in database
GPG Key ID: DCA0DAD4D2F58624

@ -79,29 +79,25 @@ class CheckmarkDialog
private fun setUpButtons(value: Int, color: Int) { private fun setUpButtons(value: Int, color: Int) {
val sres = StyledResources(context) val sres = StyledResources(context)
val mediumContrastColor = sres.getColor(R.attr.contrast60) val mediumContrastColor = sres.getColor(R.attr.contrast60)
setButtonAttrs(binding.yesBtn, color) setButtonAttrs(binding.yesBtn, color)
setButtonAttrs(binding.noBtn, mediumContrastColor) setButtonAttrs(binding.noBtn, mediumContrastColor)
setButtonAttrs(binding.skippedBtn, color, visible = preferences.isSkipEnabled)
if (preferences.isSkipEnabled) { setButtonAttrs(binding.questionBtn, mediumContrastColor, visible = preferences.areQuestionMarksEnabled)
setButtonAttrs(binding.skippedBtn, color)
if (value == SKIP) binding.skippedBtn.performClick()
}
if (preferences.areQuestionMarksEnabled) {
setButtonAttrs(binding.questionBtn, mediumContrastColor)
if (value == UNKNOWN) binding.questionBtn.performClick()
}
when (value) { when (value) {
YES_MANUAL, YES_AUTO -> binding.yesBtn.performClick() UNKNOWN -> if (preferences.areQuestionMarksEnabled) {
NO -> binding.noBtn.performClick() binding.questionBtn.performClick()
} else {
binding.noBtn.performClick()
}
SKIP -> binding.skippedBtn.performClick()
YES_MANUAL -> binding.yesBtn.performClick()
YES_AUTO, NO -> binding.noBtn.performClick()
} }
} }
private fun setButtonAttrs(button: Button, color: Int) { private fun setButtonAttrs(button: Button, color: Int, visible: Boolean = true) {
button.apply { button.apply {
visibility = View.VISIBLE visibility = if (visible) View.VISIBLE else View.GONE
typeface = fontAwesome typeface = fontAwesome
setTextColor(color) setTextColor(color)
setOnClickListener(this@CheckmarkDialog) setOnClickListener(this@CheckmarkDialog)

Loading…
Cancel
Save