From ec32b1781361a7f8eca6049efb6a01b9556084f3 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Wed, 6 Mar 2024 22:58:22 +0100 Subject: [PATCH] Fix rounding errors in calculating circle sweep angles --- .../activities/dashboard/DashboardTodayWidget.java | 6 +++--- 1 file changed, 3 insertions(+), 3 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 fd5f60cab..a4667e56b 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 @@ -291,7 +291,7 @@ public class DashboardTodayWidget extends AbstractDashboardWidget { float hourTextPixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, hourTextSp, requireContext().getResources().getDisplayMetrics()); float outerCircleMargin = mode_24h ? barWidth / 2f : barWidth / 2f + hourTextPixels * 1.3f; float innerCircleMargin = outerCircleMargin + barWidth * 1.3f; - int degreeFactor = mode_24h ? 240 : 120; + float degreeFactor = mode_24h ? 240 : 120; todayBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(todayBitmap); Paint paint = new Paint(); @@ -374,8 +374,8 @@ public class DashboardTodayWidget extends AbstractDashboardWidget { paint.setColor(color_unknown); canvas.drawArc(margin, margin, width - margin, height - margin, 270 + (secondIndex - dashboardData.timeFrom) / degreeFactor, (activity.timeFrom - secondIndex) / degreeFactor, false, paint); } - long start_angle = 270 + (activity.timeFrom - dashboardData.timeFrom) / degreeFactor; - long sweep_angle = (activity.timeTo - activity.timeFrom) / degreeFactor; + float start_angle = 270 + (activity.timeFrom - dashboardData.timeFrom) / degreeFactor; + float sweep_angle = (activity.timeTo - activity.timeFrom) / degreeFactor; if (activity.activityKind == ActivityKind.TYPE_NOT_MEASURED) { paint.setStrokeWidth(barWidth / 3f); paint.setColor(color_worn);