Allow unitless numerical habits

This commit is contained in:
2021-03-18 21:52:43 -05:00
parent 81cffc7253
commit 381c67d020
4 changed files with 17 additions and 9 deletions

View File

@@ -275,10 +275,6 @@ class EditHabitActivity : AppCompatActivity() {
isValid = false
}
if (habitType == Habit.NUMBER_HABIT) {
if (unitInput.text.isEmpty()) {
unitInput.error = getFormattedValidationError(R.string.validation_cannot_be_blank)
isValid = false
}
if (targetInput.text.isEmpty()) {
targetInput.error = getString(R.string.validation_cannot_be_blank)
isValid = false

View File

@@ -186,11 +186,16 @@ class NumberButtonView(
pNumber.typeface = typeface
pUnit.color = activeColor
rect.set(0f, 0f, width.toFloat(), height.toFloat())
canvas.drawText(label, rect.centerX(), rect.centerY(), pNumber)
rect.offset(0f, 1.3f * em)
canvas.drawText(units, rect.centerX(), rect.centerY(), pUnit)
if (units.isBlank()) {
rect.set(0f, 0f, width.toFloat(), height.toFloat())
rect.offset(0f, 0.5f * em)
canvas.drawText(label, rect.centerX(), rect.centerY(), pNumber)
} else {
rect.set(0f, 0f, width.toFloat(), height.toFloat())
canvas.drawText(label, rect.centerX(), rect.centerY(), pNumber)
rect.offset(0f, 1.3f * em)
canvas.drawText(units, rect.centerX(), rect.centerY(), pUnit)
}
}
}
}