diff --git a/app/src/main/assets/OpenAPSSMB/determine-basal.js b/app/src/main/assets/OpenAPSSMB/determine-basal.js index c4930b7789..13a220e528 100644 --- a/app/src/main/assets/OpenAPSSMB/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMB/determine-basal.js @@ -151,7 +151,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } } //cherry pick from oref upstream dev cb8e94990301277fb1016c778b4e9efa55a6edbc - if (bg <= 10 || bg === 38 || noise >= 3 || minAgo > 12 || minAgo < -5 || ( bg > 60 && glucose_status.delta == 0 && glucose_status.short_avgdelta > -1 && glucose_status.short_avgdelta < 1 && glucose_status.long_avgdelta > -1 && glucose_status.long_avgdelta < 1 ) ) { + if (bg <= 10 || bg === 38 || noise >= 3 || minAgo > 12 || minAgo < -5 || ( bg > 60 && glucose_status.delta == 0 && glucose_status.short_avgdelta > -1 && glucose_status.short_avgdelta < 1 && glucose_status.long_avgdelta > -1 && glucose_status.long_avgdelta < 1 ) && !isSaveCgmSource ) { if (currenttemp.rate > basal) { // high temp is running rT.reason += ". Replacing high temp basal of "+currenttemp.rate+" with neutral temp of "+basal; rT.deliverAt = deliverAt; diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index 109197e91a..cda4b6e0be 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -237,18 +237,21 @@ class LoopDialog : DaggerDialogFragment() { val profile = profileFunction.getProfile() ?: return true when (v.id) { R.id.overview_closeloop -> { + aapsLogger.debug("USER ENTRY: CLOSED LOOP MODE") sp.putString(R.string.key_aps_mode, "closed") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop))) return true } R.id.overview_lgsloop -> { + aapsLogger.debug("USER ENTRY: LGS LOOP MODE") sp.putString(R.string.key_aps_mode, "lgs") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) return true } R.id.overview_openloop -> { + aapsLogger.debug("USER ENTRY: OPEN LOOP MODE") sp.putString(R.string.key_aps_mode, "open") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) return true diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java index a94581ca94..e42b139f3e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java @@ -19,7 +19,6 @@ import java.nio.charset.StandardCharsets; import javax.annotation.Nullable; import javax.inject.Inject; -import info.nightscout.androidaps.plugins.general.openhumans.OpenHumansUploader; import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; @@ -28,13 +27,14 @@ import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.interfaces.ActivePluginProvider; +import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback; import info.nightscout.androidaps.plugins.aps.loop.ScriptReader; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; -import info.nightscout.androidaps.interfaces.ProfileFunction; +import info.nightscout.androidaps.plugins.general.openhumans.OpenHumansUploader; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; @@ -73,10 +73,6 @@ public class DetermineBasalAdapterSMBJS { private String storedGlucoseStatus = null; private String storedProfile = null; private String storedMeal_data = null; - private String storedAutosens_data = null; - private String storedMicroBolusAllowed = null; - private String storedSMBAlwaysAllowed = null; - private String storedCurrentTime = null; private String scriptDebug = ""; @@ -102,13 +98,13 @@ public class DetermineBasalAdapterSMBJS { aapsLogger.debug(LTag.APS, "Profile: " + (storedProfile = mProfile.toString())); aapsLogger.debug(LTag.APS, "Meal data: " + (storedMeal_data = mMealData.toString())); if (mAutosensData != null) - aapsLogger.debug(LTag.APS, "Autosens data: " + (storedAutosens_data = mAutosensData.toString())); + aapsLogger.debug(LTag.APS, "Autosens data: " + mAutosensData.toString()); else - aapsLogger.debug(LTag.APS, "Autosens data: " + (storedAutosens_data = "undefined")); + aapsLogger.debug(LTag.APS, "Autosens data: " + "undefined"); aapsLogger.debug(LTag.APS, "Reservoir data: " + "undefined"); - aapsLogger.debug(LTag.APS, "MicroBolusAllowed: " + (storedMicroBolusAllowed = "" + mMicrobolusAllowed)); - aapsLogger.debug(LTag.APS, "SMBAlwaysAllowed: " + (storedSMBAlwaysAllowed = "" + mSMBAlwaysAllowed)); - aapsLogger.debug(LTag.APS, "CurrentTime: " + (storedCurrentTime = "" + mCurrentTime)); + aapsLogger.debug(LTag.APS, "MicroBolusAllowed: " + mMicrobolusAllowed); + aapsLogger.debug(LTag.APS, "SMBAlwaysAllowed: " + mSMBAlwaysAllowed); + aapsLogger.debug(LTag.APS, "CurrentTime: " + mCurrentTime); aapsLogger.debug(LTag.APS, "isSaveCgmSource: " + mIsSaveCgmSource); @@ -151,9 +147,10 @@ public class DetermineBasalAdapterSMBJS { makeParam(mAutosensData, rhino, scope), makeParam(mMealData, rhino, scope), setTempBasalFunctionsObj, - new Boolean(mMicrobolusAllowed), + Boolean.valueOf(mMicrobolusAllowed), makeParam(null, rhino, scope), // reservoir data as undefined - new Long(mCurrentTime) + Long.valueOf(mCurrentTime), + Boolean.valueOf(mIsSaveCgmSource) }; @@ -213,14 +210,6 @@ public class DetermineBasalAdapterSMBJS { return storedMeal_data; } - String getAutosensDataParam() { - return storedAutosens_data; - } - - String getMicroBolusAllowedParam() { - return storedMicroBolusAllowed; - } - String getScriptDebug() { return scriptDebug; } @@ -243,7 +232,6 @@ public class DetermineBasalAdapterSMBJS { boolean isSaveCgmSource ) throws JSONException { - String units = profile.getUnits(); PumpInterface pump = activePluginProvider.getActivePump(); Double pumpbolusstep = pump.getPumpDescription().bolusStep; mProfile = new JSONObject(); @@ -267,8 +255,8 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("low_temptarget_lowers_sensitivity", false); - mProfile.put("sensitivity_raises_target", sp.getBoolean(R.string.key_sensitivity_raises_target,SMBDefaults.sensitivity_raises_target)); - mProfile.put("resistance_lowers_target", sp.getBoolean(R.string.key_resistance_lowers_target,SMBDefaults.resistance_lowers_target)); + mProfile.put("sensitivity_raises_target", sp.getBoolean(R.string.key_sensitivity_raises_target, SMBDefaults.sensitivity_raises_target)); + mProfile.put("resistance_lowers_target", sp.getBoolean(R.string.key_resistance_lowers_target, SMBDefaults.resistance_lowers_target)); mProfile.put("adv_target_adjustments", SMBDefaults.adv_target_adjustments); mProfile.put("exercise_mode", SMBDefaults.exercise_mode); mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target); @@ -364,14 +352,12 @@ public class DetermineBasalAdapterSMBJS { if (jsonObject == null) return Undefined.instance; - Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), (context, scriptable, scriptable1, objects) -> objects[1]); - return param; + return NativeJSON.parse(rhino, scope, jsonObject.toString(), (context, scriptable, scriptable1, objects) -> objects[1]); } private Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) { //Object param = NativeJSON.parse(rhino, scope, "{myarray: " + jsonArray.toString() + " }", new Callable() { - Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), (context, scriptable, scriptable1, objects) -> objects[1]); - return param; + return NativeJSON.parse(rhino, scope, jsonArray.toString(), (context, scriptable, scriptable1, objects) -> objects[1]); } private String readFile(String filename) throws IOException { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt index db572ade8e..10084a9110 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt @@ -70,7 +70,7 @@ class EditEventDialog : DialogFragmentWithDate() { binding.okcancel.ok.visibility = (!event.readOnly).toVisibility() binding.inputEventTitle.setText(event.title) - binding.inputEventTitle.isFocusable = false + binding.inputEventTitle.isFocusable = !event.readOnly binding.triggerDescription.text = event.trigger.friendlyDescription() binding.editTrigger.visibility = (!event.readOnly).toVisibility() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 8609a19c33..28bd08d3d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -289,12 +289,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList R.id.overview_temptarget -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { TempTargetDialog().show(childFragmentManager, "Overview") }) R.id.overview_activeprofile -> { - val args = Bundle() - args.putLong("time", DateUtil.now()) - args.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal) - val pvd = ProfileViewerDialog() - pvd.arguments = args - pvd.show(childFragmentManager, "ProfileViewDialog") + ProfileViewerDialog().also { pvd -> + pvd.arguments = Bundle().also { + it.putLong("time", DateUtil.now()) + it.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal) + } + }.show(childFragmentManager, "ProfileViewDialog") } R.id.overview_cgmbutton -> { @@ -329,24 +329,26 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList val lastRun = loopPlugin.lastRun loopPlugin.invoke("Accept temp button", false) if (lastRun?.lastAPSRun != null && lastRun.constraintsProcessed?.isChangeRequested == true) { - OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned() - ?: "".toSpanned(), { - aapsLogger.debug("USER ENTRY: ACCEPT TEMP BASAL") - overview_accepttempbutton?.visibility = View.GONE - (context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID) - actionStringHandler.handleInitiate("cancelChangeRequest") - loopPlugin.acceptChangeRequest() + protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { + OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned() + ?: "".toSpanned(), { + aapsLogger.debug("USER ENTRY: ACCEPT TEMP BASAL") + overview_accepttempbutton?.visibility = View.GONE + (context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID) + actionStringHandler.handleInitiate("cancelChangeRequest") + loopPlugin.acceptChangeRequest() + }) }) } } } R.id.overview_apsmode -> { - val args = Bundle() - args.putInt("showOkCancel", 1) // 1-> true - val pvd = LoopDialog() - pvd.arguments = args - pvd.show(childFragmentManager, "Overview") + protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { + LoopDialog().also { dialog -> + dialog.arguments = Bundle().also { it.putInt("showOkCancel", 1) } + }.show(childFragmentManager, "Overview") + }) } } } @@ -374,11 +376,13 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } R.id.overview_apsmode -> { - val args = Bundle() - args.putInt("showOkCancel", 0) // 0-> false - val pvd = LoopDialog() - pvd.arguments = args - pvd.show(childFragmentManager, "Overview") + activity?.let { activity -> + protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { + LoopDialog().also { dialog -> + dialog.arguments = Bundle().also { it.putInt("showOkCancel", 0) } + }.show(childFragmentManager, "Overview") + }) + } } R.id.overview_temptarget -> v.performClick() diff --git a/app/src/main/res/layout/overview_info_layout.xml b/app/src/main/res/layout/overview_info_layout.xml index 6fc79c29f5..0aca9574ca 100644 --- a/app/src/main/res/layout/overview_info_layout.xml +++ b/app/src/main/res/layout/overview_info_layout.xml @@ -162,18 +162,20 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginBottom="-4dp" + android:visibility="gone" app:srcCompat="@drawable/ic_loop_closed" /> + android:textStyle="bold" + android:visibility="gone" /> %1$d%%\nDuration: %2$s h]]> - %1$s U]]> Change battery. Set time/date. Contact Accu-Chek support. %1$d%%
Duration: %2$s h]]>
%1$s U
Delivered: %2$s U]]>
- Insert cartridge. Change cartridge. Change battery. @@ -20,7 +18,6 @@ Check pump status. Set battery type. Set cartridge type. - Change battery and cartridge. Change cartridge. Change language. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9efcb58784..a330a5ee4d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1425,7 +1425,7 @@ You have high glycemia. Instead of eating now it\'s recommended to wait for better glycemia. Do you want to do a correction bolus now and remind you when it\'s time to eat? In this case no carbs will be recorded and you must use wizard again when we remind you. use_bolus_advisor Enable bolus advisor - Use reminder to start eating instead of wizard during high glycemia + Use reminder to start eating later instead of wizard result during high glycemia ("pre-bolus") Time to eat!\nRun Bolus wizard and do calculation again. Time to eat diff --git a/app/src/main/res/xml/pref_openapssmb.xml b/app/src/main/res/xml/pref_openapssmb.xml index 388c523df9..1f1be8cb42 100644 --- a/app/src/main/res/xml/pref_openapssmb.xml +++ b/app/src/main/res/xml/pref_openapssmb.xml @@ -2,10 +2,10 @@ - + + android:title="@string/openapssmb" + app:initialExpandedChildrenCount="0"> + android:title="@string/smbmaxminutes_summary" + validate:maxNumber="120" + validate:minNumber="15" + validate:testType="numericRange" /> + android:title="@string/sensitivity_raises_target_title" /> + android:title="@string/resistance_lowers_target_title" /> - + + validate:testType="numericRange" /> - protectionCheck.queryProtection( - activity, ProtectionCheck.Protection.PREFERENCES, - UIRunnable(Runnable { startActivity(Intent(context, PodManagementActivity::class.java)) }) - ) + context?.let { context -> + protectionCheck.queryProtection( + activity, ProtectionCheck.Protection.PREFERENCES, + UIRunnable { startActivity(Intent(context, PodManagementActivity::class.java)) } + ) + } } } else { displayNotConfiguredDialog() @@ -514,10 +516,10 @@ class OmnipodOverviewFragment : DaggerFragment() { private fun displayNotConfiguredDialog() { context?.let { - UIRunnable(Runnable { + UIRunnable { OKDialog.show(it, resourceHelper.gs(R.string.omnipod_warning), resourceHelper.gs(R.string.omnipod_error_operation_not_possible_no_configuration), null) - }).run() + }.run() } } @@ -534,9 +536,9 @@ class OmnipodOverviewFragment : DaggerFragment() { private fun displayOkDialog(title: String, message: String) { context?.let { - UIRunnable(Runnable { + UIRunnable { OKDialog.show(it, title, message, null) - }).run() + }.run() } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java index 271a769d46..250a0a69b8 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/tasks/InitializePumpManagerTask.java @@ -65,6 +65,11 @@ public class InitializePumpManagerTask extends ServiceTask { lastGoodFrequency = rileyLinkServiceData.lastGoodFrequency; } + /* FIXME this can apparently crash: + Fatal Exception: java.lang.ClassCastException + info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin + cannot be cast to info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice + */ RileyLinkCommunicationManager rileyLinkCommunicationManager = ((RileyLinkPumpDevice) activePlugin.getActivePump()).getRileyLinkService().getDeviceCommunicationManager(); if (activePlugin.getActivePump().manufacturer() == ManufacturerType.Medtronic) { diff --git a/wear/src/main/res/drawable/digitalstyle_bg_minimal_rect.png b/wear/src/main/res/drawable/digitalstyle_bg_minimal_rect.png new file mode 100644 index 0000000000..261f6ab723 Binary files /dev/null and b/wear/src/main/res/drawable/digitalstyle_bg_minimal_rect.png differ diff --git a/wear/src/main/res/drawable/digitalstyle_bg_minimal_round.png b/wear/src/main/res/drawable/digitalstyle_bg_minimal_round.png new file mode 100644 index 0000000000..261f6ab723 Binary files /dev/null and b/wear/src/main/res/drawable/digitalstyle_bg_minimal_round.png differ diff --git a/wear/src/main/res/drawable/digitalstyle_bg_none_rect.png b/wear/src/main/res/drawable/digitalstyle_bg_none_rect.png new file mode 100644 index 0000000000..209a438645 Binary files /dev/null and b/wear/src/main/res/drawable/digitalstyle_bg_none_rect.png differ diff --git a/wear/src/main/res/drawable/digitalstyle_bg_none_round.png b/wear/src/main/res/drawable/digitalstyle_bg_none_round.png new file mode 100644 index 0000000000..209a438645 Binary files /dev/null and b/wear/src/main/res/drawable/digitalstyle_bg_none_round.png differ diff --git a/wear/src/main/res/drawable/digitalstyle_bg_shape_rect.png b/wear/src/main/res/drawable/digitalstyle_bg_shape_rect.png new file mode 100644 index 0000000000..a0acd812f6 Binary files /dev/null and b/wear/src/main/res/drawable/digitalstyle_bg_shape_rect.png differ diff --git a/wear/src/main/res/drawable/digitalstyle_bg_shape_round.png b/wear/src/main/res/drawable/digitalstyle_bg_shape_round.png new file mode 100644 index 0000000000..e8cfa435b7 Binary files /dev/null and b/wear/src/main/res/drawable/digitalstyle_bg_shape_round.png differ