mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
NumberButtonView: Display missing data as question marks
This commit is contained in:
@@ -25,11 +25,11 @@ import android.text.*
|
|||||||
import android.view.*
|
import android.view.*
|
||||||
import android.view.View.*
|
import android.view.View.*
|
||||||
import com.google.auto.factory.*
|
import com.google.auto.factory.*
|
||||||
import org.isoron.uhabits.utils.InterfaceUtils.getDimension
|
import org.isoron.uhabits.*
|
||||||
import org.isoron.uhabits.R
|
|
||||||
import org.isoron.uhabits.core.preferences.*
|
import org.isoron.uhabits.core.preferences.*
|
||||||
import org.isoron.uhabits.inject.*
|
import org.isoron.uhabits.inject.*
|
||||||
import org.isoron.uhabits.utils.*
|
import org.isoron.uhabits.utils.*
|
||||||
|
import org.isoron.uhabits.utils.InterfaceUtils.getDimension
|
||||||
import java.text.*
|
import java.text.*
|
||||||
|
|
||||||
private val BOLD_TYPEFACE = Typeface.create("sans-serif-condensed", Typeface.BOLD)
|
private val BOLD_TYPEFACE = Typeface.create("sans-serif-condensed", Typeface.BOLD)
|
||||||
@@ -140,13 +140,27 @@ class NumberButtonView(
|
|||||||
|
|
||||||
fun draw(canvas: Canvas) {
|
fun draw(canvas: Canvas) {
|
||||||
val activeColor = when {
|
val activeColor = when {
|
||||||
value == 0.0 -> lightGrey
|
value <= 0.0 -> lightGrey
|
||||||
value < threshold -> darkGrey
|
value < threshold -> darkGrey
|
||||||
else -> color
|
else -> color
|
||||||
}
|
}
|
||||||
|
|
||||||
val label = value.toShortString()
|
val label: String
|
||||||
|
val typeface: Typeface
|
||||||
|
|
||||||
|
if(value >= 0) {
|
||||||
|
label = value.toShortString()
|
||||||
|
typeface = BOLD_TYPEFACE
|
||||||
|
} else if(preferences.areQuestionMarksEnabled()) {
|
||||||
|
label = resources.getString(R.string.fa_question)
|
||||||
|
typeface = getFontAwesome()
|
||||||
|
} else {
|
||||||
|
label = "0"
|
||||||
|
typeface = BOLD_TYPEFACE
|
||||||
|
}
|
||||||
|
|
||||||
pBold.color = activeColor
|
pBold.color = activeColor
|
||||||
|
pBold.typeface = typeface
|
||||||
pRegular.color = activeColor
|
pRegular.color = activeColor
|
||||||
|
|
||||||
rect.set(0f, 0f, width.toFloat(), height.toFloat())
|
rect.set(0f, 0f, width.toFloat(), height.toFloat())
|
||||||
|
|||||||
Reference in New Issue
Block a user