Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time unit symbols for the Dex status page last connected #3817

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,9 @@ public static List<StatusItem> 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")))
Expand Down
Loading