HistoryCard: Make colors more consistent for AT_MOST habits

This commit is contained in:
2022-01-02 11:06:37 -06:00
parent d40a5a89cd
commit 5b8a7c39e2
3 changed files with 31 additions and 41 deletions

View File

@@ -29,7 +29,8 @@ import android.view.View
import android.view.View.OnClickListener
import android.view.View.OnLongClickListener
import org.isoron.uhabits.R
import org.isoron.uhabits.core.models.NumericalHabitType
import org.isoron.uhabits.core.models.NumericalHabitType.AT_LEAST
import org.isoron.uhabits.core.models.NumericalHabitType.AT_MOST
import org.isoron.uhabits.core.preferences.Preferences
import org.isoron.uhabits.inject.ActivityContext
import org.isoron.uhabits.utils.InterfaceUtils.getDimension
@@ -37,7 +38,6 @@ import org.isoron.uhabits.utils.dim
import org.isoron.uhabits.utils.drawNotesIndicator
import org.isoron.uhabits.utils.getFontAwesome
import org.isoron.uhabits.utils.sres
import java.lang.Double.max
import java.text.DecimalFormat
import javax.inject.Inject
@@ -90,7 +90,7 @@ class NumberButtonView(
invalidate()
}
var targetType = NumericalHabitType.AT_LEAST
var targetType = AT_LEAST
set(value) {
field = value
invalidate()
@@ -164,18 +164,11 @@ class NumberButtonView(
}
fun draw(canvas: Canvas) {
var activeColor = if (targetType == NumericalHabitType.AT_LEAST) {
when {
value < 0.0 && preferences.areQuestionMarksEnabled -> lowContrast
max(0.0, value) >= threshold -> color
else -> mediumContrast
}
} else {
when {
value < 0.0 && preferences.areQuestionMarksEnabled -> lowContrast
value <= threshold -> color
else -> mediumContrast
}
val activeColor = when {
value < 0.0 -> lowContrast
(targetType == AT_LEAST) && (value >= threshold) -> color
(targetType == AT_MOST) && (value <= threshold) -> color
else -> mediumContrast
}
val label: String