From 27fc33d126454a3430fb9944afedf9e0aa99ea6b Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Thu, 4 Apr 2024 20:26:23 +0200 Subject: [PATCH] Fix cut-off today widget hours due to rounding error --- .../activities/dashboard/DashboardTodayWidget.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/dashboard/DashboardTodayWidget.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/dashboard/DashboardTodayWidget.java index 86fa4c2e2..646db2f9f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/dashboard/DashboardTodayWidget.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/dashboard/DashboardTodayWidget.java @@ -202,11 +202,13 @@ public class DashboardTodayWidget extends AbstractDashboardWidget { textPaint.getTextBounds(hours.get(12), 0, hours.get(12).length(), textBounds); canvas.drawText(hours.get(12), width / 2f, clockMargin + clockStripesWidth + textBounds.height(), textPaint); textPaint.getTextBounds(hours.get(15), 0, hours.get(15).length(), textBounds); - canvas.drawText(hours.get(15), width - textBounds.width() / 2f, height / 2f + textBounds.height() / 2f, textPaint); + canvas.drawText(hours.get(15), (float) (width - Math.ceil(textBounds.width() / 2f)), height / 2f + textBounds.height() / 2f, textPaint); textPaint.getTextBounds(hours.get(18), 0, hours.get(18).length(), textBounds); canvas.drawText(hours.get(18), width / 2f, height - textBounds.height() / 2f, textPaint); + textPaint.setTextAlign(Paint.Align.LEFT); textPaint.getTextBounds(hours.get(21), 0, hours.get(21).length(), textBounds); - canvas.drawText(hours.get(21), textBounds.width() / 2f, height / 2f + textBounds.height() / 2f, textPaint); + canvas.drawText(hours.get(21), 1, height / 2f + textBounds.height() / 2f, textPaint); + textPaint.setTextAlign(Paint.Align.CENTER); textPaint.getTextBounds(hours.get(24), 0, hours.get(24).length(), textBounds); canvas.drawText(hours.get(24), width / 2f, textBounds.height(), textPaint); }