From 35b6ab7e9d77174a57f6d5cde6f4cfc3d23cfcbb Mon Sep 17 00:00:00 2001 From: Navid200 <51497406+Navid200@users.noreply.github.com> Date: Mon, 16 Dec 2024 11:47:37 -0500 Subject: [PATCH] Time unit symbols --- .../eveningoutpost/dexdrip/models/JoH.java | 23 +++++++++++-------- .../services/Ob1G5CollectionService.java | 4 +++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java b/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java index d283926acc..df2398f0ba 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java @@ -754,26 +754,29 @@ public static String niceTimeTill(long t) { } // temporary - public static String niceTimeScalar(long t) { + public static String niceTimeScalar(long t) { // If forceSym is not entered as a parameter, a value of false will be assumed for it. + return niceTimeScalar(t, false); // The method will use translations, instead of symbols, if forceSym is set to false. + } + public static String niceTimeScalar(long t, boolean forceSym) { // Symbols will be used if forceSym is true, regardless of the chosen language String unit = xdrip.getAppContext().getString(R.string.unit_second); t = t / 1000; - if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_seconds); + if (t != 1) unit = forceSym? "s" : xdrip.getAppContext().getString(R.string.unit_seconds); if (t > 59) { - unit = xdrip.getAppContext().getString(R.string.unit_minute); + unit = forceSym? "min" : xdrip.getAppContext().getString(R.string.unit_minute); t = t / 60; - if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_minutes); + if (t != 1) unit = forceSym? "min" : xdrip.getAppContext().getString(R.string.unit_minutes); if (t > 59) { - unit = xdrip.getAppContext().getString(R.string.unit_hour); + unit = forceSym? "h" : xdrip.getAppContext().getString(R.string.unit_hour); t = t / 60; - if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_hours); + if (t != 1) unit = forceSym? "h" : xdrip.getAppContext().getString(R.string.unit_hours); if (t > 24) { - unit = xdrip.getAppContext().getString(R.string.unit_day); + unit = forceSym? "d" : xdrip.getAppContext().getString(R.string.unit_day); t = t / 24; - if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_days); + if (t != 1) unit = forceSym? "d" : xdrip.getAppContext().getString(R.string.unit_days); if (t > 28) { - unit = xdrip.getAppContext().getString(R.string.unit_week); + unit = forceSym? "wk" : xdrip.getAppContext().getString(R.string.unit_week); t = t / 7; - if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_weeks); + if (t != 1) unit = forceSym? "wk" : xdrip.getAppContext().getString(R.string.unit_weeks); } } } diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java b/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java index 30e9bca565..25b60d716e 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java @@ -2175,7 +2175,9 @@ public static List megaStatus() { } if (static_last_connected > 0) { - l.add(new StatusItem("Last Connected", niceTimeScalar(msSince(static_last_connected)) + " ago")); + l.add(new StatusItem("Last Connected", niceTimeScalar(msSince(static_last_connected), true) + " ago")); // Time symbols are used to avoid translations. + // This parameter is extremely important when troubleshooting connectivity. Let's use symbols for this parameter on this page so that those helping won't have to + // translate back to English or other languages, which could possibly cause errors. } if ((!lastState.startsWith("Service Stopped")) && (!lastState.startsWith("Not running")))