From 027473d65073ac7aafe4f0af8e2f4d25927c59f5 Mon Sep 17 00:00:00 2001 From: Andrey Novikov Date: Mon, 18 Mar 2024 10:59:10 +0300 Subject: [PATCH] Show letters instead of sign in turn gauge --- app/src/main/java/mobi/maptrek/MapTrek.java | 2 ++ .../main/java/mobi/maptrek/util/StringFormatter.java | 12 +++++++++++- app/src/main/java/mobi/maptrek/view/Gauge.java | 7 +++++-- app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/mobi/maptrek/MapTrek.java b/app/src/main/java/mobi/maptrek/MapTrek.java index b1c374bc..5f6c6cc8 100644 --- a/app/src/main/java/mobi/maptrek/MapTrek.java +++ b/app/src/main/java/mobi/maptrek/MapTrek.java @@ -198,6 +198,8 @@ private void initializeSettings() { unit = Configuration.getAngleUnit(); StringFormatter.angleFactor = Double.parseDouble(resources.getStringArray(R.array.angle_factors)[unit]); StringFormatter.angleAbbr = resources.getStringArray(R.array.angle_abbreviations)[unit]; + StringFormatter.angleLeft = resources.getString(R.string.angle_left); + StringFormatter.angleRight = resources.getString(R.string.angle_right); boolean precision = Configuration.getUnitPrecision(); StringFormatter.precisionFormat = precision ? "%.1f" : "%.0f"; StringFormatter.coordinateFormat = Configuration.getCoordinatesFormat(); diff --git a/app/src/main/java/mobi/maptrek/util/StringFormatter.java b/app/src/main/java/mobi/maptrek/util/StringFormatter.java index 3aa9f627..e6c6be7e 100644 --- a/app/src/main/java/mobi/maptrek/util/StringFormatter.java +++ b/app/src/main/java/mobi/maptrek/util/StringFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Andrey Novikov + * Copyright 2024 Andrey Novikov * * This program is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -57,6 +57,8 @@ public class StringFormatter public static String angleFormat = "%.0f"; public static double angleFactor = 1d; public static String angleAbbr = "deg"; + public static String angleLeft = "L"; + public static String angleRight = "R"; //FIXME Should localize: public static String secondAbbr = "sec"; @@ -166,6 +168,14 @@ public static String angleH(final double angle) } } + public static String angleT(final double angle) + { + String value = angleC(Math.abs(angle)); + if ("0".equals(value)) + return value; + return (angle < 0 ? angleLeft : angleRight) + value; + } + public static String angleC(final double angle) { return String.format(angleFormat, angle / angleFactor); diff --git a/app/src/main/java/mobi/maptrek/view/Gauge.java b/app/src/main/java/mobi/maptrek/view/Gauge.java index e436e8c8..385848a1 100644 --- a/app/src/main/java/mobi/maptrek/view/Gauge.java +++ b/app/src/main/java/mobi/maptrek/view/Gauge.java @@ -98,11 +98,14 @@ public void setValue(float value) { break; } case Gauge.TYPE_TRACK: - case Gauge.TYPE_BEARING: - case Gauge.TYPE_TURN: { + case Gauge.TYPE_BEARING: { indication = StringFormatter.angleC(value); break; } + case Gauge.TYPE_TURN: { + indication = StringFormatter.angleT(value); + break; + } default: indication = String.format(Locale.getDefault(), StringFormatter.precisionFormat, value); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index eb8e80d9..0adfaea1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -253,6 +253,8 @@ Cross track ETE Elevation + L + R ⌶ %s ~ %s My places