mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Allow unitless numerical habits
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -73,6 +73,13 @@ class NumberButtonViewTest : BaseViewTest() {
|
|||||||
assertRenders(view, "$PATH/render_above.png")
|
assertRenders(view, "$PATH/render_above.png")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testRender_emptyUnits() {
|
||||||
|
view.value = 500.0
|
||||||
|
view.units = ""
|
||||||
|
assertRenders(view, "$PATH/render_unitless.png")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testRender_belowThreshold() {
|
fun testRender_belowThreshold() {
|
||||||
view.value = 99.0
|
view.value = 99.0
|
||||||
|
|||||||
@@ -275,10 +275,6 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
isValid = false
|
isValid = false
|
||||||
}
|
}
|
||||||
if (habitType == Habit.NUMBER_HABIT) {
|
if (habitType == Habit.NUMBER_HABIT) {
|
||||||
if (unitInput.text.isEmpty()) {
|
|
||||||
unitInput.error = getFormattedValidationError(R.string.validation_cannot_be_blank)
|
|
||||||
isValid = false
|
|
||||||
}
|
|
||||||
if (targetInput.text.isEmpty()) {
|
if (targetInput.text.isEmpty()) {
|
||||||
targetInput.error = getString(R.string.validation_cannot_be_blank)
|
targetInput.error = getString(R.string.validation_cannot_be_blank)
|
||||||
isValid = false
|
isValid = false
|
||||||
|
|||||||
@@ -186,11 +186,16 @@ class NumberButtonView(
|
|||||||
pNumber.typeface = typeface
|
pNumber.typeface = typeface
|
||||||
pUnit.color = activeColor
|
pUnit.color = activeColor
|
||||||
|
|
||||||
rect.set(0f, 0f, width.toFloat(), height.toFloat())
|
if (units.isBlank()) {
|
||||||
canvas.drawText(label, rect.centerX(), rect.centerY(), pNumber)
|
rect.set(0f, 0f, width.toFloat(), height.toFloat())
|
||||||
|
rect.offset(0f, 0.5f * em)
|
||||||
rect.offset(0f, 1.3f * em)
|
canvas.drawText(label, rect.centerX(), rect.centerY(), pNumber)
|
||||||
canvas.drawText(units, rect.centerX(), rect.centerY(), pUnit)
|
} 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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user