Handle numerical habits with target value of zero

Fixes #903
This commit is contained in:
2021-05-15 20:08:04 -05:00
parent 89e3dd7655
commit fcadbe7c38
6 changed files with 30 additions and 5 deletions

View File

@@ -37,8 +37,8 @@ android {
compileSdkVersion(30)
defaultConfig {
versionCode(20001)
versionName("2.0.1")
versionCode(20002)
versionName("2.0.2")
minSdkVersion(23)
targetSdkVersion(30)
applicationId("org.isoron.uhabits")

View File

@@ -117,7 +117,11 @@ class TargetChart : View {
barRect[rect.left + stop + padding, rect.top + baseSize * 0.05f, rect.right - padding] =
rect.bottom - baseSize * 0.05f
canvas.drawRoundRect(barRect, round, round, paint!!)
var percentage = (values[row] / targets[row]).toFloat()
var percentage = if (targets[row] > 0) {
(values[row] / targets[row]).toFloat()
} else {
1.0f
}
percentage = min(1.0f, percentage)
// Draw completed box

View File

@@ -1,3 +1,5 @@
2.0.2:
* Bug fixes
2.0:
* Track numeric habits (e.g. how many pages did you read?)
* Skip days without breaking your streak