diff --git a/app/build.gradle b/app/build.gradle index ba038fbfce..0ab6421024 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,7 +109,7 @@ android { defaultConfig { multiDexEnabled true versionCode 1500 - version "2.8.2.3-dev" + version "2.8.2.5-dev" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 00fe3c688f..65bd45444c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -1,6 +1,8 @@ package info.nightscout.androidaps.dialogs import android.os.Bundle +import android.text.Editable +import android.text.TextWatcher import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -10,22 +12,30 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.database.AppRepository +import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.ValueWithUnit +import info.nightscout.androidaps.database.transactions.InsertAndCancelCurrentTemporaryTargetTransaction import info.nightscout.androidaps.databinding.DialogProfileswitchBinding +import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.Config +import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.HardLimits import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.resources.ResourceHelper import io.reactivex.disposables.CompositeDisposable +import io.reactivex.rxkotlin.plusAssign import java.text.DecimalFormat import java.util.* +import java.util.concurrent.TimeUnit import javax.inject.Inject class ProfileSwitchDialog : DialogFragmentWithDate() { @@ -38,6 +48,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { @Inject lateinit var config: Config @Inject lateinit var hardLimits: HardLimits @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var defaultValueHelper: DefaultValueHelper private var profileIndex: Int? = null @@ -49,6 +60,17 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { // onDestroyView. private val binding get() = _binding!! + private val textWatcher: TextWatcher = object : TextWatcher { + override fun afterTextChanged(s: Editable) { + val isDuration = binding.duration.value > 0 + val isLowerPercentage = binding.percentage.value < 100 + binding.ttLayout.visibility = (isDuration && isLowerPercentage).toVisibility() + } + + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {} + override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {} + } + override fun onSaveInstanceState(savedInstanceState: Bundle) { super.onSaveInstanceState(savedInstanceState) savedInstanceState.putDouble("duration", binding.duration.value) @@ -70,9 +92,11 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { super.onViewCreated(view, savedInstanceState) binding.duration.setParams(savedInstanceState?.getDouble("duration") - ?: 0.0, 0.0, Constants.MAX_PROFILE_SWITCH_DURATION, 10.0, DecimalFormat("0"), false, binding.okcancel.ok) + ?: 0.0, 0.0, Constants.MAX_PROFILE_SWITCH_DURATION, 10.0, DecimalFormat("0"), false, binding.okcancel.ok, + textWatcher) binding.percentage.setParams(savedInstanceState?.getDouble("percentage") - ?: 100.0, Constants.CPP_MIN_PERCENTAGE.toDouble(), Constants.CPP_MAX_PERCENTAGE.toDouble(), 5.0, DecimalFormat("0"), false, binding.okcancel.ok) + ?: 100.0, Constants.CPP_MIN_PERCENTAGE.toDouble(), Constants.CPP_MAX_PERCENTAGE.toDouble(), 5.0, + DecimalFormat("0"), false, binding.okcancel.ok, textWatcher) binding.timeshift.setParams(savedInstanceState?.getDouble("timeshift") ?: 0.0, Constants.CPP_MIN_TIMESHIFT.toDouble(), Constants.CPP_MAX_TIMESHIFT.toDouble(), 1.0, DecimalFormat("0"), false, binding.okcancel.ok) @@ -104,6 +128,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { binding.reuselayout.visibility = View.GONE } } + binding.ttLayout.visibility = View.GONE } override fun onDestroyView() { @@ -135,6 +160,12 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { if (eventTimeChanged) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) + val isTT = binding.duration.value > 0 && binding.percentage.value < 100 && binding.tt.isChecked + val target = defaultValueHelper.determineActivityTT() + val units = profileFunction.getUnits() + if (isTT) + actions.add(resourceHelper.gs(R.string.careportal_temporarytarget) + ": " + resourceHelper.gs(R.string.activity)) + activity?.let { activity -> val ps = profileFunction.buildProfileSwitch(profileStore, profileName, duration, percent, timeShift, eventTime) val validity = ProfileSealed.PS(ps).isValid(resourceHelper.gs(R.string.careportal_profileswitch), activePlugin.activePump, config, resourceHelper, rxBus, hardLimits) @@ -154,6 +185,24 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { ValueWithUnit.Percent(percent), ValueWithUnit.Hour(timeShift).takeIf { timeShift != 0 }, ValueWithUnit.Minute(duration).takeIf { duration != 0 }) + if (isTT) { + disposable += repository.runTransactionForResult( + InsertAndCancelCurrentTemporaryTargetTransaction( + timestamp = eventTime, + duration = TimeUnit.MINUTES.toMillis(duration.toLong()), + reason = TemporaryTarget.Reason.ACTIVITY, + lowTarget = Profile.toMgdl(target, profileFunction.getUnits()), + highTarget = Profile.toMgdl(target, profileFunction.getUnits()) + ) + ).subscribe({ result -> + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } + }, { + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) + }) + uel.log(Action.TT, Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason( + TemporaryTarget.Reason.ACTIVITY), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration)) + } }) else { OKDialog.show( diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt index 42281c32c3..548625c396 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt @@ -166,6 +166,9 @@ class PluginStore @Inject constructor( override val activeOverview: Overview get() = getSpecificPluginsListByInterface(Overview::class.java).first() as Overview + override val activeSafety: Safety + get() = getSpecificPluginsListByInterface(Safety::class.java).first() as Safety + override fun getPluginsList(): ArrayList = ArrayList(plugins) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt index 32fa6abf91..6c8523b482 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.constraints.safety import dagger.android.HasAndroidInjector import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.R +import info.nightscout.androidaps.extensions.* import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger @@ -20,6 +21,7 @@ import info.nightscout.androidaps.utils.Round import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP +import org.json.JSONObject import javax.inject.Inject import javax.inject.Singleton import kotlin.math.floor @@ -49,7 +51,7 @@ class SafetyPlugin @Inject constructor( .pluginName(R.string.safety) .preferencesId(R.xml.pref_safety), aapsLogger, resourceHelper, injector -), Constraints { +), Constraints, Safety { /** * Constraints interface @@ -193,4 +195,16 @@ class SafetyPlugin @Inject constructor( if (apsMode == "lgs") maxIob.setIfSmaller(aapsLogger, HardLimits.MAX_IOB_LGS, String.format(resourceHelper.gs(R.string.limitingiob), HardLimits.MAX_IOB_LGS, resourceHelper.gs(R.string.lowglucosesuspend)), this) return maxIob } + + override fun configuration(): JSONObject = + JSONObject() + .putString(R.string.key_age, sp, resourceHelper) + .putDouble(R.string.key_treatmentssafety_maxbolus, sp, resourceHelper) + .putDouble(R.string.key_treatmentssafety_maxcarbs, sp, resourceHelper) + + override fun applyConfiguration(configuration: JSONObject) { + configuration.storeString(R.string.key_age, sp, resourceHelper) + configuration.storeDouble(R.string.key_treatmentssafety_maxbolus, sp, resourceHelper) + configuration.storeDouble(R.string.key_treatmentssafety_maxcarbs, sp, resourceHelper) + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt index 24433dfadc..3a56f7bcee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt @@ -176,6 +176,7 @@ class OverviewPlugin @Inject constructor( override fun configuration(): JSONObject = JSONObject() + .putInt(R.string.key_units, sp, resourceHelper) .putString(R.string.key_quickwizard, sp, resourceHelper) .putInt(R.string.key_eatingsoon_duration, sp, resourceHelper) .putDouble(R.string.key_eatingsoon_target, sp, resourceHelper) @@ -202,6 +203,7 @@ class OverviewPlugin @Inject constructor( override fun applyConfiguration(configuration: JSONObject) { configuration + .storeInt(R.string.key_units, sp, resourceHelper) .storeString(R.string.key_quickwizard, sp, resourceHelper) .storeInt(R.string.key_eatingsoon_duration, sp, resourceHelper) .storeDouble(R.string.key_eatingsoon_target, sp, resourceHelper) diff --git a/app/src/main/res/layout/dialog_profileswitch.xml b/app/src/main/res/layout/dialog_profileswitch.xml index b9efbfc06e..aa5bdf6b99 100644 --- a/app/src/main/res/layout/dialog_profileswitch.xml +++ b/app/src/main/res/layout/dialog_profileswitch.xml @@ -210,6 +210,33 @@ + + + + + + + + diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/versionChecker/AllowedVersionsTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/versionChecker/AllowedVersionsTest.kt new file mode 100644 index 0000000000..d472f0ebc2 --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/versionChecker/AllowedVersionsTest.kt @@ -0,0 +1,20 @@ +package info.nightscout.androidaps.plugins.constraints.versionChecker + +import org.junit.Assert.* +import org.junit.Test + +class AllowedVersionsTest { + + @Test + fun generateSupportedVersionsTest() { + val definition = AllowedVersions().generateSupportedVersions() + assertNull(AllowedVersions().findByApi(definition, 0)) + assertFalse(AllowedVersions().findByApi(definition, 1)?.has("supported") ?: true) + assertFalse(AllowedVersions().findByApi(definition, 23)?.has("supported") ?: true) + assertEquals("2.6.2", AllowedVersions().findByApi(definition, 24)?.getString("supported")) + assertEquals("2.6.2", AllowedVersions().findByApi(definition, 25)?.getString("supported")) + assertEquals("2.8.2", AllowedVersions().findByApi(definition, 26)?.getString("supported")) + assertEquals("2.8.2", AllowedVersions().findByApi(definition, 27)?.getString("supported")) + assertEquals("2.8.2", AllowedVersions().findByApi(definition, 28)?.getString("supported")) + } +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/ActivePlugin.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ActivePlugin.kt index 3f8545afb5..da514c7dd9 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/ActivePlugin.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ActivePlugin.kt @@ -46,6 +46,12 @@ interface ActivePlugin { */ val activeOverview: Overview + /** + * Currently selected Safety plugin + * Always SafetyPlugin + */ + val activeSafety: Safety + /** * List of all registered plugins */ diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/Safety.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/Safety.kt new file mode 100644 index 0000000000..d3bc26ae30 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/Safety.kt @@ -0,0 +1,3 @@ +package info.nightscout.androidaps.interfaces + +interface Safety : ConfigExportImport \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt index 7b5cb9c382..709ed1b71e 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt @@ -36,12 +36,14 @@ class RunningConfiguration @Inject constructor( val sensitivityInterface = activePlugin.activeSensitivity val pumpInterface = activePlugin.activePump val overviewInterface = activePlugin.activeOverview + val safetyInterface = activePlugin.activeSafety json.put("insulin", insulinInterface.id.value) json.put("insulinConfiguration", insulinInterface.configuration()) json.put("sensitivity", sensitivityInterface.id.value) json.put("sensitivityConfiguration", sensitivityInterface.configuration()) json.put("overviewConfiguration", overviewInterface.configuration()) + json.put("safetyConfiguration", safetyInterface.configuration()) json.put("pump", pumpInterface.model().description) } catch (e: JSONException) { aapsLogger.error("Unhandled exception", e) @@ -88,5 +90,8 @@ class RunningConfiguration @Inject constructor( if (configuration.has("overviewConfiguration")) activePlugin.activeOverview.applyConfiguration(configuration.getJSONObject("overviewConfiguration")) + + if (configuration.has("safetyConfiguration")) + activePlugin.activeSafety.applyConfiguration(configuration.getJSONObject("safetyConfiguration")) } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/AllowedVersions.kt b/core/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/AllowedVersions.kt new file mode 100644 index 0000000000..ae320cf929 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/AllowedVersions.kt @@ -0,0 +1,45 @@ +package info.nightscout.androidaps.plugins.constraints.versionChecker + +import org.json.JSONArray +import org.json.JSONException +import org.json.JSONObject + +class AllowedVersions { + + fun generateSupportedVersions(): String = + JSONArray() + .put(JSONObject().apply { + put("minAndroid", 1) // 1.0 + put("maxAndroid", 23) // 6.0.1 + }) + .put(JSONObject().apply { + put("minAndroid", 24) // 7.0 + put("maxAndroid", 25) // 7.1.2 + put("supported", "2.6.2") + }) + .put(JSONObject().apply { + put("minAndroid", 26) // 8.0 + put("maxAndroid", 27) // 8.1 + put("supported", "2.8.2") + }) + .put(JSONObject().apply { + put("minAndroid", 28) // 9.0 + put("maxAndroid", 99) + put("supported", "2.8.2") + }) + .toString() + + fun findByApi(definition: String?, api: Int): JSONObject? { + if (definition == null) return null + try { + val array = JSONArray(definition) + for (i in 0 until array.length()) { + val record = array[i] as JSONObject + if (api in record.getInt("minAndroid")..record.getInt("maxAndroid")) return record + } + } catch (e: JSONException) { + } + return null + } + +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerUtils.kt b/core/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerUtils.kt index e58fce4dd8..9d8d720d98 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerUtils.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerUtils.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.plugins.constraints.versionChecker import android.content.Context +import android.os.Build import info.nightscout.androidaps.core.R import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.logging.AAPSLogger @@ -53,8 +54,8 @@ class VersionCheckerUtils @Inject constructor( private fun checkVersion() = if (isConnected()) { Thread { try { - val version: String? = - findVersion(URL("https://raw.githubusercontent.com/nightscout/AndroidAPS/master/app/build.gradle").readText()) + val definition: String = URL("https://raw.githubusercontent.com/nightscout/AndroidAPS/versions/definition.json").readText() + val version: String? = AllowedVersions().findByApi(definition, Build.VERSION.SDK_INT)?.optString("supported") compareWithCurrentVersion(version, config.VERSION_NAME) } catch (e: IOException) { aapsLogger.error(LTag.CORE, "Github master version check error: $e") diff --git a/gradle/android_dependencies.gradle b/gradle/android_dependencies.gradle index 264cf88b77..a712510094 100644 --- a/gradle/android_dependencies.gradle +++ b/gradle/android_dependencies.gradle @@ -1,7 +1,7 @@ android { compileSdkVersion 30 defaultConfig { - minSdkVersion 26 + minSdkVersion 28 targetSdkVersion 28 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightFragment.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightFragment.java index bf89837dda..4a16e1aee0 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightFragment.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightFragment.java @@ -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 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 statusItems) { if (localInsightPlugin.getActiveBoluses() == null) return; for (ActiveBolus activeBolus : localInsightPlugin.getActiveBoluses()) { diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index ead54ec5e3..c93a7e895f 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -190,6 +190,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai private List 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) diff --git a/insight/src/main/res/values/strings.xml b/insight/src/main/res/values/strings.xml index dd12e644a3..ba021a8b99 100644 --- a/insight/src/main/res/values/strings.xml +++ b/insight/src/main/res/values/strings.xml @@ -21,6 +21,8 @@ %1$d%% for %2$d / %3$d min Multiwave bolus %1$.2f / %2$.2f U for %3$d min + Last Bolus + %1$.1f %2$s (%3$s) Searching for devices… Pairing completed Do the codes displayed on this device and on your pump match?