ref #7: Slightly reduce bar height

This commit is contained in:
Tim Kluge 2024-12-13 21:42:58 +01:00
parent 73a7a4f610
commit 5c6c0ff966
2 changed files with 9 additions and 8 deletions

View File

@ -7,5 +7,5 @@
"latestVersionCode": 6,
"developer": "timklge",
"description": "Adds a colored power bar to the bottom of the screen",
"releaseNotes": "Add options to add secondary power bar and to hide bar when not riding. Fix manually set up power/hr zones."
"releaseNotes": "Fixes manually set up power/hr zones. Slightly adjusts bar appearance."
}

View File

@ -22,6 +22,7 @@ class CustomProgressBar @JvmOverloads constructor(
@ColorInt var progressColor: Int = 0xFF2b86e6.toInt()
val fontSize = 40f
val barHeight = 14f
private val linePaint = Paint().apply {
isAntiAlias = true
@ -87,10 +88,10 @@ class CustomProgressBar @JvmOverloads constructor(
1f,
15f,
((canvas.width.toDouble() - 1f) * progress.coerceIn(0.0, 1.0)).toFloat(),
15f + 20f
15f + barHeight
)
canvas.drawRoundRect(0f, 15f, canvas.width.toFloat(), 15f + 20f, 2f, 2f, backgroundPaint)
canvas.drawRect(0f, 15f, canvas.width.toFloat(), 15f + barHeight, backgroundPaint)
if (progress > 0.0) {
canvas.drawRoundRect(rect, 2f, 2f, blurPaint)
@ -111,19 +112,19 @@ class CustomProgressBar @JvmOverloads constructor(
canvas.drawRoundRect(x, y, r, b, 2f, 2f, blurPaint)
canvas.drawRoundRect(x, y, r, b, 2f, 2f, lineStrokePaint)
canvas.drawText(label, x + xOffset, rect.top + 23, textPaint)
canvas.drawText(label, x + xOffset, rect.top + barHeight + 6, textPaint)
}
}
}
PowerbarLocation.BOTTOM -> {
val rect = RectF(
1f,
canvas.height.toFloat() - 1f - 20f,
canvas.height.toFloat() - 1f - barHeight,
((canvas.width.toDouble() - 1f) * progress.coerceIn(0.0, 1.0)).toFloat(),
canvas.height.toFloat() - 1f
canvas.height.toFloat()
)
canvas.drawRoundRect(0f, canvas.height.toFloat() - 20f, canvas.width.toFloat(), canvas.height.toFloat(), 2f, 2f, backgroundPaint)
canvas.drawRect(0f, canvas.height.toFloat() - barHeight - 1f, canvas.width.toFloat(), canvas.height.toFloat(), backgroundPaint)
if (progress > 0.0) {
canvas.drawRoundRect(rect, 2f, 2f, blurPaint)
@ -144,7 +145,7 @@ class CustomProgressBar @JvmOverloads constructor(
canvas.drawRoundRect(x, y, r, b, 2f, 2f, blurPaint)
canvas.drawRoundRect(x, y, r, b, 2f, 2f, lineStrokePaint)
canvas.drawText(label, x + xOffset, rect.top + 16, textPaint)
canvas.drawText(label, x + xOffset, rect.top + barHeight - 1, textPaint)
}
}
}