Extracted insight strings
This commit is contained in:
parent
7f73c59530
commit
73ea3628b2
|
@ -715,7 +715,11 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
|||
|
||||
@Override
|
||||
public String shortStatus(boolean veryShort) {
|
||||
return "Insight Pump";
|
||||
String msg = gs(R.string.insightpump_shortname) + " Batt: " + batteryPercent + " Reserv: " + reservoirInUnits + " Basal: " + basalRate;
|
||||
if (LiveHistory.getStatus().length() > 0) {
|
||||
msg += LiveHistory.getStatus();
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
private void processStatusResult() {
|
||||
|
@ -741,8 +745,8 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
|||
|
||||
// Todo last contact time
|
||||
|
||||
l.add(new StatusItem("Status", connector.getLastStatusMessage()));
|
||||
l.add(new StatusItem("Changed", connector.getNiceLastStatusTime()));
|
||||
l.add(new StatusItem(gs(R.string.status_no_colon), connector.getLastStatusMessage()));
|
||||
l.add(new StatusItem(gs(R.string.changed), connector.getNiceLastStatusTime()));
|
||||
|
||||
boolean pumpRunning;
|
||||
// also check time since received
|
||||
|
@ -752,7 +756,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
|||
if (pumpRunning) {
|
||||
l.add(new StatusItem(gs(R.string.pump_basebasalrate_label), getBaseBasalRateString() + "U"));
|
||||
} else {
|
||||
l.add(new StatusItem("Warning", "PUMP STOPPED", StatusItem.Highlight.CRITICAL));
|
||||
l.add(new StatusItem(gs(R.string.combo_warning), gs(R.string.pump_stopped_uppercase), StatusItem.Highlight.CRITICAL));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -760,7 +764,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
|||
final long offset_minutes = offset_ms / 60000;
|
||||
|
||||
if (statusResult != null) {
|
||||
l.add(new StatusItem("Status Updated", Helpers.niceTimeScalar(Helpers.msSince(statusResultTime)) + " ago"));
|
||||
l.add(new StatusItem(gs(R.string.status_updated), Helpers.niceTimeScalar(Helpers.msSince(statusResultTime)) + " " + gs(R.string.ago)));
|
||||
l.add(new StatusItem(gs(R.string.pump_battery_label), batteryPercent + "%", batteryPercent < 100 ?
|
||||
(batteryPercent < 90 ?
|
||||
(batteryPercent < 70 ?
|
||||
|
@ -768,9 +772,9 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
|||
l.add(new StatusItem(gs(R.string.pump_reservoir_label), reservoirInUnits + "U"));
|
||||
|
||||
if (statusResult.getCurrentTBRMessage().getPercentage() != 100) {
|
||||
l.add(new StatusItem("Active TBR", statusResult.getCurrentTBRMessage().getPercentage() + "% with "
|
||||
l.add(new StatusItem(gs(R.string.insight_active_tbr), statusResult.getCurrentTBRMessage().getPercentage() + "% " + gs(R.string.with) + " "
|
||||
+ Helpers.qs(statusResult.getCurrentTBRMessage().getLeftoverTime() - offset_minutes, 0)
|
||||
+ " min left", StatusItem.Highlight.NOTICE));
|
||||
+ " " + gs(R.string.insight_min_left), StatusItem.Highlight.NOTICE));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -798,13 +802,16 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
|||
}
|
||||
}
|
||||
|
||||
l.add(new StatusItem("Log book", HistoryReceiver.getStatusString()));
|
||||
l.add(new StatusItem(gs(R.string.log_book), HistoryReceiver.getStatusString()));
|
||||
|
||||
if (LiveHistory.getStatus().length() > 0) {
|
||||
l.add(new StatusItem("Last Completed Action", LiveHistory.getStatus()));
|
||||
l.add(new StatusItem(gs(R.string.insight_last_completed_action), LiveHistory.getStatus()));
|
||||
}
|
||||
|
||||
Connector.get().requestHistorySync();
|
||||
if (Helpers.ratelimit("insight-status-ui-refresh", 10)) {
|
||||
connector.tryToGetPumpStatusAgain();
|
||||
}
|
||||
connector.requestHistorySync();
|
||||
if (refresh) scheduleGUIUpdate();
|
||||
|
||||
return l;
|
||||
|
@ -827,15 +834,15 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
|||
switch (activeBolus.getBolusType()) {
|
||||
|
||||
case STANDARD:
|
||||
l.add(new StatusItem(activeBolus.getBolusType() + " Bolus", activeBolus.getInitialAmount() + "U", StatusItem.Highlight.NOTICE));
|
||||
l.add(new StatusItem(activeBolus.getBolusType() + " " + gs(R.string.bolus), activeBolus.getInitialAmount() + "U", StatusItem.Highlight.NOTICE));
|
||||
break;
|
||||
case EXTENDED:
|
||||
l.add(new StatusItem(activeBolus.getBolusType() + " Bolus", activeBolus.getInitialAmount() + "U total with "
|
||||
+ activeBolus.getLeftoverAmount() + "U remaining over " + (activeBolus.getDuration() - offset_mins) + " min", StatusItem.Highlight.NOTICE));
|
||||
l.add(new StatusItem(activeBolus.getBolusType() + " " + gs(R.string.bolus), activeBolus.getInitialAmount() + "U " + gs(R.string.insight_total_with) + " "
|
||||
+ activeBolus.getLeftoverAmount() + "U " + gs(R.string.insight_remaining_over) + " " + (activeBolus.getDuration() - offset_mins) + " " + gs(R.string.insight_min), StatusItem.Highlight.NOTICE));
|
||||
break;
|
||||
case MULTIWAVE:
|
||||
l.add(new StatusItem(activeBolus.getBolusType() + " Bolus", activeBolus.getInitialAmount() + "U upfront with "
|
||||
+ activeBolus.getLeftoverAmount() + "U remaining over " + (activeBolus.getDuration() - offset_mins) + " min", StatusItem.Highlight.NOTICE));
|
||||
l.add(new StatusItem(activeBolus.getBolusType() + " " + gs(R.string.bolus), activeBolus.getInitialAmount() + "U " + gs(R.string.insight_upfront_with) + " "
|
||||
+ activeBolus.getLeftoverAmount() + "U " + gs(R.string.insight_remaining_over) + " " + (activeBolus.getDuration() - offset_mins) + " " + gs(R.string.insight_min), StatusItem.Highlight.NOTICE));
|
||||
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
|||
import android.os.PowerManager;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.history.LiveHistory;
|
||||
|
@ -69,7 +70,7 @@ public class Connector {
|
|||
} else {
|
||||
log("PROTOCOL VERSION MISMATCH! local: " + COMPATIBILITY_VERSION + " remote: " + remoteVersion);
|
||||
statusCallback.onStatusChange(Status.INCOMPATIBLE);
|
||||
compatabilityMessage = "Incompatible companion app, we need version " + getLocalVersion();
|
||||
compatabilityMessage = gs(R.string.insight_incompatible_compantion_app_we_need_version) + " " + getLocalVersion();
|
||||
serviceConnector.disconnectFromService();
|
||||
|
||||
}
|
||||
|
@ -128,6 +129,37 @@ public class Connector {
|
|||
return COMPATIBILITY_VERSION;
|
||||
}
|
||||
|
||||
private static String statusToString(Status status) {
|
||||
switch (status) {
|
||||
|
||||
case EXCHANGING_KEYS:
|
||||
return gs(R.string.connecting).toUpperCase();
|
||||
case WAITING_FOR_CODE_CONFIRMATION:
|
||||
return gs(R.string.insight_waiting_for_code).toUpperCase();
|
||||
case CODE_REJECTED:
|
||||
return gs(R.string.insight_code_rejected).toUpperCase();
|
||||
case APP_BINDING:
|
||||
return gs(R.string.insight_app_binding).toUpperCase();
|
||||
case CONNECTING:
|
||||
return gs(R.string.connecting).toUpperCase();
|
||||
case CONNECTED:
|
||||
return gs(R.string.connected).toUpperCase();
|
||||
case DISCONNECTED:
|
||||
return gs(R.string.disconnected).toUpperCase();
|
||||
case NOT_AUTHORIZED:
|
||||
return gs(R.string.insight_not_authorized).toUpperCase();
|
||||
case INCOMPATIBLE:
|
||||
return gs(R.string.insight_incompatible).toUpperCase();
|
||||
|
||||
default:
|
||||
return status.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static String gs(int id) {
|
||||
return MainApp.instance().getString(id);
|
||||
}
|
||||
|
||||
@SuppressWarnings("AccessStaticViaInstance")
|
||||
private synchronized void initializeHistoryReceiver() {
|
||||
if (historyReceiver == null) {
|
||||
|
@ -208,7 +240,7 @@ public class Connector {
|
|||
public String getLastStatusMessage() {
|
||||
|
||||
if (!companionAppInstalled) {
|
||||
return "Companion app does not appear to be installed!";
|
||||
return gs(R.string.insight_companion_app_not_installed);
|
||||
}
|
||||
|
||||
if (!isConnected()) {
|
||||
|
@ -222,13 +254,13 @@ public class Connector {
|
|||
// if disconnected but previous state was incompatible
|
||||
return compatabilityMessage;
|
||||
} else {
|
||||
return "Not connected to companion app!";
|
||||
return gs(R.string.insight_not_connected_to_companion_app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastStatus == null) {
|
||||
return "Unknown";
|
||||
return gs(R.string.insight_unknown);
|
||||
}
|
||||
|
||||
switch (lastStatus) {
|
||||
|
@ -238,16 +270,16 @@ public class Connector {
|
|||
}
|
||||
break;
|
||||
case INCOMPATIBLE:
|
||||
return lastStatus.toString() + " needs " + getLocalVersion();
|
||||
return statusToString(lastStatus) + " " + gs(R.string.insight_needs) + " " + getLocalVersion();
|
||||
}
|
||||
return lastStatus.toString();
|
||||
return statusToString(lastStatus);
|
||||
}
|
||||
|
||||
public String getNiceLastStatusTime() {
|
||||
if (lastStatusTime < 1) {
|
||||
return "STARTUP";
|
||||
return gs(R.string.insight_startup_uppercase);
|
||||
} else {
|
||||
return Helpers.niceTimeScalar(Helpers.msSince(lastStatusTime)) + " ago";
|
||||
return Helpers.niceTimeScalar(Helpers.msSince(lastStatusTime)) + " " + gs(R.string.ago);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
|||
import android.content.IntentFilter;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.BUSY;
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.SYNCED;
|
||||
|
@ -100,10 +101,21 @@ public class HistoryReceiver {
|
|||
}
|
||||
|
||||
enum Status {
|
||||
IDLE,
|
||||
SYNCING,
|
||||
BUSY,
|
||||
SYNCED
|
||||
IDLE(R.string.insight_history_idle),
|
||||
SYNCING(R.string.insight_history_syncing),
|
||||
BUSY(R.string.insight_history_busy),
|
||||
SYNCED(R.string.insight_history_synced);
|
||||
|
||||
private final int string_id;
|
||||
|
||||
Status(int string_id) {
|
||||
this.string_id = string_id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MainApp.instance().getString(string_id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.PumpInsight.history;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers;
|
||||
|
||||
/**
|
||||
|
@ -15,7 +17,7 @@ public class LiveHistory {
|
|||
|
||||
public static String getStatus() {
|
||||
if (status.equals("")) return status;
|
||||
return status + " " + Helpers.niceTimeScalar(Helpers.msSince(status_time)) + " ago";
|
||||
return status + " " + Helpers.niceTimeScalar(Helpers.msSince(status_time)) + " " + gs(R.string.ago);
|
||||
}
|
||||
|
||||
public static long getStatusTime() {
|
||||
|
@ -29,4 +31,7 @@ public class LiveHistory {
|
|||
}
|
||||
}
|
||||
|
||||
private static String gs(int id) {
|
||||
return MainApp.instance().getString(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 24/01/2018.
|
||||
|
@ -95,28 +96,32 @@ public class Helpers {
|
|||
}
|
||||
|
||||
public static String niceTimeScalar(long t) {
|
||||
String unit = "second";
|
||||
String unit = gs(R.string.second);
|
||||
t = t / 1000;
|
||||
if (t > 59) {
|
||||
unit = "minute";
|
||||
unit = gs(R.string.minute);
|
||||
t = t / 60;
|
||||
if (t > 59) {
|
||||
unit = "hour";
|
||||
unit = gs(R.string.hour);
|
||||
t = t / 60;
|
||||
if (t > 24) {
|
||||
unit = "day";
|
||||
unit = gs(R.string.day);
|
||||
t = t / 24;
|
||||
if (t > 28) {
|
||||
unit = "week";
|
||||
unit = gs(R.string.week);
|
||||
t = t / 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t != 1) unit = unit + "s";
|
||||
if (t != 1) unit = unit + gs(R.string.time_plural);
|
||||
return qs((double) t, 0) + " " + unit;
|
||||
}
|
||||
|
||||
private static String gs(int id) {
|
||||
return MainApp.instance().getString(id);
|
||||
}
|
||||
|
||||
public static String qs(double x, int digits) {
|
||||
|
||||
if (digits == -1) {
|
||||
|
|
|
@ -863,5 +863,43 @@
|
|||
<string name="extendedbolusdeliveryerror">Extended bolus delivery error</string>
|
||||
<string name="insightpump_shortname">Insight</string>
|
||||
<string name="insightpump">Insight Pump</string>
|
||||
<string name="status_no_colon">Status</string>
|
||||
<string name="changed">Changed</string>
|
||||
<string name="pump_stopped_uppercase">PUMP STOPPED</string>
|
||||
<string name="status_updated">Status Updated</string>
|
||||
<string name="ago">ago</string>
|
||||
<string name="with">with</string>
|
||||
<string name="insight_active_tbr">Active TBR</string>
|
||||
<string name="insight_min_left">min left</string>
|
||||
<string name="log_book">Log book</string>
|
||||
<string name="insight_last_completed_action">Last Completed Action</string>
|
||||
<string name="insight_min">min</string>
|
||||
<string name="insight_remaining_over">remaining over</string>
|
||||
<string name="insight_total_with">total with</string>
|
||||
<string name="insight_upfront_with">upfront with</string>
|
||||
<string name="insight_stay_always_connected">Stay always connected</string>
|
||||
<string name="insight_use_real_tbr_cancels">Use Real TBR cancels</string>
|
||||
<string name="insight_actually_cancel_tbr_summary">Actually cancel a TBR (creates pump alarm) instead of setting 90% or 110% TBR for 15 minutes</string>
|
||||
<string name="insight_history_idle">IDLE</string>
|
||||
<string name="insight_history_syncing">SYNCING</string>
|
||||
<string name="insight_history_busy">BUSY</string>
|
||||
<string name="insight_history_synced">SYNCED</string>
|
||||
<string name="insight_startup_uppercase">STARTUP</string>
|
||||
<string name="insight_needs">needs</string>
|
||||
<string name="insight_not_connected_to_companion_app">Not connected to companion app!</string>
|
||||
<string name="insight_companion_app_not_installed">Companion app does not appear to be installed!</string>
|
||||
<string name="insight_incompatible_compantion_app_we_need_version">Incompatible companion app, we need version</string>
|
||||
<string name="insight_unknown">Unknown</string>
|
||||
<string name="insight_waiting_for_code">Waiting for code confirmation</string>
|
||||
<string name="insight_code_rejected">Code rejected</string>
|
||||
<string name="insight_app_binding">App binding</string>
|
||||
<string name="insight_not_authorized">Not authorized</string>
|
||||
<string name="insight_incompatible">Incompatible</string>
|
||||
<string name="second">second</string>
|
||||
<string name="minute">minute</string>
|
||||
<string name="hour">hour</string>
|
||||
<string name="day">day</string>
|
||||
<string name="week">week</string>
|
||||
<string name="time_plural">s</string>
|
||||
</resources>
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_always_connected"
|
||||
android:title="Stay always connected" />
|
||||
android:title="@string/insight_stay_always_connected" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_real_tbr_cancel"
|
||||
android:title="Use Real TBR cancels"
|
||||
android:summary="Actually cancel a TBR (creates pump alarm) instead of setting 90% or 110% TBR for 15 minutes"/>
|
||||
android:title="@string/insight_use_real_tbr_cancels"
|
||||
android:summary="@string/insight_actually_cancel_tbr_summary"/>
|
||||
</PreferenceScreen >
|
Loading…
Reference in a new issue