Fix #2210: measurable habits incorrectly highlighted when value is 0 but target > 0

pull/2214/head
Karthikeyan 3 weeks ago
parent 87bdcf6850
commit 6cdbfbd1a9

@ -173,8 +173,7 @@ class NumberButtonView(
fun draw(canvas: Canvas) { fun draw(canvas: Canvas) {
val activeColor = when { val activeColor = when {
value < 0.0 -> lowContrast (value < 0.0) || ((targetType == AT_LEAST) && ((value == 0.0) && (threshold != 0.0))) -> lowContrast
(targetType == AT_LEAST) && ((value == 0.0) && (threshold != 0.0)) -> lowContrast
(targetType == AT_LEAST) && (value >= threshold) -> color (targetType == AT_LEAST) && (value >= threshold) -> color
(targetType == AT_MOST) && (value <= threshold) -> color (targetType == AT_MOST) && (value <= threshold) -> color
else -> mediumContrast else -> mediumContrast

@ -46,6 +46,7 @@ import org.isoron.uhabits.core.ui.views.Theme
import org.isoron.uhabits.core.utils.DateUtils import org.isoron.uhabits.core.utils.DateUtils
import kotlin.math.roundToInt import kotlin.math.roundToInt
data class HistoryCardState( data class HistoryCardState(
val color: PaletteColor, val color: PaletteColor,
val firstWeekday: DayOfWeek, val firstWeekday: DayOfWeek,
@ -165,7 +166,7 @@ class HistoryCardPresenter(
val series = if (habit.isNumerical) { val series = if (habit.isNumerical) {
entries.map { entries.map {
when { when {
it.value == Entry.UNKNOWN -> OFF (it.value == Entry.UNKNOWN) || ((habit.targetType == AT_LEAST) && (it.value == 0 && habit.targetValue != 0.0)) -> OFF
it.value == SKIP -> HATCHED it.value == SKIP -> HATCHED
(habit.targetType == AT_MOST) && (it.value / 1000.0 <= habit.targetValue) -> ON (habit.targetType == AT_MOST) && (it.value / 1000.0 <= habit.targetValue) -> ON
(habit.targetType == AT_LEAST) && (it.value / 1000.0 >= habit.targetValue) -> ON (habit.targetType == AT_LEAST) && (it.value / 1000.0 >= habit.targetValue) -> ON

Loading…
Cancel
Save