From 5c6c0ff9661ca0cd3fcf798a369747372c2dd2d2 Mon Sep 17 00:00:00 2001 From: Tim Kluge Date: Fri, 13 Dec 2024 21:42:58 +0100 Subject: [PATCH] ref #7: Slightly reduce bar height --- app/manifest.json | 2 +- .../de/timklge/karoopowerbar/CustomProgressBar.kt | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/manifest.json b/app/manifest.json index d54feb3..afa7c6e 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -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." } \ No newline at end of file diff --git a/app/src/main/kotlin/de/timklge/karoopowerbar/CustomProgressBar.kt b/app/src/main/kotlin/de/timklge/karoopowerbar/CustomProgressBar.kt index b4f5a7b..0e9e6c2 100644 --- a/app/src/main/kotlin/de/timklge/karoopowerbar/CustomProgressBar.kt +++ b/app/src/main/kotlin/de/timklge/karoopowerbar/CustomProgressBar.kt @@ -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) } } }