Merge pull request #712 from Philoul/Fix/InsightFragmentImprovement
Insight Fragment improvement (Add Last Connected ago and last bolus)
This commit is contained in:
commit
e3374271b6
|
@ -178,6 +178,7 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick
|
|||
getTDDItems(statusItems);
|
||||
getBaseBasalRateItem(statusItems);
|
||||
getTBRItem(statusItems);
|
||||
getLastBolusItem(statusItems);
|
||||
getBolusItems(statusItems);
|
||||
for (int i = 0; i < statusItems.size(); i++) {
|
||||
statusItemContainer.addView(statusItems.get(i));
|
||||
|
@ -239,7 +240,16 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick
|
|||
default:
|
||||
long lastConnection = localInsightPlugin.getConnectionService().getLastConnected();
|
||||
if (lastConnection == 0) return;
|
||||
statusItems.add(getStatusItem(resourceHelper.gs(R.string.last_connected), dateUtil.timeString(lastConnection)));
|
||||
long agoMsc = System.currentTimeMillis() - lastConnection;
|
||||
double lastConnectionMinAgo = agoMsc / 60d / 1000d;
|
||||
String ago;
|
||||
if (lastConnectionMinAgo < 60) {
|
||||
ago = dateUtil.minAgo(resourceHelper, lastConnection);
|
||||
} else {
|
||||
ago = dateUtil.hourAgo(lastConnection, resourceHelper);
|
||||
}
|
||||
statusItems.add(getStatusItem(resourceHelper.gs(R.string.last_connected),
|
||||
dateUtil.timeString(lastConnection) + " (" + ago + ")"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,6 +316,21 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick
|
|||
resourceHelper.gs(R.string.tbr_formatter, activeTBR.getPercentage(), activeTBR.getInitialDuration() - activeTBR.getRemainingDuration(), activeTBR.getInitialDuration())));
|
||||
}
|
||||
|
||||
private void getLastBolusItem(List<View> statusItems) {
|
||||
if (localInsightPlugin.lastBolusAmount == 0 || localInsightPlugin.lastBolusTimestamp == 0) return;
|
||||
long agoMsc = System.currentTimeMillis() - localInsightPlugin.lastBolusTimestamp;
|
||||
double bolusMinAgo = agoMsc / 60d / 1000d;
|
||||
String unit = resourceHelper.gs(R.string.insulin_unit_shortname);
|
||||
String ago;
|
||||
if (bolusMinAgo < 60) {
|
||||
ago = dateUtil.minAgo(resourceHelper, localInsightPlugin.lastBolusTimestamp);
|
||||
} else {
|
||||
ago = dateUtil.hourAgo(localInsightPlugin.lastBolusTimestamp, resourceHelper);
|
||||
}
|
||||
statusItems.add(getStatusItem(resourceHelper.gs(R.string.insight_last_bolus),
|
||||
resourceHelper.gs(R.string.insight_last_bolus_formater, localInsightPlugin.lastBolusAmount, unit, ago)));
|
||||
}
|
||||
|
||||
private void getBolusItems(List<View> statusItems) {
|
||||
if (localInsightPlugin.getActiveBoluses() == null) return;
|
||||
for (ActiveBolus activeBolus : localInsightPlugin.getActiveBoluses()) {
|
||||
|
|
|
@ -190,6 +190,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai
|
|||
private List<ActiveBolus> activeBoluses;
|
||||
private boolean statusLoaded;
|
||||
private TBROverNotificationBlock tbrOverNotificationBlock;
|
||||
public double lastBolusAmount = 0;
|
||||
public long lastBolusTimestamp = 0L;
|
||||
|
||||
@Inject
|
||||
public LocalInsightPlugin(
|
||||
|
@ -1439,6 +1441,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai
|
|||
bolusID.getId(),
|
||||
PumpType.ACCU_CHEK_INSIGHT,
|
||||
serial);
|
||||
lastBolusTimestamp = bolusID.getTimestamp();
|
||||
lastBolusAmount = event.getImmediateAmount();
|
||||
}
|
||||
if (event.getBolusType() == BolusType.EXTENDED || event.getBolusType() == BolusType.MULTIWAVE) {
|
||||
if (event.getDuration() > 0 && profileFunction.getProfile(bolusID.getTimestamp()) != null)
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
<string name="tbr_formatter">%1$d%% for %2$d / %3$d min</string>
|
||||
<string name="multiwave_bolus">Multiwave bolus</string>
|
||||
<string name="eb_formatter">%1$.2f / %2$.2f U for %3$d min</string>
|
||||
<string name="insight_last_bolus" >Last Bolus</string>
|
||||
<string name="insight_last_bolus_formater" translatable="false">%1$.1f %2$s (%3$s)</string>
|
||||
<string name="searching_for_devices">Searching for devices…</string>
|
||||
<string name="pairing_completed">Pairing completed</string>
|
||||
<string name="code_compare">Do the codes displayed on this device and on your pump match?</string>
|
||||
|
|
Loading…
Reference in a new issue