This commit is contained in:
Milos Kozak 2021-10-05 20:38:19 +02:00
commit 4239e38547
4 changed files with 33 additions and 2 deletions

View file

@ -109,7 +109,7 @@ android {
defaultConfig {
multiDexEnabled true
versionCode 1500
version "2.8.2.3-dev"
version "2.8.2.4-dev"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'

View file

@ -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()) {

View file

@ -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)

View file

@ -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>