From b42304d836f8ad5ca57b1dbeb344f1c5fd271e3e Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Mon, 27 Apr 2020 20:09:46 +1200 Subject: [PATCH 01/45] Add skip Neutral Temps preference --- .../plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java | 2 +- app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/pref_openapssmb.xml | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) 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 4d3a0db704..796eb9ef4e 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 @@ -265,7 +265,7 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("exercise_mode", SMBDefaults.exercise_mode); mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target); mProfile.put("maxCOB", SMBDefaults.maxCOB); - mProfile.put("skip_neutral_temps", SMBDefaults.skip_neutral_temps); + mProfile.put("skip_neutral_temps", sp.getBoolean(R.string.key_skip_neutral_temps,SMBDefaults.skip_neutral_temps)); // min_5m_carbimpact is not used within SMB determinebasal //if (mealData.usedMinCarbsImpact > 0) { // mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b0f6821b69..3560471abf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -956,6 +956,9 @@ enableSMB_with_temptarget enableSMB_after_carbs enableSMB_with_high_temptarget + skip_neutral_temps + Skip neutral temp basals + If enabled, sets basal to neutral before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. Enable SMB always Enable SMB always independently to boluses. Possible only with BG source with nice filtering of data like G5 Enable SMB after carbs diff --git a/app/src/main/res/xml/pref_openapssmb.xml b/app/src/main/res/xml/pref_openapssmb.xml index 859a75a82b..09c6ff1221 100644 --- a/app/src/main/res/xml/pref_openapssmb.xml +++ b/app/src/main/res/xml/pref_openapssmb.xml @@ -73,6 +73,12 @@ android:summary="@string/enablesmbaftercarbs_summary" android:title="@string/enablesmbaftercarbs" /> + + Date: Mon, 27 Apr 2020 20:33:41 +1200 Subject: [PATCH 02/45] clarify definition --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3560471abf..c4c96fb42a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -958,7 +958,7 @@ enableSMB_with_high_temptarget skip_neutral_temps Skip neutral temp basals - If enabled, sets basal to neutral before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. + If enabled, it skips setting basal to neutral before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. Enable SMB always Enable SMB always independently to boluses. Possible only with BG source with nice filtering of data like G5 Enable SMB after carbs From 017b6187b5ec92d5e46e4d5ff6153040bf6f029f Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Sun, 3 May 2020 23:09:48 +1200 Subject: [PATCH 03/45] Patch determine basal --- app/src/main/assets/OpenAPSSMB/determine-basal.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/OpenAPSSMB/determine-basal.js b/app/src/main/assets/OpenAPSSMB/determine-basal.js index 00a9c1d0a2..18181d25de 100644 --- a/app/src/main/assets/OpenAPSSMB/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMB/determine-basal.js @@ -897,7 +897,8 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // if not in LGS mode, cancel temps before the top of the hour to reduce beeping/vibration // console.error(profile.skip_neutral_temps, rT.deliverAt.getMinutes()); - if ( profile.skip_neutral_temps && rT.deliverAt.getMinutes() >= 55 ) { + //patch determine basal so skip_neutral_temps works as expected + if ( !profile.skip_neutral_temps && rT.deliverAt.getMinutes() >= 55 ) { rT.reason += "; Canceling temp at " + rT.deliverAt.getMinutes() + "m past the hour. "; return tempBasalFunctions.setTempBasal(0, 0, profile, rT, currenttemp); } From 39d011a4ccdf099286772c1b9b9864efdd88f4f3 Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Sun, 3 May 2020 23:10:46 +1200 Subject: [PATCH 04/45] Move to Medtronic driver --- app/src/main/res/xml/pref_medtronic.xml | 6 ++++++ app/src/main/res/xml/pref_openapssmb.xml | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/xml/pref_medtronic.xml b/app/src/main/res/xml/pref_medtronic.xml index fd9a84ab64..c5f4562e1d 100644 --- a/app/src/main/res/xml/pref_medtronic.xml +++ b/app/src/main/res/xml/pref_medtronic.xml @@ -98,6 +98,12 @@ + + \ No newline at end of file diff --git a/app/src/main/res/xml/pref_openapssmb.xml b/app/src/main/res/xml/pref_openapssmb.xml index 09c6ff1221..859a75a82b 100644 --- a/app/src/main/res/xml/pref_openapssmb.xml +++ b/app/src/main/res/xml/pref_openapssmb.xml @@ -73,12 +73,6 @@ android:summary="@string/enablesmbaftercarbs_summary" android:title="@string/enablesmbaftercarbs" /> - - Date: Sun, 3 May 2020 23:11:29 +1200 Subject: [PATCH 05/45] Use different defaults if using Medtronic Pump --- .../aps/openAPSSMB/DetermineBasalAdapterSMBJS.java | 12 ++++++++++-- .../plugins/aps/openAPSSMB/SMBDefaults.java | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) 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 796eb9ef4e..16949fcb4c 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 @@ -26,10 +26,12 @@ import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.aps.loop.ScriptReader; import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback; +import info.nightscout.androidaps.plugins.common.ManufacturerType; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; @@ -237,7 +239,9 @@ public class DetermineBasalAdapterSMBJS { ) throws JSONException { String units = profile.getUnits(); - Double pumpbolusstep = activePluginProvider.getActivePump().getPumpDescription().bolusStep; + PumpInterface pump = activePluginProvider.getActivePump(); + ManufacturerType manufacturer = pump.manufacturer(); + Double pumpbolusstep = pump.getPumpDescription().bolusStep; mProfile = new JSONObject(); mProfile.put("max_iob", maxIob); @@ -265,7 +269,11 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("exercise_mode", SMBDefaults.exercise_mode); mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target); mProfile.put("maxCOB", SMBDefaults.maxCOB); - mProfile.put("skip_neutral_temps", sp.getBoolean(R.string.key_skip_neutral_temps,SMBDefaults.skip_neutral_temps)); + if (!manufacturer.name().equals("Medtronic")) { + mProfile.put("skip_neutral_temps",SMBDefaults.skip_neutral_temps); + } else { + mProfile.put("skip_neutral_temps", sp.getBoolean(R.string.key_skip_neutral_temps, SMBDefaults.skip_neutral_temps_medtronic)); + } // min_5m_carbimpact is not used within SMB determinebasal //if (mealData.usedMinCarbsImpact > 0) { // mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java index 5f2216b5ae..42eacdbce6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java @@ -38,6 +38,7 @@ public class SMBDefaults { // Essentially, this just limits AMA/SMB as a safety cap against excessive COB entry) public final static int maxCOB = 120; public final static boolean skip_neutral_temps = true; // ***** default false in oref1 ***** if true, don't set neutral temps + public final static boolean skip_neutral_temps_medtronic = false;//if using a medtronic pump default to false so the pump doesnt beep on the hour // unsuspend_if_no_temp:false // if true, pump will un-suspend after a zero temp finishes // bolussnooze_dia_divisor:2 // bolus snooze decays after 1/2 of DIA public final static double min_5m_carbimpact = 8d; // mg/dL per 5m (8 mg/dL/5m corresponds to 24g/hr at a CSF of 4 mg/dL/g (x/5*60/4)) From 441e5fdf3e40bbe8c36c69dfbed262693206cf6b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 11 May 2020 14:50:35 +0200 Subject: [PATCH 06/45] extend pump interface for neutral temps --- .../androidaps/interfaces/PumpInterface.java | 4 ++++ .../aps/openAPSSMB/DetermineBasalAdapterSMBJS.java | 13 +++---------- .../plugins/aps/openAPSSMB/SMBDefaults.java | 3 +-- .../plugins/pump/medtronic/MedtronicPumpPlugin.java | 4 ++++ app/src/main/res/values/strings.xml | 6 +++--- app/src/main/res/xml/pref_medtronic.xml | 8 ++++---- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java index d85a383752..3ad7ed6ab8 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java @@ -122,4 +122,8 @@ public interface PumpInterface { default boolean isUnreachableAlertTimeoutExceeded(long alertTimeoutMilliseconds) { return false; } + + default boolean setNeutralTempAtFullHour() { + return false; + } } 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 16949fcb4c..f37f85d26b 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 @@ -26,18 +26,16 @@ import info.nightscout.androidaps.data.IobTotal; 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.PumpInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.aps.loop.ScriptReader; import info.nightscout.androidaps.plugins.aps.logger.LoggerCallback; -import info.nightscout.androidaps.plugins.common.ManufacturerType; +import info.nightscout.androidaps.plugins.aps.loop.ScriptReader; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; -import info.nightscout.androidaps.interfaces.ActivePluginProvider; - import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.SafeParse; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -240,7 +238,6 @@ public class DetermineBasalAdapterSMBJS { String units = profile.getUnits(); PumpInterface pump = activePluginProvider.getActivePump(); - ManufacturerType manufacturer = pump.manufacturer(); Double pumpbolusstep = pump.getPumpDescription().bolusStep; mProfile = new JSONObject(); @@ -269,11 +266,7 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("exercise_mode", SMBDefaults.exercise_mode); mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target); mProfile.put("maxCOB", SMBDefaults.maxCOB); - if (!manufacturer.name().equals("Medtronic")) { - mProfile.put("skip_neutral_temps",SMBDefaults.skip_neutral_temps); - } else { - mProfile.put("skip_neutral_temps", sp.getBoolean(R.string.key_skip_neutral_temps, SMBDefaults.skip_neutral_temps_medtronic)); - } + mProfile.put("skip_neutral_temps", !pump.setNeutralTempAtFullHour()); // min_5m_carbimpact is not used within SMB determinebasal //if (mealData.usedMinCarbsImpact > 0) { // mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java index 42eacdbce6..83ef09f89a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/SMBDefaults.java @@ -37,8 +37,7 @@ public class SMBDefaults { // (If someone enters more carbs or stacks more; OpenAPS will just truncate dosing based on 120. // Essentially, this just limits AMA/SMB as a safety cap against excessive COB entry) public final static int maxCOB = 120; - public final static boolean skip_neutral_temps = true; // ***** default false in oref1 ***** if true, don't set neutral temps - public final static boolean skip_neutral_temps_medtronic = false;//if using a medtronic pump default to false so the pump doesnt beep on the hour + //public final static boolean skip_neutral_temps = true; // ***** default false in oref1 ***** if true, don't set neutral temps // unsuspend_if_no_temp:false // if true, pump will un-suspend after a zero temp finishes // bolussnooze_dia_divisor:2 // bolus snooze decays after 1/2 of DIA public final static double min_5m_carbimpact = 8d; // mg/dL per 5m (8 mg/dL/5m corresponds to 24g/hr at a CSF of 4 mg/dL/g (x/5*60/4)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index 4bb5609f33..8f997b9b58 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -1558,6 +1558,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter this.hasTimeDateOrTimeZoneChanged = true; } + @Override public boolean setNeutralTempAtFullHour() { + return sp.getBoolean(R.string.key_set_neutral_temps, true); + } + private void setEnableCustomAction(MedtronicCustomActionType customAction, boolean isEnabled) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1561f13835..8f84bd2b87 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -958,9 +958,9 @@ enableSMB_with_temptarget enableSMB_after_carbs enableSMB_with_high_temptarget - skip_neutral_temps - Skip neutral temp basals - If enabled, it skips setting basal to neutral before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. + set_neutral_temps + Set neutral temp basals + If enabled, it sets basal to neutral before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. Enable SMB always Enable SMB always independently to boluses. Possible only with BG source with nice filtering of data like G5 Enable SMB after carbs diff --git a/app/src/main/res/xml/pref_medtronic.xml b/app/src/main/res/xml/pref_medtronic.xml index c5f4562e1d..342250d046 100644 --- a/app/src/main/res/xml/pref_medtronic.xml +++ b/app/src/main/res/xml/pref_medtronic.xml @@ -99,10 +99,10 @@ + android:defaultValue="true" + android:key="@string/key_set_neutral_temps" + android:summary="@string/set_neutral_temps_summary" + android:title="@string/set_neutral_temps_title" /> From b49d9d13af75d08ca5fba84ef0a643d0af530d1b Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Wed, 13 May 2020 10:36:16 +1200 Subject: [PATCH 07/45] revert counter logic --- app/src/main/assets/OpenAPSSMB/determine-basal.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/assets/OpenAPSSMB/determine-basal.js b/app/src/main/assets/OpenAPSSMB/determine-basal.js index 18181d25de..00a9c1d0a2 100644 --- a/app/src/main/assets/OpenAPSSMB/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMB/determine-basal.js @@ -897,8 +897,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // if not in LGS mode, cancel temps before the top of the hour to reduce beeping/vibration // console.error(profile.skip_neutral_temps, rT.deliverAt.getMinutes()); - //patch determine basal so skip_neutral_temps works as expected - if ( !profile.skip_neutral_temps && rT.deliverAt.getMinutes() >= 55 ) { + if ( profile.skip_neutral_temps && rT.deliverAt.getMinutes() >= 55 ) { rT.reason += "; Canceling temp at " + rT.deliverAt.getMinutes() + "m past the hour. "; return tempBasalFunctions.setTempBasal(0, 0, profile, rT, currenttemp); } From bcfd5e014998e07c905acc169c703c9fe29d594e Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Wed, 13 May 2020 11:36:32 +1200 Subject: [PATCH 08/45] revert counter logic --- .../plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1032f81287..fa92994920 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 @@ -266,7 +266,7 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("exercise_mode", SMBDefaults.exercise_mode); mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target); mProfile.put("maxCOB", SMBDefaults.maxCOB); - mProfile.put("skip_neutral_temps", !pump.setNeutralTempAtFullHour()); + mProfile.put("skip_neutral_temps", pump.setNeutralTempAtFullHour()); // min_5m_carbimpact is not used within SMB determinebasal //if (mealData.usedMinCarbsImpact > 0) { // mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact); From 1dd579fd1934d1241566992a45b0267d4b2d663f Mon Sep 17 00:00:00 2001 From: Philoul Date: Fri, 15 May 2020 11:37:09 +0200 Subject: [PATCH 09/45] Add disable vibration in insight settings (local_full only) Build works but as it related to pump communication, I prefer to not test it on my pump before Tebbe confirmation... (code is very simple, so it should work!) --- .../plugins/pump/insight/LocalInsightPlugin.java | 2 ++ .../app_layer/remote_control/DeliverBolusMessage.java | 9 ++++++++- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/pref_insight_local_full.xml | 6 ++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index f8d1cf1ce5..51c6337df1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -597,6 +597,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, bolusMessage.setDuration(0); bolusMessage.setExtendedAmount(0); bolusMessage.setImmediateAmount(insulin); + bolusMessage.setVibration(sp.getBoolean("insight_disable_vibration",false)); bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId(); bolusCancelled = false; } @@ -820,6 +821,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, bolusMessage.setDuration(durationInMinutes); bolusMessage.setExtendedAmount(insulin); bolusMessage.setImmediateAmount(0); + bolusMessage.setVibration(sp.getBoolean("insight_disable_vibration",false)); int bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId(); InsightBolusID insightBolusID = new InsightBolusID(); insightBolusID.bolusID = bolusID; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java index e0d0f2461a..6a4973b42b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java @@ -14,6 +14,7 @@ public class DeliverBolusMessage extends AppLayerMessage { private double extendedAmount; private int duration; private int bolusId; + private boolean disableVibration = false; public DeliverBolusMessage() { super(MessagePriority.NORMAL, true, true, Service.REMOTE_CONTROL); @@ -22,7 +23,11 @@ public class DeliverBolusMessage extends AppLayerMessage { @Override protected ByteBuf getData() { ByteBuf byteBuf = new ByteBuf(22); - byteBuf.putUInt16LE(252); + // 805 => Old value with vibration (2.6.1 and earlier), 252 => new value without vibrations for firmware 3.x + if (disableVibration) + byteBuf.putUInt16LE(252); + else + byteBuf.putUInt16LE(805); byteBuf.putUInt16LE(BolusTypeIDs.IDS.getID(bolusType)); byteBuf.putUInt16LE(31); byteBuf.putUInt16LE(0); @@ -57,6 +62,8 @@ public class DeliverBolusMessage extends AppLayerMessage { this.duration = duration; } + public void setVibration(boolean disableVibration) { this.disableVibration = disableVibration;} + public int getBolusId() { return bolusId; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4a4595fab4..8033c82057 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1016,6 +1016,8 @@ Log alerts Enable TBR emulation Use extended boluses instead of TBRs to bypass the 250%% limit + Disable vibrations on bolus delivery + This setting is only available with Insight firmware 3.x Disconnect delay [s] Serial number Release software version diff --git a/app/src/main/res/xml/pref_insight_local_full.xml b/app/src/main/res/xml/pref_insight_local_full.xml index ceaba15e38..761016b287 100644 --- a/app/src/main/res/xml/pref_insight_local_full.xml +++ b/app/src/main/res/xml/pref_insight_local_full.xml @@ -48,6 +48,12 @@ android:summary="@string/enable_tbr_emulation_summary" android:title="@string/enable_tbr_emulation" /> + + Date: Tue, 19 May 2020 19:27:31 +0200 Subject: [PATCH 10/45] RS hwver 7 --- ...DanaRS_Packet_APS_Set_Event_HistoryTest.kt | 1 + .../DanaRS_Packet_Option_Get_Pump_TimeTest.kt | 2 +- .../pump/danaR/comm/MsgSettingPumpTimeTest.kt | 2 +- .../nightscout/androidaps/data/Profile.java | 5 + .../nightscout/androidaps/dana/DanaPump.kt | 72 +++++++++--- .../activities/DanaUserOptionsActivity.kt | 8 +- dana/src/main/res/values/strings.xml | 3 + .../danar/comm/MsgSettingPumpTime.kt | 7 +- .../danars/comm/DanaRSMessageHashTable.kt | 5 + .../androidaps/danars/comm/DanaRS_Packet.java | 23 ++++ .../comm/DanaRS_Packet_APS_History_Events.kt | 106 ++++++++++-------- .../DanaRS_Packet_APS_Set_Event_History.kt | 34 +++--- ...DanaRS_Packet_Bolus_Get_24_CIR_CF_Array.kt | 39 +++++++ ...DanaRS_Packet_Bolus_Set_24_CIR_CF_Array.kt | 52 +++++++++ .../danars/comm/DanaRS_Packet_History_.kt | 14 ++- .../danars/comm/DanaRS_Packet_Notify_Alarm.kt | 10 +- .../DanaRS_Packet_Option_Get_Pump_Time.kt | 28 ++--- ...Packet_Option_Get_Pump_UTC_And_TimeZone.kt | 41 +++++++ ...Packet_Option_Set_Pump_UTC_And_TimeZone.kt | 49 ++++++++ .../androidaps/danars/di/DanaRSCommModule.kt | 4 + .../danars/encryption/BleEncryption.java | 8 ++ .../danars/services/DanaRSService.kt | 52 +++++---- 22 files changed, 433 insertions(+), 132 deletions(-) create mode 100644 danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_24_CIR_CF_Array.kt create mode 100644 danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_24_CIR_CF_Array.kt create mode 100644 danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone.kt create mode 100644 danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone.kt diff --git a/app/src/test/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt b/app/src/test/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt index cdd68df473..2bbb735ac2 100644 --- a/app/src/test/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_HistoryTest.kt @@ -20,6 +20,7 @@ class DanaRS_Packet_APS_Set_Event_HistoryTest : DanaRSTestBase() { it.dateUtil = dateUtil } if (it is DanaRS_Packet_APS_Set_Event_History) { + it.danaPump = danaPump } } } diff --git a/app/src/test/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt b/app/src/test/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt index 0cda0fa06c..3a1a8e1256 100644 --- a/app/src/test/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_TimeTest.kt @@ -34,7 +34,7 @@ class DanaRS_Packet_Option_Get_Pump_TimeTest : DanaRSTestBase() { putByteToArray(array, 5, 35) // second 35 packet.handleMessage(array) - Assert.assertEquals(DateTime(2019, 2, 4, 20, 11, 35).millis, danaPump.pumpTime) + Assert.assertEquals(DateTime(2019, 2, 4, 20, 11, 35).millis, danaPump.getPumpTime()) Assert.assertEquals("OPTION__GET_PUMP_TIME", packet.friendlyName) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt index f99a68d472..600768548f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt @@ -25,6 +25,6 @@ class MsgSettingPumpTimeTest : DanaRTestBase() { packet.intFromBuff(bytes, 0, 1) ).time packet.handleMessage(bytes) - Assert.assertEquals(time, danaPump.pumpTime) + Assert.assertEquals(time, danaPump.getPumpTime()) } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/data/Profile.java b/core/src/main/java/info/nightscout/androidaps/data/Profile.java index dc8e08b0df..4aaa5848fb 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/core/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -100,6 +100,7 @@ public class Profile { } protected void init(JSONObject json, int percentage, int timeshift) { + if (json == null) return; units = null; dia = Constants.defaultDIA; timeZone = TimeZone.getDefault(); @@ -404,6 +405,10 @@ public class Profile { return toMgdl(getIsfTimeFromMidnight(secondsFromMidnight(time)), units); } + public double getIsfMgdlTimeFromMidnight(int timeAsSeconds) { + return toMgdl(getIsfTimeFromMidnight(timeAsSeconds), units); + } + public double getIsfTimeFromMidnight(int timeAsSeconds) { if (isf_v == null) isf_v = convertToSparseArray(isf); diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/DanaPump.kt b/dana/src/main/java/info/nightscout/androidaps/dana/DanaPump.kt index 33f92910ac..e06f924215 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/DanaPump.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/DanaPump.kt @@ -3,10 +3,11 @@ package info.nightscout.androidaps.dana import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.db.Treatment import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.db.Treatment +import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.sharedPreferences.SP import org.json.JSONArray import org.json.JSONException @@ -49,8 +50,32 @@ class DanaPump @Inject constructor( var bleModel = "" // RS v3: like BPN-1.0.1 var isNewPump = true // R only , providing model info var password = -1 // R, RSv1 - var pumpTime: Long = 0 + + // time + private var pumpTime: Long = 0 + var zoneOffset: Int = 0 // i (hw 7+) + + fun setPumpTime(value: Long) { + pumpTime = value + } + + fun setPumpTime(value: Long, zoneOffset: Int) { + pumpTime = value + T.hours(zoneOffset.toLong()).msecs() + this.zoneOffset = zoneOffset + } + + fun resetPumpTime() { + pumpTime = 0 + } + + fun getPumpTime() = pumpTime + var hwModel = 0 + val usingUTC + get() = hwModel >= 7 + val profile24 + get() = hwModel >= 7 + var protocol = 0 var productCode = 0 var errorState: ErrorState = ErrorState.NONE @@ -90,8 +115,9 @@ class DanaPump @Inject constructor( var extendedBolusRemainingMinutes = 0 var extendedBolusDeliveredSoFar = 0.0 //RS only = 0.0 - // Profile + // Profile R,RSv1 var units = 0 + var activeProfile = 0 var easyBasalMode = 0 var basal48Enable = false var currentCIR = 0 @@ -107,7 +133,10 @@ class DanaPump @Inject constructor( var eveningCF = 0.0 var nightCIR = 0 var nightCF = 0.0 - var activeProfile = 0 + + // Profile I + var cf24 = Array(24) { 0.0 } + var cir24 = Array(24) { 0.0 } //var pumpProfiles = arrayOf>() var pumpProfiles: Array>? = null @@ -151,6 +180,8 @@ class DanaPump @Inject constructor( var bolusDone = false // success end var lastEventTimeLoaded: Long = 0 // timestamp of last received event + val lastKnownHistoryId: Int = 0 // hwver 7+, 1-2000 + fun createConvertedProfile(): ProfileStore? { pumpProfiles?.let { val json = JSONObject() @@ -165,18 +196,30 @@ class DanaPump @Inject constructor( json.put("store", store) profile.put("dia", Constants.defaultDIA) val carbratios = JSONArray() - carbratios.put(JSONObject().put("time", "00:00").put("timeAsSeconds", 0).put("value", nightCIR)) - carbratios.put(JSONObject().put("time", "06:00").put("timeAsSeconds", 6 * 3600).put("value", morningCIR)) - carbratios.put(JSONObject().put("time", "11:00").put("timeAsSeconds", 11 * 3600).put("value", afternoonCIR)) - carbratios.put(JSONObject().put("time", "14:00").put("timeAsSeconds", 17 * 3600).put("value", eveningCIR)) - carbratios.put(JSONObject().put("time", "22:00").put("timeAsSeconds", 22 * 3600).put("value", nightCIR)) + if (!profile24) { + carbratios.put(JSONObject().put("time", "00:00").put("timeAsSeconds", 0).put("value", nightCIR)) + carbratios.put(JSONObject().put("time", "06:00").put("timeAsSeconds", 6 * 3600).put("value", morningCIR)) + carbratios.put(JSONObject().put("time", "11:00").put("timeAsSeconds", 11 * 3600).put("value", afternoonCIR)) + carbratios.put(JSONObject().put("time", "14:00").put("timeAsSeconds", 17 * 3600).put("value", eveningCIR)) + carbratios.put(JSONObject().put("time", "22:00").put("timeAsSeconds", 22 * 3600).put("value", nightCIR)) + } else { // 24 values + for (i in 0..23) { + carbratios.put(JSONObject().put("time", String.format("%02d", i) + ":00").put("timeAsSeconds", i * 3600).put("value", cir24[i])) + } + } profile.put("carbratio", carbratios) val sens = JSONArray() - sens.put(JSONObject().put("time", "00:00").put("timeAsSeconds", 0).put("value", nightCF)) - sens.put(JSONObject().put("time", "06:00").put("timeAsSeconds", 6 * 3600).put("value", morningCF)) - sens.put(JSONObject().put("time", "11:00").put("timeAsSeconds", 11 * 3600).put("value", afternoonCF)) - sens.put(JSONObject().put("time", "17:00").put("timeAsSeconds", 17 * 3600).put("value", eveningCF)) - sens.put(JSONObject().put("time", "22:00").put("timeAsSeconds", 22 * 3600).put("value", nightCF)) + if (!profile24) { + sens.put(JSONObject().put("time", "00:00").put("timeAsSeconds", 0).put("value", nightCF)) + sens.put(JSONObject().put("time", "06:00").put("timeAsSeconds", 6 * 3600).put("value", morningCF)) + sens.put(JSONObject().put("time", "11:00").put("timeAsSeconds", 11 * 3600).put("value", afternoonCF)) + sens.put(JSONObject().put("time", "17:00").put("timeAsSeconds", 17 * 3600).put("value", eveningCF)) + sens.put(JSONObject().put("time", "22:00").put("timeAsSeconds", 22 * 3600).put("value", nightCF)) + } else { // 24 values + for (i in 0..23) { + sens.put(JSONObject().put("time", String.format("%02d", i) + ":00").put("timeAsSeconds", i * 3600).put("value", cf24[i])) + } + } profile.put("sens", sens) val basals = JSONArray() val basalValues = if (basal48Enable) 48 else 24 @@ -270,6 +313,7 @@ class DanaPump @Inject constructor( const val PROFILECHANGE = 13 const val CARBS = 14 const val PRIMECANNULA = 15 + const val TIMECHANGE = 16 // Dana R btModel const val DOMESTIC_MODEL = 0x01 diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt index be38978236..fd9c50fb48 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt @@ -44,6 +44,8 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() { private fun isDanaR() = activePlugin.activePump.pumpDescription.pumpType == PumpType.DanaR private fun isDanaRv2() = activePlugin.activePump.pumpDescription.pumpType == PumpType.DanaRv2 + var minBacklight = 1 + @Synchronized override fun onResume() { super.onResume() @@ -65,6 +67,8 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() { save_user_options.setOnClickListener { onSaveClick() } + minBacklight = if (danaPump.hwModel < 7) 1 else 0 // Dana-i allows zero + aapsLogger.debug(LTag.PUMP, "UserOptionsLoaded:" + (System.currentTimeMillis() - danaPump.lastConnection) / 1000 + " s ago" + "\ntimeDisplayType:" + danaPump.timeDisplayType @@ -76,7 +80,7 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() { + "\nlowReservoir:" + danaPump.lowReservoirRate) danar_screentimeout.setParams(danaPump.lcdOnTimeSec.toDouble(), 5.0, 240.0, 5.0, DecimalFormat("1"), false, save_user_options) - danar_backlight.setParams(danaPump.backlightOnTimeSec.toDouble(), 1.0, 60.0, 1.0, DecimalFormat("1"), false, save_user_options) + danar_backlight.setParams(danaPump.backlightOnTimeSec.toDouble(), minBacklight.toDouble(), 60.0, 1.0, DecimalFormat("1"), false, save_user_options) danar_shutdown.setParams(danaPump.shutdownHour.toDouble(), 0.0, 24.0, 1.0, DecimalFormat("1"), true, save_user_options) danar_lowreservoir.setParams(danaPump.lowReservoirRate.toDouble(), 10.0, 60.0, 10.0, DecimalFormat("10"), false, save_user_options) when (danaPump.beepAndAlarm) { @@ -136,7 +140,7 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() { // step is 5 seconds, 5 to 240 danaPump.lcdOnTimeSec = min(max(danar_screentimeout.value.toInt() / 5 * 5, 5), 240) // 1 to 60 - danaPump.backlightOnTimeSec = min(max(danar_backlight.value.toInt(), 1), 60) + danaPump.backlightOnTimeSec = min(max(danar_backlight.value.toInt(), minBacklight), 60) danaPump.units = if (danar_units.isChecked) 1 else 0 diff --git a/dana/src/main/res/values/strings.xml b/dana/src/main/res/values/strings.xml index b0fe53ee25..bf26707ffc 100644 --- a/dana/src/main/res/values/strings.xml +++ b/dana/src/main/res/values/strings.xml @@ -42,6 +42,9 @@ Pump Battery Discharged Occlusion Empty reservoir + Check shaft + Basal max + Daily max Blood sugar measurement alert Remaining insulin level Missed bolus diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgSettingPumpTime.kt b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgSettingPumpTime.kt index 5fffb9cf71..d8d216c16e 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgSettingPumpTime.kt +++ b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgSettingPumpTime.kt @@ -1,10 +1,7 @@ package info.nightscout.androidaps.danar.comm import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag -import info.nightscout.androidaps.dana.DanaPump -import info.nightscout.androidaps.utils.DateUtil import org.joda.time.DateTime import java.util.* @@ -27,10 +24,10 @@ class MsgSettingPumpTime( intFromBuff(bytes, 0, 1) ).millis aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + dateUtil.dateAndTimeString(time) + " Phone time: " + Date()) - danaPump.pumpTime = time + danaPump.setPumpTime(time) } override fun handleMessageNotReceived() { - danaPump.pumpTime = 0 + danaPump.resetPumpTime() } } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSMessageHashTable.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSMessageHashTable.kt index 9280187622..84e0dffa09 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSMessageHashTable.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSMessageHashTable.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.danars.comm import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.data.Profile import java.util.* import javax.inject.Inject import javax.inject.Singleton @@ -37,6 +38,7 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_Bolus_Get_Calculation_Information(injector)) put(DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(injector)) put(DanaRS_Packet_Bolus_Get_CIR_CF_Array(injector)) + put(DanaRS_Packet_Bolus_Get_24_CIR_CF_Array(injector)) put(DanaRS_Packet_Bolus_Get_Dual_Bolus(injector)) put(DanaRS_Packet_Bolus_Get_Extended_Bolus(injector)) put(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(injector)) @@ -45,6 +47,7 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_Bolus_Set_Bolus_Option(injector)) put(DanaRS_Packet_Bolus_Set_Initial_Bolus(injector)) put(DanaRS_Packet_Bolus_Set_CIR_CF_Array(injector)) + put(DanaRS_Packet_Bolus_Set_24_CIR_CF_Array(injector, Profile(injector, null))) put(DanaRS_Packet_Bolus_Set_Dual_Bolus(injector)) put(DanaRS_Packet_Bolus_Set_Extended_Bolus(injector)) put(DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(injector)) @@ -60,8 +63,10 @@ class DanaRSMessageHashTable @Inject constructor( put(DanaRS_Packet_Notify_Delivery_Rate_Display(injector)) put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(injector)) put(DanaRS_Packet_Option_Get_Pump_Time(injector)) + put(DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone(injector)) put(DanaRS_Packet_Option_Get_User_Option(injector)) put(DanaRS_Packet_Option_Set_Pump_Time(injector)) + put(DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone(injector)) put(DanaRS_Packet_Option_Set_User_Option(injector)) //put(new DanaRS_Packet_History_(injector)); put(DanaRS_Packet_History_Alarm(injector)) diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet.java b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet.java index cf10a2d95c..87ff77d0e6 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet.java +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet.java @@ -151,6 +151,29 @@ public class DanaRS_Packet { return ret; } + protected static int intFromBuffMsbLsb(byte[] b, int srcStart, int srcLength) { + int ret; + + switch (srcLength) { + case 1: + ret = b[DATA_START + srcStart] & 0x000000FF; + break; + case 2: + ret = ((b[DATA_START + srcStart] & 0x000000FF) << 8) + (b[DATA_START + srcStart + 1] & 0x000000FF); + break; + case 3: + ret = ((b[DATA_START + srcStart] & 0x000000FF) << 16) + ((b[DATA_START + srcStart + 1] & 0x000000FF) << 8) + (b[DATA_START + srcStart + 2] & 0x000000FF); + break; + case 4: + ret = ((b[DATA_START + srcStart] & 0x000000FF) << 24) + ((b[DATA_START + srcStart + 1] & 0x000000FF) << 16) + ((b[DATA_START + srcStart + 2] & 0x000000FF) << 8) + (b[DATA_START + srcStart + 3] & 0x000000FF); + break; + default: + ret = -1; + break; + } + return ret; + } + @TargetApi(Build.VERSION_CODES.KITKAT) public static String stringFromBuff(byte[] buff, int offset, int length) { byte[] strbuff = new byte[length]; diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt index d2e8bbc3dd..6c351210be 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt @@ -18,6 +18,8 @@ import info.nightscout.androidaps.danars.encryption.BleEncryption import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP +import org.joda.time.DateTime +import org.joda.time.DateTimeZone import java.util.* import javax.inject.Inject @@ -34,59 +36,67 @@ open class DanaRS_Packet_APS_History_Events( @Inject lateinit var sp: SP @Inject lateinit var nsUpload: NSUpload - private var year = 0 - private var month = 0 - private var day = 0 - private var hour = 0 - private var min = 0 - private var sec = 0 - init { opCode = BleEncryption.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS - val cal = GregorianCalendar() if (from > DateUtil.now()) { aapsLogger.debug(LTag.PUMPCOMM, "Asked to load from the future") from = 0 } - if (from != 0L) cal.timeInMillis = from else cal[2000, 0, 1, 0, 0] = 0 - year = cal[Calendar.YEAR] - 1900 - 100 - month = cal[Calendar.MONTH] + 1 - day = cal[Calendar.DAY_OF_MONTH] - hour = cal[Calendar.HOUR_OF_DAY] - min = cal[Calendar.MINUTE] - sec = cal[Calendar.SECOND] - aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(cal.timeInMillis)) + aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(from)) danaPump.historyDoneReceived = false } override fun getRequestParams(): ByteArray { + val date = + if (danaPump.usingUTC) DateTime(from).withZone(DateTimeZone.UTC) + else DateTime(from) val request = ByteArray(6) - request[0] = (year and 0xff).toByte() - request[1] = (month and 0xff).toByte() - request[2] = (day and 0xff).toByte() - request[3] = (hour and 0xff).toByte() - request[4] = (min and 0xff).toByte() - request[5] = (sec and 0xff).toByte() + if (from == 0L) { + request[0] = 0 + request[1] = 1 + request[2] = 1 + request[3] = 0 + request[4] = 0 + request[5] = 0 + } else { + request[0] = (date.year - 2000 and 0xff).toByte() + request[1] = (date.monthOfYear and 0xff).toByte() + request[2] = (date.dayOfMonth and 0xff).toByte() + request[3] = (date.hourOfDay and 0xff).toByte() + request[4] = (date.minuteOfHour and 0xff).toByte() + request[5] = (date.secondOfMinute and 0xff).toByte() + } return request } override fun handleMessage(data: ByteArray) { - val recordCode = intFromBuff(data, 0, 1).toByte() + var recordCode = intFromBuff(data, 0, 1).toByte() // Last record if (recordCode == 0xFF.toByte()) { danaPump.historyDoneReceived = true aapsLogger.debug(LTag.PUMPCOMM, "Last record received") return } - val datetime = dateTimeSecFromBuff(data, 1) // 6 bytes - val param1 = (intFromBuff(data, 7, 1) shl 8 and 0xFF00) + (intFromBuff(data, 8, 1) and 0xFF) - val param2 = (intFromBuff(data, 9, 1) shl 8 and 0xFF00) + (intFromBuff(data, 10, 1) and 0xFF) - val temporaryBasal = TemporaryBasal(injector).date(datetime).source(Source.PUMP).pumpId(datetime) - val extendedBolus = ExtendedBolus(injector).date(datetime).source(Source.PUMP).pumpId(datetime) + val datetime: Long + val param1 = intFromBuffMsbLsb(data, 7, 2) + val param2 = intFromBuffMsbLsb(data, 9, 2) + val pumpId: Long + var id = 0 + if (!danaPump.usingUTC) { + datetime = dateTimeSecFromBuff(data, 1) // 6 bytes + pumpId = datetime + } else { + datetime = intFromBuffMsbLsb(data, 3, 4) * 1000L + recordCode = intFromBuff(data, 2, 1).toByte() + id = intFromBuffMsbLsb(data, 0, 2) // range only 1-2000 + pumpId = datetime shl 16 + id + } + val temporaryBasal = TemporaryBasal(injector).date(datetime).source(Source.PUMP).pumpId(pumpId) + val extendedBolus = ExtendedBolus(injector).date(datetime).source(Source.PUMP).pumpId(pumpId) val status: String when (recordCode.toInt()) { DanaPump.TEMPSTART -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT TEMPSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min") temporaryBasal.percentRate = param1 temporaryBasal.durationInMinutes = param2 activePlugin.activeTreatments.addToHistoryTempBasal(temporaryBasal) @@ -94,13 +104,13 @@ open class DanaRS_Packet_APS_History_Events( } DanaPump.TEMPSTOP -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime)) + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT TEMPSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime)) activePlugin.activeTreatments.addToHistoryTempBasal(temporaryBasal) status = "TEMPSTOP " + dateUtil.timeString(datetime) } DanaPump.EXTENDEDSTART -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT EXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") extendedBolus.insulin = param1 / 100.0 extendedBolus.durationInMinutes = param2 activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) @@ -108,7 +118,7 @@ open class DanaRS_Packet_APS_History_Events( } DanaPump.EXTENDEDSTOP -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT EXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) status = "EXTENDEDSTOP " + dateUtil.timeString(datetime) } @@ -121,7 +131,7 @@ open class DanaRS_Packet_APS_History_Events( detailedBolusInfo.pumpId = datetime detailedBolusInfo.insulin = param1 / 100.0 val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) - aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") status = "BOLUS " + dateUtil.timeString(datetime) } @@ -133,12 +143,12 @@ open class DanaRS_Packet_APS_History_Events( detailedBolusInfo.pumpId = datetime detailedBolusInfo.insulin = param1 / 100.0 val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) - aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") status = "DUALBOLUS " + dateUtil.timeString(datetime) } DanaPump.DUALEXTENDEDSTART -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") extendedBolus.insulin = param1 / 100.0 extendedBolus.durationInMinutes = param2 activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) @@ -146,37 +156,37 @@ open class DanaRS_Packet_APS_History_Events( } DanaPump.DUALEXTENDEDSTOP -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime) } DanaPump.SUSPENDON -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDON (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT SUSPENDON (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") status = "SUSPENDON " + dateUtil.timeString(datetime) } DanaPump.SUSPENDOFF -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT SUSPENDOFF (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") status = "SUSPENDOFF " + dateUtil.timeString(datetime) } DanaPump.REFILL -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT REFILL (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT REFILL (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") if (sp.getBoolean(R.string.key_rs_loginsulinchange, true)) nsUpload.generateCareportalEvent(CareportalEvent.INSULINCHANGE, datetime, resourceHelper.gs(R.string.danarspump)) status = "REFILL " + dateUtil.timeString(datetime) } DanaPump.PRIME -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIME (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT PRIME (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") if (sp.getBoolean(R.string.key_rs_logcanulachange, true)) nsUpload.generateCareportalEvent(CareportalEvent.SITECHANGE, datetime, resourceHelper.gs(R.string.danarspump)) status = "PRIME " + dateUtil.timeString(datetime) } DanaPump.PROFILECHANGE -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT PROFILECHANGE (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h") status = "PROFILECHANGE " + dateUtil.timeString(datetime) } @@ -187,17 +197,23 @@ open class DanaRS_Packet_APS_History_Events( emptyCarbsInfo.source = Source.PUMP emptyCarbsInfo.pumpId = datetime val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(emptyCarbsInfo, false) - aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g") status = "CARBS " + dateUtil.timeString(datetime) } DanaPump.PRIMECANNULA -> { - aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIMECANNULA(" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT PRIMECANNULA(" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") status = "PRIMECANNULA " + dateUtil.timeString(datetime) } - else -> { - aapsLogger.debug(LTag.PUMPCOMM, "Event: " + recordCode + " " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) + DanaPump.TIMECHANGE -> { + val oldDateTime = intFromBuffMsbLsb(data, 7, 4) * 1000L + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "EVENT TIMECHANGE(" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Previous: " + dateUtil.dateAndTimeString(oldDateTime)) + status = "TIMECHANGE " + dateUtil.timeString(datetime) + } + + else -> { + aapsLogger.debug(LTag.PUMPCOMM, "[" + id + "] " + "Event: " + recordCode + " " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) status = "UNKNOWN " + dateUtil.timeString(datetime) } } diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_History.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_History.kt index 67d4643064..802eb09b56 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_History.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_Set_Event_History.kt @@ -1,9 +1,12 @@ package info.nightscout.androidaps.danars.comm import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption -import java.util.* +import info.nightscout.androidaps.logging.LTag +import org.joda.time.DateTime +import org.joda.time.DateTimeZone +import javax.inject.Inject class DanaRS_Packet_APS_Set_Event_History( injector: HasAndroidInjector, @@ -13,29 +16,26 @@ class DanaRS_Packet_APS_Set_Event_History( private var param2: Int ) : DanaRS_Packet(injector) { + @Inject lateinit var danaPump: DanaPump + init { opCode = BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY - if ((packetType == info.nightscout.androidaps.dana.DanaPump.CARBS || packetType == info.nightscout.androidaps.dana.DanaPump.BOLUS) && param1 <= 0) this.param1 = 0 + if ((packetType == DanaPump.CARBS || packetType == DanaPump.BOLUS) && param1 <= 0) this.param1 = 0 aapsLogger.debug(LTag.PUMPCOMM, "Set history entry: " + dateUtil.dateAndTimeString(time) + " type: " + packetType + " param1: " + param1 + " param2: " + param2) } override fun getRequestParams(): ByteArray { - val cal = GregorianCalendar() - cal.timeInMillis = time - val year = cal[Calendar.YEAR] - 1900 - 100 - val month = cal[Calendar.MONTH] + 1 - val day = cal[Calendar.DAY_OF_MONTH] - val hour = cal[Calendar.HOUR_OF_DAY] - val min = cal[Calendar.MINUTE] - val sec = cal[Calendar.SECOND] + val date = + if (danaPump.usingUTC) DateTime(time).withZone(DateTimeZone.UTC) + else DateTime(time) val request = ByteArray(11) request[0] = (packetType and 0xff).toByte() - request[1] = (year and 0xff).toByte() - request[2] = (month and 0xff).toByte() - request[3] = (day and 0xff).toByte() - request[4] = (hour and 0xff).toByte() - request[5] = (min and 0xff).toByte() - request[6] = (sec and 0xff).toByte() + request[1] = (date.year - 2000 and 0xff).toByte() + request[2] = (date.monthOfYear and 0xff).toByte() + request[3] = (date.dayOfMonth and 0xff).toByte() + request[4] = (date.hourOfDay and 0xff).toByte() + request[5] = (date.minuteOfHour and 0xff).toByte() + request[6] = (date.secondOfMinute and 0xff).toByte() request[7] = (param1 ushr 8 and 0xff).toByte() request[8] = (param1 and 0xff).toByte() request[9] = (param2 ushr 8 and 0xff).toByte() diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_24_CIR_CF_Array.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_24_CIR_CF_Array.kt new file mode 100644 index 0000000000..5f8be76b2e --- /dev/null +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_24_CIR_CF_Array.kt @@ -0,0 +1,39 @@ +package info.nightscout.androidaps.danars.comm + +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.dana.DanaPump +import info.nightscout.androidaps.danars.encryption.BleEncryption +import javax.inject.Inject + +class DanaRS_Packet_Bolus_Get_24_CIR_CF_Array( + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaPump: DanaPump + + init { + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_24_CIR_CF_ARRAY + aapsLogger.debug(LTag.PUMPCOMM, "New message") + } + + override fun handleMessage(data: ByteArray) { + danaPump.units = byteArrayToInt(getBytes(data, DATA_START, 1)) + for (i in 0 .. 23) { + val cf = byteArrayToInt(getBytes(data, DATA_START + 1 + 2 * i, 2)).toDouble() + val cir = if (danaPump.units == DanaPump.UNITS_MGDL) + byteArrayToInt(getBytes(data, DATA_START + 1 + 48 + 2 * i, 2)).toDouble() + else + byteArrayToInt(getBytes(data, DATA_START + 1 + 48 + 2 * i, 2)) / 100.0 + danaPump.cir24[i] = cir + danaPump.cf24[i] = cf + aapsLogger.debug(LTag.PUMPCOMM, "$i: CIR: $cir CF: $cf") + } + if (danaPump.units < 0 || danaPump.units > 1) failed = true + aapsLogger.debug(LTag.PUMPCOMM, "Pump units: " + if (danaPump.units == DanaPump.UNITS_MGDL) "MGDL" else "MMOL") + } + + override fun getFriendlyName(): String { + return "BOLUS__GET_24_ CIR_CF_ARRAY" + } +} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_24_CIR_CF_Array.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_24_CIR_CF_Array.kt new file mode 100644 index 0000000000..7a0e925ab6 --- /dev/null +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Set_24_CIR_CF_Array.kt @@ -0,0 +1,52 @@ +package info.nightscout.androidaps.danars.comm + +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.dana.DanaPump +import info.nightscout.androidaps.danars.encryption.BleEncryption +import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.logging.LTag +import javax.inject.Inject + +class DanaRS_Packet_Bolus_Set_24_CIR_CF_Array( + injector: HasAndroidInjector, + private val profile: Profile? +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaPump: DanaPump + + init { + opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_24_CIR_CF_ARRAY + aapsLogger.debug(LTag.PUMPCOMM, "New message") + } + + override fun getRequestParams(): ByteArray { + val request = ByteArray(96) + profile ?: return request // profile is null only in hash table + val cfStart = 24 * 2 + for (i in 0..23) { + var isf = profile.getIsfMgdlTimeFromMidnight(i * 3600) + if (danaPump.units == DanaPump.UNITS_MMOL) isf *= 10 + val ic = profile.getIcTimeFromMidnight(i * 3600) * 100 + request[2 * i] = (isf.toInt() and 0xff).toByte() + request[2 * i] = (isf.toInt() ushr 8 and 0xff).toByte() + request[cfStart + 2 * i] = (ic.toInt() and 0xff).toByte() + request[cfStart + 2 * i] = (ic.toInt() ushr 8 and 0xff).toByte() + } + return request + } + + override fun handleMessage(data: ByteArray) { + val result = intFromBuff(data, 0, 1) + if (result == 0) { + aapsLogger.debug(LTag.PUMPCOMM, "Result OK") + failed = false + } else { + aapsLogger.error("Result Error: $result") + failed = true + } + } + + override fun getFriendlyName(): String { + return "BOLUS__SET_24_CIR_CF_ARRAY" + } +} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_.kt index c5a0b40ceb..538d9b0bf7 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_History_.kt @@ -193,11 +193,15 @@ abstract class DanaRS_Packet_History_( val datetimewihtsec = DateTime(2000 + historyYear, historyMonth, historyDay, historyHour, historyMinute, historySecond) danaRHistoryRecord.recordDate = datetimewihtsec.millis var strAlarm = "None" - when (paramByte8.toInt()) { - 67 -> strAlarm = "Check" - 79 -> strAlarm = "Occlusion" - 66 -> strAlarm = "Low Battery" - 83 -> strAlarm = "Shutdown" + when (paramByte8) { + 'P'.toByte() -> strAlarm = "Basal Compare" + 'R'.toByte() -> strAlarm = "Empty Reservoir" + 'C'.toByte() -> strAlarm = "Check" + 'O'.toByte() -> strAlarm = "Occlusion" + 'M'.toByte() -> strAlarm = "Basal max" + 'D'.toByte() -> strAlarm = "Daily max" + 'B'.toByte() -> strAlarm = "Low Battery" + 'S'.toByte() -> strAlarm = "Shutdown" } danaRHistoryRecord.recordAlarm = strAlarm danaRHistoryRecord.recordValue = value * 0.01 diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Alarm.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Alarm.kt index fe94033ea8..f397179185 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Alarm.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Notify_Alarm.kt @@ -41,12 +41,18 @@ class DanaRS_Packet_Notify_Alarm( errorString = resourceHelper.gs(R.string.lowbattery) 0x06 -> // Basal Compare errorString = resourceHelper.gs(R.string.basalcompare) - 0x09 -> // Empty Reservoir - errorString = resourceHelper.gs(R.string.emptyreservoir) 0x07, 0xFF -> // Blood sugar measurement alert errorString = resourceHelper.gs(R.string.bloodsugarmeasurementalert) 0x08, 0xFE -> // Remaining insulin level errorString = resourceHelper.gs(R.string.remaininsulinalert) + 0x09 -> // Empty Reservoir + errorString = resourceHelper.gs(R.string.emptyreservoir) + 0x0A -> // Check shaft + errorString = resourceHelper.gs(R.string.checkshaft) + 0x0B -> // Basal MAX + errorString = resourceHelper.gs(R.string.basalmax) + 0x0C -> // Daily MAX + errorString = resourceHelper.gs(R.string.dailymax) 0xFD -> // Blood sugar check miss alarm errorString = resourceHelper.gs(R.string.missedbolus) } diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_Time.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_Time.kt index 1b1daf30b7..11659879e3 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_Time.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_Time.kt @@ -19,31 +19,19 @@ class DanaRS_Packet_Option_Get_Pump_Time( } override fun handleMessage(data: ByteArray) { - var dataIndex = DATA_START - var dataSize = 1 - val year = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 1 - val month = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 1 - val day = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 1 - val hour = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 1 - val min = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - dataIndex += dataSize - dataSize = 1 - val sec = byteArrayToInt(getBytes(data, dataIndex, dataSize)) + val year = byteArrayToInt(getBytes(data, DATA_START, 1)) + val month = byteArrayToInt(getBytes(data, DATA_START + 1, 1)) + val day = byteArrayToInt(getBytes(data, DATA_START + 2, 1)) + val hour = byteArrayToInt(getBytes(data, DATA_START + 3, 1)) + val min = byteArrayToInt(getBytes(data, DATA_START + 4, 1)) + val sec = byteArrayToInt(getBytes(data, DATA_START + 5, 1)) val time = DateTime(2000 + year, month, day, hour, min, sec) - danaPump.pumpTime = time.millis + danaPump.setPumpTime(time.millis) aapsLogger.debug(LTag.PUMPCOMM, "Pump time " + dateUtil.dateAndTimeString(time.millis)) } override fun handleMessageNotReceived() { - danaPump.pumpTime = 0 + danaPump.resetPumpTime() } override fun getFriendlyName(): String { diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone.kt new file mode 100644 index 0000000000..9f35fcb82c --- /dev/null +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone.kt @@ -0,0 +1,41 @@ +package info.nightscout.androidaps.danars.comm + +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.dana.DanaPump +import info.nightscout.androidaps.danars.encryption.BleEncryption +import org.joda.time.DateTime +import javax.inject.Inject + +class DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone( + injector: HasAndroidInjector +) : DanaRS_Packet(injector) { + + @Inject lateinit var danaPump: DanaPump + + init { + opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_UTC_AND_TIME_ZONE + aapsLogger.debug(LTag.PUMPCOMM, "Requesting pump UTC time") + } + + override fun handleMessage(data: ByteArray) { + val year = byteArrayToInt(getBytes(data, DATA_START, 1)) + val month = byteArrayToInt(getBytes(data, DATA_START + 1, 1)) + val day = byteArrayToInt(getBytes(data, DATA_START + 2, 1)) + val hour = byteArrayToInt(getBytes(data, DATA_START + 3, 1)) + val min = byteArrayToInt(getBytes(data, DATA_START + 4, 1)) + val sec = byteArrayToInt(getBytes(data, DATA_START + 5, 1)) + val zoneOffset = getBytes(data, DATA_START + 6, 1)[0].toInt() + val time = DateTime(2000 + year, month, day, hour, min, sec) + danaPump.setPumpTime(time.millis, zoneOffset) + aapsLogger.debug(LTag.PUMPCOMM, "Pump time ${dateUtil.dateAndTimeString(danaPump.getPumpTime())} ZoneOffset: $zoneOffset") + } + + override fun handleMessageNotReceived() { + danaPump.resetPumpTime() + } + + override fun getFriendlyName(): String { + return "OPTION__GET_PUMP_UTC_AND_TIMEZONE" + } +} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone.kt new file mode 100644 index 0000000000..3fbf79a388 --- /dev/null +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone.kt @@ -0,0 +1,49 @@ +package info.nightscout.androidaps.danars.comm + +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.danars.encryption.BleEncryption +import org.joda.time.DateTime +import org.joda.time.DateTimeZone + +class DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone( + injector: HasAndroidInjector, + private var time: Long = 0, + private var zoneOffset: Int = 0 +) : DanaRS_Packet(injector) { + + var error = 0 + + init { + opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__SET_PUMP_UTC_AND_TIME_ZONE + aapsLogger.debug(LTag.PUMPCOMM, "Setting UTC pump time ${dateUtil.dateAndTimeString(time)} ZoneOffset: $zoneOffset") + } + + override fun getRequestParams(): ByteArray { + val date = DateTime(time).withZone(DateTimeZone.UTC) + val request = ByteArray(7) + request[0] = (date.year - 2000 and 0xff).toByte() + request[1] = (date.monthOfYear and 0xff).toByte() + request[2] = (date.dayOfMonth and 0xff).toByte() + request[3] = (date.hourOfDay and 0xff).toByte() + request[4] = (date.minuteOfHour and 0xff).toByte() + request[5] = (date.secondOfMinute and 0xff).toByte() + request[6] = zoneOffset.toByte() + return request + } + + override fun handleMessage(data: ByteArray) { + val result = intFromBuff(data, 0, 1) + if (result == 0) { + aapsLogger.debug(LTag.PUMPCOMM, "Result OK") + failed = false + } else { + aapsLogger.error("Result Error: $result") + failed = true + } + } + + override fun getFriendlyName(): String { + return "OPTION__SET_PUMP_UTC_AND_TIMEZONE" + } +} \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/di/DanaRSCommModule.kt b/danars/src/main/java/info/nightscout/androidaps/danars/di/DanaRSCommModule.kt index cb7a0dcfcd..f239525f85 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/di/DanaRSCommModule.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/di/DanaRSCommModule.kt @@ -25,6 +25,7 @@ abstract class DanaRSCommModule { @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Calculation_Information(): DanaRS_Packet_Bolus_Get_Calculation_Information @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(): DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_CIR_CF_Array(): DanaRS_Packet_Bolus_Get_CIR_CF_Array + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_24_CIR_CF_Array(): DanaRS_Packet_Bolus_Get_24_CIR_CF_Array @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Dual_Bolus(): DanaRS_Packet_Bolus_Get_Dual_Bolus @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Bolus(): DanaRS_Packet_Bolus_Get_Extended_Bolus @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Get_Extended_Bolus_State(): DanaRS_Packet_Bolus_Get_Extended_Bolus_State @@ -33,6 +34,7 @@ abstract class DanaRSCommModule { @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Bolus_Option(): DanaRS_Packet_Bolus_Set_Bolus_Option @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Initial_Bolus(): DanaRS_Packet_Bolus_Set_Initial_Bolus @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_CIR_CF_Array(): DanaRS_Packet_Bolus_Set_CIR_CF_Array + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_24_CIR_CF_Array(): DanaRS_Packet_Bolus_Set_24_CIR_CF_Array @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Dual_Bolus(): DanaRS_Packet_Bolus_Set_Dual_Bolus @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Extended_Bolus(): DanaRS_Packet_Bolus_Set_Extended_Bolus @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(): DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel @@ -76,4 +78,6 @@ abstract class DanaRSCommModule { @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_APS_Set_Event_History(): DanaRS_Packet_APS_Set_Event_History @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_General_Get_Shipping_Version(): DanaRS_Packet_General_Get_Shipping_Version @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Review_Get_Pump_Dec_Ratio(): DanaRS_Packet_Review_Get_Pump_Dec_Ratio + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone(): DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone + @ContributesAndroidInjector abstract fun contributesDanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone(): DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone } \ No newline at end of file diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/encryption/BleEncryption.java b/danars/src/main/java/info/nightscout/androidaps/danars/encryption/BleEncryption.java index 418881d6df..fbb441e223 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/encryption/BleEncryption.java +++ b/danars/src/main/java/info/nightscout/androidaps/danars/encryption/BleEncryption.java @@ -75,6 +75,8 @@ public class BleEncryption { public static final int DANAR_PACKET__OPCODE_BOLUS__SET_CIR_CF_ARRAY = 0x4F; public static final int DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION = 0x50; public static final int DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_OPTION = 0x51; + public static final int DANAR_PACKET__OPCODE_BOLUS__GET_24_CIR_CF_ARRAY = 0x52; + public static final int DANAR_PACKET__OPCODE_BOLUS__SET_24_CIR_CF_ARRAY = 0x53; public static final int DANAR_PACKET__OPCODE_BASAL__SET_TEMPORARY_BASAL = 0x60; public static final int DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE = 0x61; @@ -104,6 +106,12 @@ public class BleEncryption { // Easy Mode public static final int DANAR_PACKET__OPCODE_OPTION__GET_EASY_MENU_OPTION = 0x74; public static final int DANAR_PACKET__OPCODE_OPTION__SET_EASY_MENU_OPTION = 0x75; + public static final int DANAR_PACKET__OPCODE_OPTION__GET_EASY_MENU_STATUS = 0x76; + public static final int DANAR_PACKET__OPCODE_OPTION__SET_EASY_MENU_STATUS = 0x77; + public static final int DANAR_PACKET__OPCODE_OPTION__GET_PUMP_UTC_AND_TIME_ZONE = 0x78; + public static final int DANAR_PACKET__OPCODE_OPTION__SET_PUMP_UTC_AND_TIME_ZONE = 0x79; + public static final int DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME_ZONE = 0x7A; + public static final int DANAR_PACKET__OPCODE_OPTION__SET_PUMP_TIME_ZONE = 0x7B; public static final int DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE = 0xE0; public static final int DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION = 0xFF; diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt b/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt index ad5023a849..b1f472decf 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt @@ -43,6 +43,9 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import io.reactivex.disposables.CompositeDisposable import io.reactivex.schedulers.Schedulers +import org.joda.time.DateTime +import org.joda.time.DateTimeZone +import java.util.concurrent.TimeUnit import javax.inject.Inject import kotlin.math.abs import kotlin.math.min @@ -110,6 +113,21 @@ class DanaRSService : DaggerService() { fun readPumpStatus() { try { + val now = System.currentTimeMillis() + val pump = activePlugin.activePump + if (danaPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized) { + rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))) + sendMessage(DanaRS_Packet_General_Get_Shipping_Information(injector)) // serial no + sendMessage(DanaRS_Packet_General_Get_Pump_Check(injector)) // firmware + sendMessage(DanaRS_Packet_Basal_Get_Profile_Number(injector)) + sendMessage(DanaRS_Packet_Bolus_Get_Bolus_Option(injector)) // isExtendedEnabled + sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) // basal profile, basalStep, maxBasal + sendMessage(DanaRS_Packet_Bolus_Get_Calculation_Information(injector)) // target + if (danaPump.profile24) sendMessage(DanaRS_Packet_Bolus_Get_24_CIR_CF_Array(injector)) + else sendMessage(DanaRS_Packet_Bolus_Get_CIR_CF_Array(injector)) + sendMessage(DanaRS_Packet_Option_Get_User_Option(injector)) // Getting user options + danaPump.lastSettingsRead = now + } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus))) sendMessage(DanaRS_Packet_General_Initial_Screen_Information(injector)) rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingextendedbolusstatus))) @@ -120,7 +138,6 @@ class DanaRSService : DaggerService() { sendMessage(DanaRS_Packet_Basal_Get_Temporary_Basal_State(injector)) danaPump.lastConnection = System.currentTimeMillis() val profile = profileFunction.getProfile() - val pump = activePlugin.activePump if (profile != null && abs(danaPump.currentBasal - profile.basal) >= pump.pumpDescription.basalStep) { rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))) sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) // basal profile, basalStep, maxBasal @@ -129,9 +146,10 @@ class DanaRSService : DaggerService() { } } rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))) - sendMessage(DanaRS_Packet_Option_Get_Pump_Time(injector)) - var timeDiff = (danaPump.pumpTime - System.currentTimeMillis()) / 1000L - if (danaPump.pumpTime == 0L) { + if (danaPump.usingUTC) sendMessage(DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone(injector)) + else sendMessage(DanaRS_Packet_Option_Get_Pump_Time(injector)) + var timeDiff = (danaPump.getPumpTime() - System.currentTimeMillis()) / 1000L + if (danaPump.getPumpTime() == 0L) { // initial handshake was not successful // de-initialize pump danaPump.reset() @@ -139,19 +157,6 @@ class DanaRSService : DaggerService() { rxBus.send(EventInitializationChanged()) return } - val now = System.currentTimeMillis() - if (danaPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized) { - rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))) - sendMessage(DanaRS_Packet_General_Get_Shipping_Information(injector)) // serial no - sendMessage(DanaRS_Packet_General_Get_Pump_Check(injector)) // firmware - sendMessage(DanaRS_Packet_Basal_Get_Profile_Number(injector)) - sendMessage(DanaRS_Packet_Bolus_Get_Bolus_Option(injector)) // isExtendedEnabled - sendMessage(DanaRS_Packet_Basal_Get_Basal_Rate(injector)) // basal profile, basalStep, maxBasal - sendMessage(DanaRS_Packet_Bolus_Get_Calculation_Information(injector)) // target - sendMessage(DanaRS_Packet_Bolus_Get_CIR_CF_Array(injector)) - sendMessage(DanaRS_Packet_Option_Get_User_Option(injector)) // Getting user options - danaPump.lastSettingsRead = now - } aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds") if (abs(timeDiff) > 3) { if (abs(timeDiff) > 60 * 60 * 1.5) { @@ -170,15 +175,22 @@ class DanaRSService : DaggerService() { rxBus.send(EventInitializationChanged()) return } else { - if (danaPump.protocol >= 6) { + if (danaPump.usingUTC) { + val tz = DateTimeZone.getDefault() + val instant = DateTime.now().millis + val offsetInMilliseconds = tz.getOffset(instant).toLong() + val hours = TimeUnit.MILLISECONDS.toHours(offsetInMilliseconds).toInt() + sendMessage(DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone(injector, DateUtil.now(), hours)) + } else if (danaPump.protocol >= 6) { // can set seconds sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, DateUtil.now())) } else { waitForWholeMinute() // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cut off anyway) sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, DateUtil.now() + T.secs(10).msecs())) } - sendMessage(DanaRS_Packet_Option_Get_Pump_Time(injector)) - timeDiff = (danaPump.pumpTime - System.currentTimeMillis()) / 1000L + if (danaPump.usingUTC) sendMessage(DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone(injector)) + else sendMessage(DanaRS_Packet_Option_Get_Pump_Time(injector)) + timeDiff = (danaPump.getPumpTime() - System.currentTimeMillis()) / 1000L aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds") } } From 6229161c9692ec7699f4e34e62ce481f61f52989 Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 19 May 2020 19:32:27 +0200 Subject: [PATCH 11/45] Add constraintChecker for autosens icon in overview --- .../androidaps/plugins/general/overview/OverviewFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1188caccf7..93c112f745 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 @@ -757,7 +757,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList overview_uploader?.setOnClickListener { activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.uploader), nsDeviceStatus.extendedUploaderStatus) } } // Sensitivity - if (sp.getBoolean(R.string.key_openapsama_useautosens, false)) { + if (sp.getBoolean(R.string.key_openapsama_useautosens, false) && constraintChecker.isAutosensModeEnabled().value()) { overview_sensitivity_icon.setImageResource(R.drawable.ic_swap_vert_black_48dp_green) }else { overview_sensitivity_icon.setImageResource(R.drawable.ic_x_swap_vert_48px_green) From 6a837708828bb456f67633866be5211561949579 Mon Sep 17 00:00:00 2001 From: Dominik Dzienia Date: Tue, 19 May 2020 20:22:19 +0200 Subject: [PATCH 12/45] Fix issue #2594 (crash when Preferences are opened on Wear variant) --- wear/src/main/res/xml/preferences.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml index e8e48e3f51..3c114cb59c 100644 --- a/wear/src/main/res/xml/preferences.xml +++ b/wear/src/main/res/xml/preferences.xml @@ -1,5 +1,5 @@ - - + From cbf830353cb05221f37ad84044c4f0ab1949b299 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 19 May 2020 21:22:29 +0200 Subject: [PATCH 13/45] New Crowdin translations (#2645) * New translations strings.xml (Portuguese) * New translations strings.xml (Portuguese) * New translations strings.xml (Portuguese) * New translations strings.xml (Portuguese) * New translations exam.xml (Portuguese) * New translations strings.xml (French) * New translations strings.xml (Portuguese) * New translations strings.xml (Swedish) * New translations strings.xml (Swedish) * New translations exam.xml (Swedish) * New translations strings.xml (Portuguese, Brazilian) * New translations strings.xml (Portuguese) * New translations strings.xml (German) * New translations strings.xml (French) --- app/src/main/res/values-fr-rFR/strings.xml | 2 +- app/src/main/res/values-pt-rPT/exam.xml | 2 +- app/src/main/res/values-pt-rPT/strings.xml | 22 ++++---- app/src/main/res/values-sv-rSE/exam.xml | 2 +- app/src/main/res/values-sv-rSE/strings.xml | 14 ++--- core/src/main/res/values-fr-rFR/strings.xml | 2 +- core/src/main/res/values-pt-rPT/strings.xml | 4 +- dana/src/main/res/values-de-rDE/strings.xml | 3 ++ dana/src/main/res/values-pt-rBR/strings.xml | 57 ++++++++++++++++++++- dana/src/main/res/values-pt-rPT/strings.xml | 3 ++ 10 files changed, 85 insertions(+), 26 deletions(-) diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index f9e0d10cc5..ce6f943445 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -567,7 +567,7 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Max. minutes de basal pour limiter le SMB SMB RNS minutes max Minutes de basal max pour limiter les SMB des RNS - Seuil de suggestionde glucides + Seuil de suggestion de glucides Quantité de glucides à partir de laquelle une notification est envoyée Transmettre les Gly vers xDrip+ Dans xDrip+ veuillez séléctionner 640g/Eversense comme source de données diff --git a/app/src/main/res/values-pt-rPT/exam.xml b/app/src/main/res/values-pt-rPT/exam.xml index cf9f53bcf4..737c4c23a9 100644 --- a/app/src/main/res/values-pt-rPT/exam.xml +++ b/app/src/main/res/values-pt-rPT/exam.xml @@ -115,7 +115,7 @@ https://androidaps.readthedocs.io/en/latest/EN/Usage/Extended-Carbs.html Tópico: Monitorização Remota Como pode monitorizar AAPS do seu filho remotamente? - A usar um site Nightscout. + Usando um site Nightscout. App Dex om Follow se estiver a usar a app original Dexcom (Glic apenas). Dexcom Follow se estiver a usar a app xDrip. xDrip a correr no modo seguidor. diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 1b8cc9057a..f496fef1ea 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -143,7 +143,7 @@ Outro Medidor Sensor - Hidratos de Carbono + Hidratos Insulina Tempo Hidratos Dividir @@ -370,12 +370,12 @@ A Executar Definições da bomba virtual Enviar estado para NS - NSCliente - NSCI + ClienteNS + CLNS URL: Rolar automático Reiniciar - NSCliente + ClienteNS Nightscout URL Introduza o Nightscout URL NS API secret @@ -388,7 +388,7 @@ Estado: Em pausa Limpar Registo - NSCliente sem permissões para alterar dados. Tem a senha API correta? + ClienteNS sem permissões para alterar dados. Tem a senha API correta? Definições Wear Mostrar IOB detalhada Dividir IOB entre IOB de bolus e de basal na face do relógio @@ -506,7 +506,7 @@ Cancelar Nem todos perfis foram carregados! Valores não guardados! - Activar transmissões para outras aplicações (como xDrip). Não habilite se tiver mais de uma instância de AAPS ou NSClient instalado! + Activar transmissões para outras aplicações (como xDrip). Não habilite se tiver mais de uma instância de AAPS ou ClienteNS instalado! Activar partilha local. ACTIVIDADE & FEEDBACK HIDRATOS & BÓLUS @@ -570,7 +570,7 @@ Quando Hidratos são sugeridos, quantos hidratos irá solicitar uma notificação Enviar dados Glic. para xDrip+ Seleccionar 640g/Eversense como fonte no xDrip+ - Glic NSCliente + Glic ClienteNS Cálculos Glic Cálculo de Bólus IOB Cálculo de Basal IOB @@ -584,7 +584,7 @@ Cálculo alvo temporário Loop activado APS seleccionado - NSCLiente tem permissão de escrita + ClienteNS tem permissão de escrita Modo fechado ativado IOB máxima definida correctamente Glicemia disponivel desde a fonte selecionada @@ -759,7 +759,7 @@ Resultado cálculos incluídos no Assistente: Configurações Ecrã Configurações Gerais - Activar NSCliente + Activar ClienteNS Bem-vindo ao assistente de configuração. Vai guiá-lo(a) através do processo de instalação\n Configurações da bomba Ler estado @@ -770,7 +770,7 @@ Configurar plugin Sensibilidade Plugin de Sensibilidade é usado para detecção de sensibilidade e cálculos COB. Para mais info visite: https://github.com/MilosKozak/AndroidAPS/wiki/Sensitivity-detection-and-COB - NSCliente gere a ligação ao Nightscout. Pode saltar esta parte mas não será possível passar os objectivos até que o configure. + ClienteNS gere a ligação ao Nightscout. Pode saltar esta parte mas não será possível passar os objectivos até que o configure. Lembre-se: novos perfis de insulina requerem diâmetro de pelo menos 5h. DIA 5–6h no novo perfil é igual ao diâmetro 3h nos antigos perfis de insulina. Configure a fonte das glicemias Por favor seleccione a fonte do perfil. Se o paciente é uma criança deverá utilizar perfil NS. Se ninguém o está a seguir no Nightscout provavelmente preferirá um perfil Local. Lembre-se que apenas está a escolher a fonte de perfil. Para o utilizar terá que o activar executando \"Troca Perfil\" @@ -821,7 +821,7 @@ Sem dados Autosens disponíveis Definições de registo Repor definições por defeito - Erro de funcionamento do NSCliente. Pondere reiniciar o NS e NSCliente. + Erro de funcionamento do ClienteNS. Pondere reiniciar o NS e ClienteNS. AS Disponível %1$s disponível Fuso horário diff --git a/app/src/main/res/values-sv-rSE/exam.xml b/app/src/main/res/values-sv-rSE/exam.xml index 507b63f02f..5a94009f00 100644 --- a/app/src/main/res/values-sv-rSE/exam.xml +++ b/app/src/main/res/values-sv-rSE/exam.xml @@ -130,7 +130,7 @@ Om du ändrar ISF-värdet i din profil är det tillräckligt för att tillämpa ändringen. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#insulin-sensitivity-factor-isf-mmol-l-u-or-mg-dl-u https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html - Ämne: IC-kvoten + Ämne: KH-kvot Högre IC-kvot leder till mindre insulin som levereras för en given mängd kolhydrater. Lägre IC-kvot leder till mindre insulin som levereras för en given mängd kolhydrater. Om du har 0 COB, kommer en förändring av IC-kvoten leda till en annan mängd insulin för att korrigera din BG-nivå. diff --git a/app/src/main/res/values-sv-rSE/strings.xml b/app/src/main/res/values-sv-rSE/strings.xml index 511f476671..0f432004a8 100644 --- a/app/src/main/res/values-sv-rSE/strings.xml +++ b/app/src/main/res/values-sv-rSE/strings.xml @@ -132,12 +132,12 @@ Eversense-appen. Closed Loop Open Loop Stopp innan lågt - Loop avstängd + Loop inaktiverad Inaktivera loop Aktivera loop Ny rekommendation tillgänglig Versionen av Nightscout stöds inte - LOOP STOPPAD PGA BEGRÄNSNINGAR + LOOP INAKTIVERAD PGA BEGRÄNSNINGAR IOB från basal Bolusspärr aktiverad Kolhydratsspärr aktiverad @@ -251,9 +251,9 @@ Eversense-appen. Laddar upp Bolus avbruten Avbryter bolus - Loop stängdes av. - Loop aktiverades - Loop är avstängd + Loop inaktiverad. + Loop aktiverad + Loop är inaktiverad Loop är aktiverad %1$.2f begränsat till %2$.2f Värdet %1$s är utanför hård begränsning @@ -423,7 +423,7 @@ Eversense-appen. Återuppta Återanslut Pump Fel duration - Loop pausad. + Loop pausad Loop återupptagen 15 min trend COB @@ -675,7 +675,7 @@ Eversense-appen. Basaler Ingen åtgärd vald. Inget ändras. Starta \"Hypo\" - Du kör nu dev-versionen. Closed Loop inte tillåtet. + Du kör nu dev-versionen. Closed Loop inaktiverat. Engineering Mode aktiverat Engineering Mode inte aktiverat och appen körs inte som release Läser basalprofil diff --git a/core/src/main/res/values-fr-rFR/strings.xml b/core/src/main/res/values-fr-rFR/strings.xml index 85f5ce3e2f..4f7e558f4d 100644 --- a/core/src/main/res/values-fr-rFR/strings.xml +++ b/core/src/main/res/values-fr-rFR/strings.xml @@ -10,7 +10,7 @@ Erreur injection basal temporaire %1$.2fU vont être injectées Attente connection pompe - Connexion à %1$s en cours + Connexion à %1$d en cours Injection en cours %1$.2fU Connexion Connection en cours diff --git a/core/src/main/res/values-pt-rPT/strings.xml b/core/src/main/res/values-pt-rPT/strings.xml index eae9d66156..3375afa7a1 100644 --- a/core/src/main/res/values-pt-rPT/strings.xml +++ b/core/src/main/res/values-pt-rPT/strings.xml @@ -8,7 +8,7 @@ Perfil Basal actualizado na bomba Entrada Inválida Erro na administração da Basal Temp - A ser administrada %1$.2fU + Quantidade a ser administrada %1$.2fU À espera da bomba A ligar durante %1$d s A administrar %1$.2fU @@ -130,7 +130,7 @@ Questão Exercício Mudança Local Bomba - Colocação do Sensor CGM + Colocação Sensor CGM Início do Sensor CGM Mudança de Cartucho de Insulina Troca de Perfil diff --git a/dana/src/main/res/values-de-rDE/strings.xml b/dana/src/main/res/values-de-rDE/strings.xml index 4d7efc4638..56f9391d6e 100644 --- a/dana/src/main/res/values-de-rDE/strings.xml +++ b/dana/src/main/res/values-de-rDE/strings.xml @@ -29,6 +29,9 @@ Pumpenbatterie entladen Verstopfung Reservoir leer + Gewindestange prüfen + max. Basal + Tagesmaximum Alarm BZ-Messung Restinsulin Versäumter Bolus diff --git a/dana/src/main/res/values-pt-rBR/strings.xml b/dana/src/main/res/values-pt-rBR/strings.xml index 445b5cfe64..d641178465 100644 --- a/dana/src/main/res/values-pt-rBR/strings.xml +++ b/dana/src/main/res/values-pt-rBR/strings.xml @@ -12,9 +12,11 @@ Erro no comando Erro velocidade Transgressão limite insulina - Pedido: %1$.2fU Entregue: %2$.2fU Código Erro: %3$s + Pedido: %1$.2fU Administrado: %2$.2fU Código Erro: %3$s Valor não definido corretamente Coloque o incremento da basal em 0.01 U/h + Repor as informações de emparelhamento? + %1$s\nModelo: %2$02X\nProtocolo: %3$02X\nCódigo: %4$02X A processar acção Habilitar bólus prolongado na bomba Administrado @@ -22,6 +24,7 @@ Firmware bomba não suportado Erro Bomba Bateria fraca + A administrar menos que a taxa de base predefinida Encerrar Bomba Bateria da Bomba Descarregada Oclusão @@ -29,6 +32,7 @@ Alerta medição da glicemia Nível de insulina restante Bólus não administrado + Informações de emparelhamento inválidas. A solicitar novo emparelhamento A obter estado bomba A procurar o estado do bólus prolongado A obter estado bólus @@ -39,7 +43,7 @@ Grande diferença horária:\n A diferença de hora para a bomba é superior a 1.5h.\nPor favor ajuste manualmente a hora na bomba e certifique-se que a leitura do histórico da bomba não provoca problemas.\nSe possível apague o histórico da bomba antes de modificar a hora ou desabilite o loop durante toda a duração de acção da insulina (DIA) depois da ultima entrada no histórico da bomba ou mais um DIA desde o momento da correcção, qual delas seja a que mantenha o loop aberto durante mais tempo. Emparelhe a sua bomba com o seu telefone! Aproximação do limite diário de insulina - A iniciar administração de bolus + A iniciar administração de bólus A aguardar o final do bolus. Restam %1$d seg. A parar basal temp A configurar bólus prolongado @@ -61,6 +65,55 @@ Purgar Opções do utilizador Formato hora + Botão rolamento + Sinal ao pressionar botão + Alarme + Som + Vibrar + Ambos + LCD na hora [segundos] + Luz de fundo na hora [segundos] + Unidades de Glicose + Desligar [horas] + Reservatório baixo [Unidades] + Gravar opções para a bomba + Integração para bombas DANA Diabecare R + Integração para bombas DANA Diabecare R Coreanas + Integração para as bombas DANA Diabecare R com firmware actualizado + DANA + Nenhum dispositivo bluetooth encontrado + Dispositivo seleccionado não foi encontrado + Mudar de modo U/d para U/h na bomba + DanaR Coreana + DanaR + Controlador bomba corrigido + DanaRv2 + Desactivar modo EasyUI na bomba + Não foi possível configurar o perfil de basal + Estado Bluetooth + IOB Bomba + Incremento Basal + Incremento Bólus + Firmware + Configurações da bomba Dana + 12h + 24h + Ligado + Desligado + Dispositivo Bluetooth DanaR + Senha da bomba (apenas v1) + Senha da bomba Usar bólus prolongado por >200%% Visualizar bólus prolongado como %% + Velocidade Bólus + Bomba seleccionada + Registar mudança de reservatório + Adicionar evento \"Mudança de Insulina\" ao careportal quando detectado no histórico + Registar mudança de canula + Adicionar evento \"Mudança Local Bomba\" ao careportal, quando detectado no histórico + PIN1 + PIN2 + Pressione OK na bomba\ne digite os 2 números mostrados\nManter o visor da bomba ligado, pressionando o botão menos até que você termine a digitação do código. + 1: (12 dígitos) + 2: (8 dígitos) diff --git a/dana/src/main/res/values-pt-rPT/strings.xml b/dana/src/main/res/values-pt-rPT/strings.xml index d641178465..2a9b392910 100644 --- a/dana/src/main/res/values-pt-rPT/strings.xml +++ b/dana/src/main/res/values-pt-rPT/strings.xml @@ -29,6 +29,9 @@ Bateria da Bomba Descarregada Oclusão Reservatório vazio + Verificar Eixo + Máx Basal + Máx Diário Alerta medição da glicemia Nível de insulina restante Bólus não administrado From 9fc84dbeebedd9afece8cb975507d34191de0f5d Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Thu, 21 May 2020 00:09:31 +1200 Subject: [PATCH 14/45] Add required functions --- .../info/nightscout/androidaps/data/Profile.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/src/main/java/info/nightscout/androidaps/data/Profile.java b/core/src/main/java/info/nightscout/androidaps/data/Profile.java index 4aaa5848fb..972730ca3d 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/core/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -523,13 +523,28 @@ public class Profile { return ret; } + public double getTargetUnits() { + if (units.equals(Constants.MGDL)) { + return getTargetMgdl(secondsFromMidnight()); + } else { + return getTargetMmol(secondsFromMidnight()); + } + } + public double getTargetMgdl() { return getTargetMgdl(secondsFromMidnight()); } + public double getTargetMmol() { + return getTargetMmol(secondsFromMidnight()); + } + public double getTargetMgdl(int timeAsSeconds) { return toMgdl((getTargetLowTimeFromMidnight(timeAsSeconds) + getTargetHighTimeFromMidnight(timeAsSeconds)) / 2, units); } + public double getTargetMmol(int timeAsSeconds) { + return toMmol((getTargetLowTimeFromMidnight(timeAsSeconds) + getTargetHighTimeFromMidnight(timeAsSeconds)) / 2, units); + } public double getTargetLowMgdl() { return toMgdl(getTargetLowTimeFromMidnight(secondsFromMidnight()), units); From 3c2d5ff3d6d67676a7a6fef22268be1609be51be Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Thu, 21 May 2020 00:10:16 +1200 Subject: [PATCH 15/45] Add targetBG --- app/src/main/assets/OpenAPSSMB/determine-basal.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/OpenAPSSMB/determine-basal.js b/app/src/main/assets/OpenAPSSMB/determine-basal.js index 00a9c1d0a2..fbc0a4de9f 100644 --- a/app/src/main/assets/OpenAPSSMB/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMB/determine-basal.js @@ -407,6 +407,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ , 'bg': bg , 'tick': tick , 'eventualBG': eventualBG + , 'targetBG': target_bg , 'insulinReq': 0 , 'reservoir' : reservoir_data // The expected reservoir volume at which to deliver the microbolus (the reservoir volume from right before the last pumphistory run) , 'deliverAt' : deliverAt // The time at which the microbolus should be delivered From a20008c0dbb6035c025808257ad80fdd9bfed83c Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Thu, 21 May 2020 00:10:51 +1200 Subject: [PATCH 16/45] Add TargetBG --- .../plugins/aps/openAPSSMB/DetermineBasalResultSMB.java | 3 +++ .../info/nightscout/androidaps/plugins/aps/loop/APSResult.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java index dae170d5d9..f8f72c6c87 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java @@ -51,6 +51,9 @@ public class DetermineBasalResultSMB extends APSResult { } else { smb = 0d; } + if (result.has("targetBG")) { + targetBG = result.getDouble("targetBG"); + } if (result.has("deliverAt")) { String date = result.getString("deliverAt"); diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java b/core/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java index 84ab8e5661..359ed88560 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.java @@ -62,6 +62,7 @@ public class APSResult { public boolean hasPredictions = false; public double smb = 0d; // super micro bolus in units public long deliverAt = 0; + public double targetBG = 0d; public Constraint inputConstraints; @@ -184,6 +185,7 @@ public class APSResult { newResult.smbConstraint = smbConstraint; newResult.percent = percent; newResult.usePercent = usePercent; + newResult.targetBG = targetBG; } From 77a5af75e22f5115b637404606057b926361a16c Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Thu, 21 May 2020 00:11:36 +1200 Subject: [PATCH 17/45] Display when Target BG is overidden --- .../general/overview/OverviewFragment.kt | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) 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 93c112f745..d3038090b6 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 @@ -646,6 +646,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } else { overview_apsmode_text?.visibility = View.GONE } + val lastRun = loopPlugin.lastRun // temp target val tempTarget = treatmentsPlugin.tempTargetFromHistory @@ -654,9 +655,27 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning)) overview_temptarget?.text = Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end(), resourceHelper) } else { - overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) - overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) - overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) + //If the target is not the same as set in the profile then oref has overridden it + //show this change to the user if it exists + if (lastRun != null){ + var targetused = lastRun!!.constraintsProcessed!!.targetBG + if (units == Constants.MMOL) + targetused *= Constants.MGDL_TO_MMOLL + + if (profile.targetUnits != targetused) { + overview_temptarget?.text = targetused.toString() + overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) + overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground)) + }else{ + overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) + overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) + overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) + } + }else { + overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) + overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) + overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) + } } // Basal, TBR @@ -741,7 +760,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } overview_cob?.text = cobText - val lastRun = loopPlugin.lastRun val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT // pump status from ns From 723c0292289ee4c441ec5d9b94ac245cdb57ef1a Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Thu, 21 May 2020 02:20:38 +1200 Subject: [PATCH 18/45] Deal with 0.0 if AMA is used --- .../plugins/general/overview/OverviewFragment.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 d3038090b6..547dc3d85b 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 @@ -657,8 +657,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } else { //If the target is not the same as set in the profile then oref has overridden it //show this change to the user if it exists - if (lastRun != null){ - var targetused = lastRun!!.constraintsProcessed!!.targetBG + var targetused = lastRun?.constraintsProcessed?.targetBG + if (targetused != null && targetused != 0.0) { if (units == Constants.MMOL) targetused *= Constants.MGDL_TO_MMOLL @@ -666,12 +666,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList overview_temptarget?.text = targetused.toString() overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground)) - }else{ + } else { overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) } - }else { + } else { overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) @@ -696,7 +696,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList if (activeTemp != null) overview_basebasal_icon.setImageResource(if (activeTemp.tempBasalConvertedToPercent(System.currentTimeMillis(), profile) > 100) R.drawable.icon_cp_basal_tbr_high else R.drawable.icon_cp_basal_tbr_low) else - overview_basebasal_icon.setImageResource( R.drawable.icon_cp_basal_no_tbr ) + overview_basebasal_icon.setImageResource(R.drawable.icon_cp_basal_no_tbr) // Extended bolus val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) @@ -777,7 +777,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList // Sensitivity if (sp.getBoolean(R.string.key_openapsama_useautosens, false) && constraintChecker.isAutosensModeEnabled().value()) { overview_sensitivity_icon.setImageResource(R.drawable.ic_swap_vert_black_48dp_green) - }else { + } else { overview_sensitivity_icon.setImageResource(R.drawable.ic_x_swap_vert_48px_green) } From bf412ea798c85488fe28d62c7b69a312f3fae2a6 Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Thu, 21 May 2020 04:19:22 +1200 Subject: [PATCH 19/45] refractor --- .../androidaps/plugins/general/overview/OverviewFragment.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 547dc3d85b..3891ba6b7e 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 @@ -659,11 +659,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList //show this change to the user if it exists var targetused = lastRun?.constraintsProcessed?.targetBG if (targetused != null && targetused != 0.0) { - if (units == Constants.MMOL) - targetused *= Constants.MGDL_TO_MMOLL - if (profile.targetUnits != targetused) { - overview_temptarget?.text = targetused.toString() + if (((profile.targetLowMgdl+profile.targetHighMgdl)/2)!= targetused) { + overview_temptarget?.text = Profile.toTargetRangeString(targetused, targetused, Constants.MGDL, units) overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground)) } else { From e053d3601db7729f776113d2e96f72c32b1970e7 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 20 May 2020 19:36:22 +0200 Subject: [PATCH 20/45] regional independent test --- .../androidaps/utils/DecimalFormatterTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/test/java/info/nightscout/androidaps/utils/DecimalFormatterTest.java b/app/src/test/java/info/nightscout/androidaps/utils/DecimalFormatterTest.java index e02e5fe28b..a7112fae48 100644 --- a/app/src/test/java/info/nightscout/androidaps/utils/DecimalFormatterTest.java +++ b/app/src/test/java/info/nightscout/androidaps/utils/DecimalFormatterTest.java @@ -10,26 +10,26 @@ public class DecimalFormatterTest { @Test public void to0DecimalTest() { - Assert.assertEquals("1", DecimalFormatter.to0Decimal(1.33d)); - Assert.assertEquals("1U", DecimalFormatter.to0Decimal(1.33d, "U")); + Assert.assertEquals("1", DecimalFormatter.to0Decimal(1.33d).replace(",", ".")); + Assert.assertEquals("1U", DecimalFormatter.to0Decimal(1.33d, "U").replace(",", ".")); } @Test public void to1DecimalTest() { - Assert.assertEquals("1.3", DecimalFormatter.to1Decimal(1.33d)); - Assert.assertEquals("1.3U", DecimalFormatter.to1Decimal(1.33d, "U")); + Assert.assertEquals("1.3", DecimalFormatter.to1Decimal(1.33d).replace(",", ".")); + Assert.assertEquals("1.3U", DecimalFormatter.to1Decimal(1.33d, "U").replace(",", ".")); } @Test public void to2DecimalTest() { - Assert.assertEquals("1.33", DecimalFormatter.to2Decimal(1.3333d)); - Assert.assertEquals("1.33U", DecimalFormatter.to2Decimal(1.3333d, "U")); + Assert.assertEquals("1.33", DecimalFormatter.to2Decimal(1.3333d).replace(",", ".")); + Assert.assertEquals("1.33U", DecimalFormatter.to2Decimal(1.3333d, "U").replace(",", ".")); } @Test public void to3DecimalTest() { - Assert.assertEquals("1.333", DecimalFormatter.to3Decimal(1.3333d)); - Assert.assertEquals("1.333U", DecimalFormatter.to3Decimal(1.3333d, "U")); + Assert.assertEquals("1.333", DecimalFormatter.to3Decimal(1.3333d).replace(",", ".")); + Assert.assertEquals("1.333U", DecimalFormatter.to3Decimal(1.3333d, "U").replace(",", ".")); } @Test From 06e97400f7fe07ddfbe327c0cef93316c0826d8f Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 20 May 2020 22:34:09 +0200 Subject: [PATCH 21/45] Simplify show-targets view logic --- .../general/overview/OverviewFragment.kt | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) 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 3891ba6b7e..c9ea872345 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 @@ -655,20 +655,13 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning)) overview_temptarget?.text = Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end(), resourceHelper) } else { - //If the target is not the same as set in the profile then oref has overridden it - //show this change to the user if it exists - var targetused = lastRun?.constraintsProcessed?.targetBG - if (targetused != null && targetused != 0.0) { + // If the target is not the same as set in the profile then oref has overridden it + val targetUsed = lastRun?.constraintsProcessed?.targetBG ?: 0.0 - if (((profile.targetLowMgdl+profile.targetHighMgdl)/2)!= targetused) { - overview_temptarget?.text = Profile.toTargetRangeString(targetused, targetused, Constants.MGDL, units) - overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) - overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground)) - } else { - overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) - overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) - overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) - } + if (targetUsed != 0.0 && profile.targetMgdl != targetUsed) { + overview_temptarget?.text = Profile.toTargetRangeString(targetUsed, targetUsed, Constants.MGDL, units) + overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) + overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground)) } else { overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) @@ -899,4 +892,4 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } } } -} \ No newline at end of file +} From 87782377a58f4b0f98d8e060e2deab31f4d2e930 Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Thu, 21 May 2020 10:21:37 +1200 Subject: [PATCH 22/45] Remove not needed functions --- .../info/nightscout/androidaps/data/Profile.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/data/Profile.java b/core/src/main/java/info/nightscout/androidaps/data/Profile.java index 972730ca3d..21eb288c09 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/core/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -523,29 +523,13 @@ public class Profile { return ret; } - public double getTargetUnits() { - if (units.equals(Constants.MGDL)) { - return getTargetMgdl(secondsFromMidnight()); - } else { - return getTargetMmol(secondsFromMidnight()); - } - } - public double getTargetMgdl() { return getTargetMgdl(secondsFromMidnight()); } - public double getTargetMmol() { - return getTargetMmol(secondsFromMidnight()); - } - public double getTargetMgdl(int timeAsSeconds) { return toMgdl((getTargetLowTimeFromMidnight(timeAsSeconds) + getTargetHighTimeFromMidnight(timeAsSeconds)) / 2, units); } - public double getTargetMmol(int timeAsSeconds) { - return toMmol((getTargetLowTimeFromMidnight(timeAsSeconds) + getTargetHighTimeFromMidnight(timeAsSeconds)) / 2, units); - } - public double getTargetLowMgdl() { return toMgdl(getTargetLowTimeFromMidnight(secondsFromMidnight()), units); } From 72943a5236fd6e7ffdb93f7ac235df7c385076a9 Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Fri, 22 May 2020 11:08:01 +1200 Subject: [PATCH 23/45] Add back setting adjustment --- .../plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 6b5f5363b0..8b894e8579 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 @@ -259,8 +259,8 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("low_temptarget_lowers_sensitivity", false); - mProfile.put("sensitivity_raises_target", SMBDefaults.sensitivity_raises_target); - mProfile.put("resistance_lowers_target", SMBDefaults.resistance_lowers_target); + mProfile.put("sensitivity_raises_target", sp.getBoolean(resourceHelper.gs(R.string.key_sensitivity_raises_target),SMBDefaults.sensitivity_raises_target)); + mProfile.put("resistance_lowers_target", sp.getBoolean(resourceHelper.gs(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); From d40188f04e429283e17b2653ab2b2c363b53805d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 23 May 2020 15:39:05 +0200 Subject: [PATCH 24/45] Default language option --- .../nightscout/androidaps/MainActivity.kt | 2 +- .../info/nightscout/androidaps/MainApp.java | 2 +- .../activities/PreferencesActivity.kt | 2 +- .../activities/SingleFragmentActivity.kt | 2 +- .../activities/PrefImportListActivity.kt | 2 +- .../androidaps/setupwizard/SWDefinition.kt | 2 +- .../setupwizard/SetupWizardActivity.kt | 2 +- .../androidaps/utils/JSONFormatter.java | 25 ++++--------- app/src/main/res/values/arrays.xml | 2 + app/src/main/res/values/strings.xml | 1 + .../activities/DialogAppCompatActivity.kt | 2 +- .../activities/NoSplashAppCompatActivity.kt | 2 +- .../androidaps/events/EventRebuildTabs.kt | 2 +- .../nightscout/androidaps/utils/HtmlHelper.kt | 7 +--- .../androidaps/utils/locale/LocaleHelper.kt | 37 ++++++++++--------- 15 files changed, 40 insertions(+), 52 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index c78aaedaf5..f25cf49fc9 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -49,7 +49,7 @@ import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicato import info.nightscout.androidaps.setupwizard.SetupWizardActivity import info.nightscout.androidaps.utils.AndroidPermission import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.LocaleHelper +import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 126ba47d22..6b78a50599 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -37,7 +37,7 @@ import info.nightscout.androidaps.receivers.NetworkChangeReceiver; import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver; import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.utils.ActivityMonitor; -import info.nightscout.androidaps.utils.LocaleHelper; +import info.nightscout.androidaps.utils.locale.LocaleHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; public class MainApp extends DaggerApplication { diff --git a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt index ad3961c883..ea90f4b250 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt @@ -5,7 +5,7 @@ import android.os.Bundle import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceScreen import info.nightscout.androidaps.R -import info.nightscout.androidaps.utils.LocaleHelper +import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.kt index 9e62f16c97..0193b690a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.kt @@ -9,7 +9,7 @@ import dagger.android.support.DaggerAppCompatActivity import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.plugins.configBuilder.PluginStore -import info.nightscout.androidaps.utils.LocaleHelper +import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.protection.ProtectionCheck import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt index 7703166d04..6be8b5e020 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt @@ -19,7 +19,7 @@ import info.nightscout.androidaps.plugins.general.maintenance.PrefsFileContract import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsFormatsHandler import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsMetadataKey import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsStatus -import info.nightscout.androidaps.utils.LocaleHelper +import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.resources.ResourceHelper import kotlinx.android.synthetic.main.maintenance_importlist_activity.* import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt index c8e406881b..d0f8c29138 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt @@ -34,7 +34,7 @@ import info.nightscout.androidaps.setupwizard.elements.* import info.nightscout.androidaps.setupwizard.events.EventSWUpdate import info.nightscout.androidaps.utils.AndroidPermission import info.nightscout.androidaps.utils.CryptoUtil -import info.nightscout.androidaps.utils.LocaleHelper.update +import info.nightscout.androidaps.utils.locale.LocaleHelper.update import info.nightscout.androidaps.utils.extensions.isRunningTest import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.resources.ResourceHelper diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt index b265af0d4c..44af0e1312 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt @@ -20,7 +20,7 @@ import info.nightscout.androidaps.setupwizard.elements.SWItem import info.nightscout.androidaps.setupwizard.events.EventSWUpdate import info.nightscout.androidaps.utils.AndroidPermission import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.LocaleHelper.update +import info.nightscout.androidaps.utils.locale.LocaleHelper.update import info.nightscout.androidaps.utils.alertDialogs.OKDialog.show import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation import info.nightscout.androidaps.utils.resources.ResourceHelper diff --git a/app/src/main/java/info/nightscout/androidaps/utils/JSONFormatter.java b/app/src/main/java/info/nightscout/androidaps/utils/JSONFormatter.java index 9b754ac47a..db1f6af239 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/JSONFormatter.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/JSONFormatter.java @@ -1,6 +1,5 @@ package info.nightscout.androidaps.utils; -import android.os.Build; import android.text.Html; import android.text.Spanned; @@ -8,7 +7,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Iterator; @@ -24,33 +22,24 @@ public class JSONFormatter { final JsonVisitor visitor = new JsonVisitor(1, '\t'); try { if (jsonString.equals("undefined")) - return Html.fromHtml("undefined"); + return HtmlHelper.INSTANCE.fromHtml("undefined"); else if (jsonString.getBytes()[0] == '[') - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - return Html.fromHtml(visitor.visit(new JSONArray(jsonString), 0), Html.FROM_HTML_MODE_COMPACT); - } else { - return Html.fromHtml(visitor.visit(new JSONArray(jsonString), 0)); - } - else { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - return Html.fromHtml(visitor.visit(new JSONObject(jsonString), 0), Html.FROM_HTML_MODE_COMPACT); - } else { - return Html.fromHtml(visitor.visit(new JSONObject(jsonString), 0)); - } - } + return HtmlHelper.INSTANCE.fromHtml(visitor.visit(new JSONArray(jsonString), 0)); + else + return HtmlHelper.INSTANCE.fromHtml(visitor.visit(new JSONObject(jsonString), 0)); } catch (JSONException e) { log.error("Unhandled exception", e); - return Html.fromHtml(""); + return HtmlHelper.INSTANCE.fromHtml(""); } } public static Spanned format(final JSONObject object) { final JsonVisitor visitor = new JsonVisitor(1, '\t'); try { - return Html.fromHtml(visitor.visit(object, 0)); + return HtmlHelper.INSTANCE.fromHtml(visitor.visit(object, 0)); } catch (JSONException e) { log.error("Unhandled exception", e); - return Html.fromHtml(""); + return HtmlHelper.INSTANCE.fromHtml(""); } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 7ca80a7af9..0d8f4134a1 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -22,6 +22,7 @@ + @string/default_lang @string/en_lang @string/af_lang @string/bg_lang @@ -45,6 +46,7 @@ @string/zh_lang + default en af bg diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4a4595fab4..140c3310cf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,5 @@ + System default English Czech Afrikaans diff --git a/core/src/main/java/info/nightscout/androidaps/activities/DialogAppCompatActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/DialogAppCompatActivity.kt index e2aa70d960..14f941a422 100644 --- a/core/src/main/java/info/nightscout/androidaps/activities/DialogAppCompatActivity.kt +++ b/core/src/main/java/info/nightscout/androidaps/activities/DialogAppCompatActivity.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.activities import android.content.Context import dagger.android.support.DaggerAppCompatActivity -import info.nightscout.androidaps.utils.LocaleHelper +import info.nightscout.androidaps.utils.locale.LocaleHelper open class DialogAppCompatActivity : DaggerAppCompatActivity() { public override fun attachBaseContext(newBase: Context) { diff --git a/core/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt index 060f1a8c2e..6ded8b95b5 100644 --- a/core/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt +++ b/core/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt @@ -4,7 +4,7 @@ import android.content.Context import android.os.Bundle import dagger.android.support.DaggerAppCompatActivity import info.nightscout.androidaps.core.R -import info.nightscout.androidaps.utils.LocaleHelper +import info.nightscout.androidaps.utils.locale.LocaleHelper //@Suppress("registered") open class NoSplashAppCompatActivity : DaggerAppCompatActivity() { diff --git a/core/src/main/java/info/nightscout/androidaps/events/EventRebuildTabs.kt b/core/src/main/java/info/nightscout/androidaps/events/EventRebuildTabs.kt index aa0db3467a..3d4180f29f 100644 --- a/core/src/main/java/info/nightscout/androidaps/events/EventRebuildTabs.kt +++ b/core/src/main/java/info/nightscout/androidaps/events/EventRebuildTabs.kt @@ -1,3 +1,3 @@ package info.nightscout.androidaps.events -class EventRebuildTabs @JvmOverloads constructor(var recreate: Boolean = false) : Event() +class EventRebuildTabs constructor(var recreate: Boolean = false) : Event() diff --git a/core/src/main/java/info/nightscout/androidaps/utils/HtmlHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/HtmlHelper.kt index b79fe884b4..dd0da3b72f 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/HtmlHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/HtmlHelper.kt @@ -6,11 +6,6 @@ import android.text.Spanned object HtmlHelper { fun fromHtml(source: String): Spanned { - // API level 24 to replace call - @Suppress("DEPRECATION") - return when { - Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY) - else -> Html.fromHtml(source) - } + return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY) } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt index 7180bf7927..d7bc0a8ce5 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt @@ -1,22 +1,23 @@ -package info.nightscout.androidaps.utils +package info.nightscout.androidaps.utils.locale import android.content.Context import android.content.ContextWrapper -import android.os.Build import android.os.LocaleList import androidx.preference.PreferenceManager import info.nightscout.androidaps.core.R import java.util.* object LocaleHelper { - private fun currentLanguage(context: Context): String = - PreferenceManager.getDefaultSharedPreferences(context).getString(context.getString(R.string.key_language), "en") - ?: "en" + private fun selectedLanguage(context: Context): String = + PreferenceManager.getDefaultSharedPreferences(context).getString(context.getString(R.string.key_language), "default") + ?: "default" // injection not possible because of use in attachBaseContext //SP.getString(R.string.key_language, Locale.getDefault().language) private fun currentLocale(context: Context): Locale { - val language = currentLanguage(context) + val language = selectedLanguage(context) + if (language == "default") return Locale.getDefault() + var locale = Locale(language) if (language.contains("_")) { // language with country like pt_BR defined in arrays.xml @@ -27,8 +28,10 @@ object LocaleHelper { return locale } - @Suppress("DEPRECATION") fun update(context: Context) { + // no action for system default language + if (selectedLanguage(context) == "default") return + val locale = currentLocale(context) Locale.setDefault(locale) val resources = context.resources @@ -39,20 +42,18 @@ object LocaleHelper { resources.updateConfiguration(configuration, resources.displayMetrics) } - fun wrap(ctx: Context): ContextWrapper { + fun wrap(ctx: Context): Context { + // no action for system default language + if (selectedLanguage(ctx) == "default") return ctx + val res = ctx.resources val configuration = res.configuration val newLocale = currentLocale(ctx) - val context = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - configuration.setLocale(newLocale) - val localeList = LocaleList(newLocale) - LocaleList.setDefault(localeList) - configuration.locales = localeList - ctx.createConfigurationContext(configuration) - } else { - configuration.setLocale(newLocale) - ctx.createConfigurationContext(configuration) - } + configuration.setLocale(newLocale) + val localeList = LocaleList(newLocale) + LocaleList.setDefault(localeList) + configuration.locales = localeList + val context = ctx.createConfigurationContext(configuration) return ContextWrapper(context) } } \ No newline at end of file From 4f41890add4b00dca59abffee5edad8068840c78 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 23 May 2020 16:30:03 +0200 Subject: [PATCH 25/45] Add additionnal setting for automated deliveries and add both in pumpcontrol pref - previous setting is for manual bolus and extended bolus - This new setting is for SMB and temp basal with TBR emulation You can change settings name and summary if you find better... --- .../plugins/pump/insight/LocalInsightPlugin.java | 11 ++++++----- app/src/main/res/values/strings.xml | 8 ++++++-- app/src/main/res/xml/pref_insight_local_full.xml | 8 +++++++- .../main/res/xml/pref_insight_local_pumpcontrol.xml | 12 ++++++++++++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index 51c6337df1..1b4e537f0c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -597,7 +597,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, bolusMessage.setDuration(0); bolusMessage.setExtendedAmount(0); bolusMessage.setImmediateAmount(insulin); - bolusMessage.setVibration(sp.getBoolean("insight_disable_vibration",false)); + bolusMessage.setVibration(sp.getBoolean(detailedBolusInfo.isSMB ? R.string.key_disable_vibration_auto : R.string.key_disable_vibration ,false)); bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId(); bolusCancelled = false; } @@ -721,7 +721,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, PumpEnactResult cancelTBRResult = cancelTempBasalOnly(); if (cancelTBRResult.success) { PumpEnactResult ebResult = setExtendedBolusOnly((absoluteRate - getBaseBasalRate()) / 60D - * ((double) durationInMinutes), durationInMinutes); + * ((double) durationInMinutes), durationInMinutes, + sp.getBoolean(R.string.key_disable_vibration_auto,false)); if (ebResult.success) { result.success = true; result.enacted = true; @@ -799,7 +800,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, @NonNull @Override public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { PumpEnactResult result = cancelExtendedBolusOnly(); - if (result.success) result = setExtendedBolusOnly(insulin, durationInMinutes); + if (result.success) result = setExtendedBolusOnly(insulin, durationInMinutes, sp.getBoolean(R.string.key_disable_vibration,false)); try { fetchStatus(); readHistory(); @@ -813,7 +814,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, return result; } - public PumpEnactResult setExtendedBolusOnly(Double insulin, Integer durationInMinutes) { + public PumpEnactResult setExtendedBolusOnly(Double insulin, Integer durationInMinutes, boolean disableVibration) { PumpEnactResult result = new PumpEnactResult(getInjector()); try { DeliverBolusMessage bolusMessage = new DeliverBolusMessage(); @@ -821,7 +822,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, bolusMessage.setDuration(durationInMinutes); bolusMessage.setExtendedAmount(insulin); bolusMessage.setImmediateAmount(0); - bolusMessage.setVibration(sp.getBoolean("insight_disable_vibration",false)); + bolusMessage.setVibration(disableVibration); int bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId(); InsightBolusID insightBolusID = new InsightBolusID(); insightBolusID.bolusID = bolusID; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8033c82057..c9530266e8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1016,8 +1016,12 @@ Log alerts Enable TBR emulation Use extended boluses instead of TBRs to bypass the 250%% limit - Disable vibrations on bolus delivery - This setting is only available with Insight firmware 3.x + insight_disable_vibration + Disable vibrations on manual bolus delivery + For bolus and extended bolus (only available with Insight firmware 3.x) + insight_disable_vibration_auto + Disable vibrations on automated bolus delivery + For SMB and Temp Basal with TBR emulation (only available with Insight firmware 3.x) Disconnect delay [s] Serial number Release software version diff --git a/app/src/main/res/xml/pref_insight_local_full.xml b/app/src/main/res/xml/pref_insight_local_full.xml index 761016b287..820c12d422 100644 --- a/app/src/main/res/xml/pref_insight_local_full.xml +++ b/app/src/main/res/xml/pref_insight_local_full.xml @@ -50,10 +50,16 @@ + + + + + + Date: Sat, 23 May 2020 17:49:49 +0200 Subject: [PATCH 26/45] Update pref_insight_local_pumpcontrol.xml --- app/src/main/res/xml/pref_insight_local_pumpcontrol.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/src/main/res/xml/pref_insight_local_pumpcontrol.xml b/app/src/main/res/xml/pref_insight_local_pumpcontrol.xml index d40a48e1d0..a863e56757 100644 --- a/app/src/main/res/xml/pref_insight_local_pumpcontrol.xml +++ b/app/src/main/res/xml/pref_insight_local_pumpcontrol.xml @@ -54,12 +54,6 @@ android:summary="@string/disable_vibration_summary" android:title="@string/disable_vibration" /> - - Date: Sat, 23 May 2020 21:54:01 +0200 Subject: [PATCH 27/45] nsalarm notifications fix --- .../general/nsclient/data/NSDeviceStatus.java | 2 +- .../nsclient/services/NSClientService.java | 47 +++++++++++-------- .../notifications/NotificationWithAction.kt | 7 +-- app/src/main/res/values/strings.xml | 16 ++----- .../main/res/xml/pref_nsclientinternal.xml | 30 ++---------- 5 files changed, 39 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.java index 7195435515..757692e655 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.java @@ -331,7 +331,7 @@ public class NSDeviceStatus { // test warning level int level = Levels.INFO; long now = System.currentTimeMillis(); - if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_urgent_staledatavalue, 16) * 60 * 1000L < now) + if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_urgent_staledatavalue, 31) * 60 * 1000L < now) level = Levels.URGENT; else if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_staledatavalue, 16) * 60 * 1000L < now) level = Levels.WARN; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java index cc5057f7eb..7c4d41ca86 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java @@ -842,33 +842,42 @@ public class NSClientService extends DaggerService { } private void handleAnnouncement(JSONObject announcement) { - NSAlarm nsAlarm = new NSAlarm(announcement); - Notification notification = new NotificationWithAction(injector, nsAlarm); - rxBus.send(new EventNewNotification(notification)); - rxBus.send(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(announcement, "message", "received"))); - aapsLogger.debug(LTag.NSCLIENT, announcement.toString()); + boolean defaultVal = config.getNSCLIENT(); + if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) { + NSAlarm nsAlarm = new NSAlarm(announcement); + Notification notification = new NotificationWithAction(injector, nsAlarm); + rxBus.send(new EventNewNotification(notification)); + rxBus.send(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(announcement, "message", "received"))); + aapsLogger.debug(LTag.NSCLIENT, announcement.toString()); + } } private void handleAlarm(JSONObject alarm) { - long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L); - if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { - NSAlarm nsAlarm = new NSAlarm(alarm); - Notification notification = new NotificationWithAction(injector, nsAlarm); - rxBus.send(new EventNewNotification(notification)); + boolean defaultVal = config.getNSCLIENT(); + if (sp.getBoolean(R.string.key_ns_alarms, defaultVal)) { + long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L); + if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { + NSAlarm nsAlarm = new NSAlarm(alarm); + Notification notification = new NotificationWithAction(injector, nsAlarm); + rxBus.send(new EventNewNotification(notification)); + } + rxBus.send(new EventNSClientNewLog("ALARM", JsonHelper.safeGetString(alarm, "message", "received"))); + aapsLogger.debug(LTag.NSCLIENT, alarm.toString()); } - rxBus.send(new EventNSClientNewLog("ALARM", JsonHelper.safeGetString(alarm, "message", "received"))); - aapsLogger.debug(LTag.NSCLIENT, alarm.toString()); } private void handleUrgentAlarm(JSONObject alarm) { - long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L); - if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { - NSAlarm nsAlarm = new NSAlarm(alarm); - Notification notification = new NotificationWithAction(injector, nsAlarm); - rxBus.send(new EventNewNotification(notification)); + boolean defaultVal = config.getNSCLIENT(); + if (sp.getBoolean(R.string.key_ns_alarms, defaultVal)) { + long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L); + if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { + NSAlarm nsAlarm = new NSAlarm(alarm); + Notification notification = new NotificationWithAction(injector, nsAlarm); + rxBus.send(new EventNewNotification(notification)); + } + rxBus.send(new EventNSClientNewLog("URGENTALARM", JsonHelper.safeGetString(alarm, "message", "received"))); + aapsLogger.debug(LTag.NSCLIENT, alarm.toString()); } - rxBus.send(new EventNSClientNewLog("URGENTALARM", JsonHelper.safeGetString(alarm, "message", "received"))); - aapsLogger.debug(LTag.NSCLIENT, alarm.toString()); } public void handleNewCal(JSONArray cals, boolean isDelta) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt index f492196b29..4e85b03b5c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt @@ -22,8 +22,6 @@ class NotificationWithAction constructor( @Inject lateinit var defaultValueHelper: DefaultValueHelper @Inject lateinit var nsClientPlugin: NSClientPlugin - private var nsAlarm: NSAlarm? = null - init { injector.androidInjector().inject(this) } @@ -36,7 +34,6 @@ class NotificationWithAction constructor( } constructor (injector: HasAndroidInjector, nsAlarm: NSAlarm) : this(injector) { - this.nsAlarm = nsAlarm date = System.currentTimeMillis() when (nsAlarm.level()) { 0 -> { @@ -50,14 +47,14 @@ class NotificationWithAction constructor( id = NSALARM level = NORMAL text = nsAlarm.title() - if (nsAlarm.low() && sp.getBoolean(R.string.key_nsalarm_low, false) || nsAlarm.high() && sp.getBoolean(R.string.key_nsalarm_high, false) || nsAlarm.timeago() && sp.getBoolean(R.string.key_nsalarm_staledata, false)) soundId = R.raw.alarm + soundId = R.raw.alarm } 2 -> { id = NSURGENTALARM level = URGENT text = nsAlarm.title() - if (nsAlarm.low() && sp.getBoolean(R.string.key_nsalarm_urgent_low, false) || nsAlarm.high() && sp.getBoolean(R.string.key_nsalarm_urgent_high, false) || nsAlarm.timeago() && sp.getBoolean(R.string.key_nsalarm_staledata, false)) soundId = R.raw.urgentalarm + soundId = R.raw.urgentalarm } } buttonText = R.string.snooze diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index de9f03587e..4908f7d04f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -549,20 +549,12 @@ Do Profile Switch Pump battery age Alarm options - nsalarm_urgent_high - nsalarm_high - nsalarm_low - nsalarm_urgent_low - nsalarm_staledata - nsalarm_urgent_staledata + ns_announcements + ns_alarms nsalarm_staledatavalue nsalarm_urgent_staledatavalue - Urgent high - High - Low - Urgent low - Stale data - Urgent stale data + Create notifications from NS alarms + Create notifications from NS announcements Stale data threshold [min] Urgent stale data threshold [min] Interval for autosens [h] diff --git a/app/src/main/res/xml/pref_nsclientinternal.xml b/app/src/main/res/xml/pref_nsclientinternal.xml index 6f68d77a7b..a25aeebd2f 100644 --- a/app/src/main/res/xml/pref_nsclientinternal.xml +++ b/app/src/main/res/xml/pref_nsclientinternal.xml @@ -42,29 +42,12 @@ android:title="@string/ns_alarmoptions"> + android:key="@string/key_ns_alarms" + android:title="@string/ns_alarms" /> - - - - - - + android:key="@string/key_ns_announcements" + android:title="@string/ns_announcements" /> - - Date: Sat, 23 May 2020 22:16:55 +0200 Subject: [PATCH 28/45] fix ProfileSwitch loading --- .../info/nightscout/androidaps/db/DatabaseHelper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index 50a7d3ed47..4b8d637c47 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -1531,7 +1531,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { //add last one without duration ProfileSwitch last = getLastProfileSwitchWithoutDuration(); if (last != null) { - if (!profileSwitches.contains(last)) + if (!isInList(profileSwitches, last)) profileSwitches.add(last); } return profileSwitches; @@ -1541,6 +1541,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { return new ArrayList<>(); } + boolean isInList(List profileSwitches, ProfileSwitch last) { + for (ProfileSwitch ps : profileSwitches) { + if (ps.isEqual(last)) return true; + } + return false; + } + @Nullable private ProfileSwitch getLastProfileSwitchWithoutDuration() { try { From 87eb8021de430adf18b313dd095c6f0a2ea6137a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 23 May 2020 22:49:05 +0200 Subject: [PATCH 29/45] configbuilder fix --- .../nightscout/androidaps/plugins/configBuilder/PluginStore.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5166248e7d..3958f17d78 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 @@ -108,7 +108,7 @@ class PluginStore @Inject constructor( (activeProfile as PluginBase).setPluginEnabled(PluginType.PROFILE, true) aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting ProfileInterface") } - setFragmentVisiblities((activeSensitivity as PluginBase).name, pluginsInCategory, PluginType.PROFILE) + setFragmentVisiblities((activeProfile as PluginBase).name, pluginsInCategory, PluginType.PROFILE) // PluginType.BGSOURCE pluginsInCategory = getSpecificPluginsList(PluginType.BGSOURCE) From 828612fe6566fd64c15c58b56bc6fbedf2527485 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 24 May 2020 18:30:16 +0200 Subject: [PATCH 30/45] default language default --- app/src/main/res/xml/pref_general.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 9ae1ff6b9a..8dd2f98b76 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -14,7 +14,7 @@ android:title="@string/unitsnosemicolon" /> Date: Sun, 24 May 2020 19:07:26 +0200 Subject: [PATCH 31/45] run test in parallel --- build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.gradle b/build.gradle index fe6a38714e..d33f0f9437 100644 --- a/build.gradle +++ b/build.gradle @@ -58,3 +58,9 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir } + +subprojects { + tasks.withType(Test) { + maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 + } +} From 1cb648c09a28f99dbbd4d8d3ab90e70b2c8b72cd Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 24 May 2020 20:23:22 +0200 Subject: [PATCH 32/45] fix TriggerRecurringTime --- .../automation/triggers/TriggerRecurringTime.kt | 3 +-- .../automation/triggers/TriggerRecurringTimeTest.kt | 12 +++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt index 08343a3c94..5f6db0494d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt @@ -37,9 +37,8 @@ class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) { override fun shouldRun(): Boolean { val currentMinSinceMidnight = getMinSinceMidnight(DateUtil.now()) val scheduledDayOfWeek = Calendar.getInstance()[Calendar.DAY_OF_WEEK] - val scheduled = getMinSinceMidnight(time.value.toLong()) if (days.isSet(Objects.requireNonNull(InputWeekDay.DayOfWeek.fromCalendarInt(scheduledDayOfWeek)))) { - if (currentMinSinceMidnight >= scheduled && currentMinSinceMidnight - scheduled < 5) { + if (currentMinSinceMidnight >= time.value && currentMinSinceMidnight - time.value < 5) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt index 566a0b4c7b..ca20e1cee3 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt @@ -14,7 +14,7 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(DateUtil::class) class TriggerRecurringTimeTest : TriggerTestBase() { - var now = 1514766900000L + var now = 1514766900000L // 95 min from midnight @Before fun mock() { PowerMockito.mockStatic(DateUtil::class.java) @@ -26,20 +26,14 @@ class TriggerRecurringTimeTest : TriggerTestBase() { @Test fun shouldRunTest() { - // limit by validTo - var t: TriggerRecurringTime = TriggerRecurringTime(injector).time(94) + var t: TriggerRecurringTime = TriggerRecurringTime(injector).time(89) t.days.setAll(true) Assert.assertFalse(t.shouldRun()) // scheduled 1 min before -// t = new TriggerRecurringTime().hour(1).minute(34); -// t.setAll(true); -// Assert.assertTrue(t.shouldRun()); - - // already run t = TriggerRecurringTime(injector).time(94) t.days.setAll(true) - Assert.assertFalse(t.shouldRun()) + Assert.assertTrue(t.shouldRun()) } private var timeJson = "{\"data\":{\"WEDNESDAY\":false,\"MONDAY\":false,\"THURSDAY\":false,\"SUNDAY\":false,\"TUESDAY\":false,\"FRIDAY\":false,\"SATURDAY\":false,\"time\":4444},\"type\":\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerRecurringTime\"}" From 0a33f4c0db3b68a7ae6590ac7e35d2cd7650d1d5 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 24 May 2020 21:10:44 +0200 Subject: [PATCH 33/45] fix TriggerRecurringTime #2 --- .../general/automation/triggers/TriggerRecurringTime.kt | 4 ++-- .../general/automation/triggers/TriggerRecurringTimeTest.kt | 6 +----- .../java/info/nightscout/androidaps/utils/DateUtil.java | 5 +++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt index 5f6db0494d..ffc79e39e1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt @@ -34,8 +34,8 @@ class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) { return this } - override fun shouldRun(): Boolean { - val currentMinSinceMidnight = getMinSinceMidnight(DateUtil.now()) + override fun shouldRun() : Boolean { + val currentMinSinceMidnight = getMinSinceMidnight(dateUtil._now()) val scheduledDayOfWeek = Calendar.getInstance()[Calendar.DAY_OF_WEEK] if (days.isSet(Objects.requireNonNull(InputWeekDay.DayOfWeek.fromCalendarInt(scheduledDayOfWeek)))) { if (currentMinSinceMidnight >= time.value && currentMinSinceMidnight - time.value < 5) { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt index ca20e1cee3..46feb70b1c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt @@ -17,11 +17,7 @@ class TriggerRecurringTimeTest : TriggerTestBase() { var now = 1514766900000L // 95 min from midnight @Before fun mock() { - PowerMockito.mockStatic(DateUtil::class.java) - PowerMockito.`when`(DateUtil.now()).thenReturn(now) -// val calendar = GregorianCalendar() -// calendar.timeInMillis = now -// PowerMockito.`when`(DateUtil.gregorianCalendar()).thenReturn(calendar) + PowerMockito.`when`(dateUtil._now()).thenReturn(now) } @Test fun shouldRunTest() { diff --git a/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java index 419729a126..c5c5b68335 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java +++ b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.java @@ -261,6 +261,10 @@ public class DateUtil { return timeFrameString(timestamp - System.currentTimeMillis(), resourceHelper); } + public long _now() { + return System.currentTimeMillis(); + } + public static long now() { return System.currentTimeMillis(); } @@ -358,6 +362,7 @@ public class DateUtil { // singletons to avoid repeated allocation private static DecimalFormatSymbols dfs; private static DecimalFormat df; + public static String qs(double x, int digits) { if (digits == -1) { From c1c87b2e30acc240393e314b09e883cab559f580 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 24 May 2020 19:42:58 +0000 Subject: [PATCH 34/45] fix TriggerRecurringTimeTest --- .../general/automation/triggers/TriggerRecurringTimeTest.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt index 46feb70b1c..d23b8e8428 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt @@ -1,6 +1,8 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.MidnightTime +import info.nightscout.androidaps.utils.T import org.json.JSONObject import org.junit.Assert import org.junit.Before @@ -14,9 +16,10 @@ import org.powermock.modules.junit4.PowerMockRunner @PrepareForTest(DateUtil::class) class TriggerRecurringTimeTest : TriggerTestBase() { - var now = 1514766900000L // 95 min from midnight + var now : Long = 0L @Before fun mock() { + now = MidnightTime.calc() + T.mins(95).msecs() // 95 min from midnight PowerMockito.`when`(dateUtil._now()).thenReturn(now) } From b492e47728ee656809d64314147bd48b9246f487 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 24 May 2020 21:57:52 +0200 Subject: [PATCH 35/45] New Crowdin translations (#2660) * New translations strings.xml (Czech) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Russian) * New translations strings.xml (Portuguese, Brazilian) * New translations strings.xml (Dutch) * New translations strings.xml (German) * New translations protection.xml (German) * New translations insight_exceptions.xml (German) * New translations strings.xml (German) * New translations strings.xml (German) * New translations strings.xml (Russian) * New translations strings.xml (French) * New translations strings.xml (French) * New translations strings.xml (French) * New translations strings.xml (Romanian) * New translations strings.xml (Lithuanian) * New translations strings.xml (Portuguese, Brazilian) * New translations strings.xml (Chinese Simplified) * New translations strings.xml (Turkish) * New translations strings.xml (Swedish) * New translations strings.xml (Slovak) * New translations strings.xml (Russian) * New translations strings.xml (Portuguese) * New translations strings.xml (Polish) * New translations strings.xml (Dutch) * New translations strings.xml (Korean) * New translations strings.xml (French) * New translations strings.xml (Italian) * New translations strings.xml (Greek) * New translations strings.xml (German) * New translations strings.xml (Czech) * New translations strings.xml (Bulgarian) * New translations strings.xml (Afrikaans) * New translations strings.xml (Spanish) * New translations strings.xml (German) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (German) * New translations strings.xml (German) * New translations strings.xml (German) --- app/src/main/res/values-af-rZA/strings.xml | 6 -- app/src/main/res/values-bg-rBG/strings.xml | 6 -- app/src/main/res/values-cs-rCZ/strings.xml | 6 -- .../res/values-de-rDE/insight_exceptions.xml | 2 +- app/src/main/res/values-de-rDE/protection.xml | 4 +- app/src/main/res/values-de-rDE/strings.xml | 38 +++++----- app/src/main/res/values-el-rGR/strings.xml | 6 -- app/src/main/res/values-es-rES/strings.xml | 6 -- app/src/main/res/values-fr-rFR/strings.xml | 10 +-- app/src/main/res/values-it-rIT/strings.xml | 12 +-- app/src/main/res/values-ko-rKR/strings.xml | 6 -- app/src/main/res/values-lt-rLT/strings.xml | 6 -- app/src/main/res/values-nl-rNL/strings.xml | 7 +- app/src/main/res/values-pl-rPL/strings.xml | 6 -- app/src/main/res/values-pt-rBR/strings.xml | 75 +++++++++++++------ app/src/main/res/values-pt-rPT/strings.xml | 6 -- app/src/main/res/values-ro-rRO/strings.xml | 6 -- app/src/main/res/values-ru-rRU/strings.xml | 10 +-- app/src/main/res/values-sk-rSK/strings.xml | 6 -- app/src/main/res/values-sv-rSE/strings.xml | 6 -- app/src/main/res/values-tr-rTR/strings.xml | 6 -- app/src/main/res/values-zh-rCN/strings.xml | 6 -- core/src/main/res/values-de-rDE/strings.xml | 19 +++-- dana/src/main/res/values-cs-rCZ/strings.xml | 3 + dana/src/main/res/values-fr-rFR/strings.xml | 2 + dana/src/main/res/values-it-rIT/strings.xml | 3 + dana/src/main/res/values-ru-rRU/strings.xml | 3 + 27 files changed, 109 insertions(+), 163 deletions(-) diff --git a/app/src/main/res/values-af-rZA/strings.xml b/app/src/main/res/values-af-rZA/strings.xml index 892dc8ef6b..c0aee58045 100644 --- a/app/src/main/res/values-af-rZA/strings.xml +++ b/app/src/main/res/values-af-rZA/strings.xml @@ -381,12 +381,6 @@ Insulien ouderdom Pomp battery ouderdom Alarm Opsies - Nood hoog - Hoog - Laag - Nood laag - Ou data - Nood ou data Ou data drumpel [min] Nood ou data drumpel [min] Interval vir autosens [h] diff --git a/app/src/main/res/values-bg-rBG/strings.xml b/app/src/main/res/values-bg-rBG/strings.xml index 80bafc0b29..08b1a5a211 100644 --- a/app/src/main/res/values-bg-rBG/strings.xml +++ b/app/src/main/res/values-bg-rBG/strings.xml @@ -410,12 +410,6 @@ Смени профил Възраст на батерията на помпата Опции за аларми - Много висока - Висока - Ниска - Много ниска - Стари данни - Много стари данни Когато няма данни повече от [мин] Много стари данни при повече от [мин] Интервал за autosens [ч] diff --git a/app/src/main/res/values-cs-rCZ/strings.xml b/app/src/main/res/values-cs-rCZ/strings.xml index 9819565981..691837ca7e 100644 --- a/app/src/main/res/values-cs-rCZ/strings.xml +++ b/app/src/main/res/values-cs-rCZ/strings.xml @@ -468,12 +468,6 @@ Proveďte přepnutí profilu Stáří baterie v pumpě Nastavení alarmů - Urgentně vysoká - Vysoká - Nízká - Urgentně nízká - Zastaralá data - Urgentně zastaralá data Mezní hodnota pro zastaralá data [min] Urgentní mezní hodnota pro zastaralá data [min] Interval pro detekci senzitivity [h] diff --git a/app/src/main/res/values-de-rDE/insight_exceptions.xml b/app/src/main/res/values-de-rDE/insight_exceptions.xml index 8f8f0015de..43eeeea573 100644 --- a/app/src/main/res/values-de-rDE/insight_exceptions.xml +++ b/app/src/main/res/values-de-rDE/insight_exceptions.xml @@ -2,7 +2,7 @@ Verbindung fehlgeschlagen Verbindung unterbrochen - Pairing abgelehnt + Kopplung abgelehnt Erstellen des Sockets fehlgeschlagen Zeitüberschreitung Maximale Anzahl an Boli dieses Typs bereits aktiv diff --git a/app/src/main/res/values-de-rDE/protection.xml b/app/src/main/res/values-de-rDE/protection.xml index 0c6f2dd337..83fce7bd9a 100644 --- a/app/src/main/res/values-de-rDE/protection.xml +++ b/app/src/main/res/values-de-rDE/protection.xml @@ -1,7 +1,7 @@ Authentifizierung erforderlich - Legen Deinen Finger auf den Fingerabdrucksensors, um Deine Identität zu bestätigen. + Lege Deinen Finger auf den Fingerabdrucksensor, um Deine Identität zu bestätigen. Schutz der Einstellungen Schutz der App Bolus-Schutz @@ -14,7 +14,7 @@ Benutzerdefiniertes Passwort Kein Schutz Schutz - Das Master-Passwort ist nicht festgelegt!\n\nLege Dein Master-Passwort bitte in en Einstellungen fest (%1$s → %2$s) + Das Master-Passwort ist nicht festgelegt!\n\nLege Dein Master-Passwort bitte in den Einstellungen fest (%1$s → %2$s) Passwort festgelegt! Passwort nicht festgelegt Passwort nicht geändert diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index f496669e05..e084f0475b 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -185,7 +185,7 @@ Trotzdem importieren (GEFÄHRLICH!) Einstellungen wurden mit einer anderen Variante von AAPS erstellt (%1$s). Du nutzt: %2$s.\n\nEinige Einstellungen können fehlen oder ungültig sein - überprüfe und aktualisiere Deine Einstellungen nach dem Import . Einstellungen wurden auf einem anderen Gerät erstellt. Das ist OK, wenn Du von einem älteren/anderen Handy importierst. Stelle aber sicher, dass die importierten Einstellungen korrekt sind! - Du verwendest das veraltete Format einer alten AAPS-Version das nicht sicher ist! Verwende dieses nur als letzte Möglichkeit, wenn Du keinen Export im aktuellen JSON-Format hast. + Du verwendest das veraltete Format einer alten AAPS-Version, das nicht sicher ist! Verwende dieses nur als letzte Möglichkeit, wenn Du keinen Export im aktuellen JSON-Format hast. Die importierten Einstellungen sind bereits %1$s Tage alt! Hast Du aktuellere Einstellungen oder evtl. die falsche Datei gewählt? Denke daran, die Einstellungen regelmäßig zu exportieren. Ungültiges Datums-/Zeitformat! Einstellungen stammen aus einer Vorgängerversion (Nebenversion). Du kannst diese importieren, prüfe aber unbedingt nach dem Import, ob diese noch korrekt sind! @@ -251,7 +251,7 @@ Bolus gestoppt Bolus wird gestoppt Loop wurde deaktiviert. - Loop wurde aktiviert + Lopp wurde aktiviert. Loop ist deaktiviert. Loop ist aktiviert. %1$.2f limitiert auf %2$.2f @@ -266,15 +266,15 @@ Um das Loopen für %1$d Minuten zu pausieren, antworte mit dem Code %2$s. TBR mit %1$.2f IE/h für %2$d min wurde erfolgreich gestartet. Der erweiterte Bolus %1$.2f IE/h für %2$d Minuten wurde erfolgreich gestartet - %1$dg Kohlenhydrate erfolgreich erfasst + %1$dg Kohlenhydrate erfolgreich erfasst. Eingabe von %1$dg Kohlenhydraten ist fehlgeschlagen. - Die temporäre Basalrate wurde erfolgreich für %2$d Minuten auf %1$d%% gesetzt + Die temporäre Basalrate wurde erfolgreich für %2$d Minuten auf %1$d%% gesetzt. Das Starten der TBR ist fehlgeschlagen. - Die Abgabe des erweiterten Bolus ist fehlgeschlagen - Antworte mit dem Code %1$s, um die temporäre Basalrate zu beenden - Antworte mit dem Code %1$s, um den erweiterten Bolus zu beenden + Die Abgabe des erweiterten Bolus ist fehlgeschlagen. + Antworte mit dem Code %1$s, um die temporäre Basalrate zu beenden. + Antworte mit dem Code %1$s, um den erweiterten Bolus zu beenden. TBR abgebrochen - Die Abgabe des erweiterten Bolus wurde abgebrochen + Die Abgabe des erweiterten Bolus wurde abgebrochen. Das Abbrechen der TBR ist fehlgeschlagen. Der Abbruch des erweiterten Bolus ist fehlgeschlagen Unbekannter Befehl oder falsche Antwort @@ -326,7 +326,7 @@ Array mit %1$d Elementen.\nWert: Autosens-Daten Skript Debug - Nutze Autosense + Nutze Autosens Aktualisiere Einträge von Nightscout Lösche Behandlungen in der Zukunft Bald essen @@ -468,12 +468,8 @@ Profilwechsel durchführen Batteriealter Alarm-Optionen - Sehr hoch - Hoch - Niedrig - Sehr niedrig - Veraltete Daten - Stark veraltete Daten + Benachrichtigungen über NS-Alarme + Benachrichtigungen über NS-Ankündigungen Veraltete Daten seit [min] Stark veraltete Daten seit [min] Intervall für Autosens [h] @@ -832,9 +828,9 @@ Unerwartetes Verhalten. Minimaler Wert zur Anfrage einer Änderung [%] Open Loop schlägt neue Änderungen nur dann vor, wenn die Änderung größer als dieser Wert ist. Der Standard-Wert ist 20%. Geräte werden gesucht… - Pairing abgeschlossen + Kopplung abgeschlossen Stimmen die Codes auf diesem Gerät und auf deiner Pumpe überein? - Insight Pairing + Insight Kopplung Accu-Chek Insight %1$.2f U / %2$.2f U abgegeben %1$s: %2$s @@ -851,6 +847,10 @@ Unerwartetes Verhalten. Alarme protokollieren TBR-Emulation aktivieren Verzögerte Boli an Stelle von TBRs verwenden, um die Beschränkung auf 250%% zu umgehen + Vibrationen bei manueller Bolus-Abgabe deaktivieren + Für Boli und verlängerte Boli (nur mit Insight Firmware 3.x verfügbar) + Vibrationen bei automatischer Bolus-Abgabe deaktivieren + Für SMB und Temporäre Basalraten mit TBR Emulation (nur mit Insight Firmware 3.x verfügbar) Verbindungsabbau-Verzögerung [s] Seriennummer Release-Softwareversion @@ -862,8 +862,8 @@ Unerwartetes Verhalten. Bluetooth-Adresse System-ID-Appendix Herstellungsdatum - Pairing löschen - Pairinginformationen + Kopplung aufheben + Kopplungsinformation Pumpe starten Pumpe stoppen Betriebsmodus diff --git a/app/src/main/res/values-el-rGR/strings.xml b/app/src/main/res/values-el-rGR/strings.xml index b40f6e7b2e..f5184d6876 100644 --- a/app/src/main/res/values-el-rGR/strings.xml +++ b/app/src/main/res/values-el-rGR/strings.xml @@ -386,12 +386,6 @@ Χρόνος ζωής Ινσουλίνης Χρόνος ζωής μπαταρίας αντλίας Επιλογές συναγερμού - Επείγον υψηλό - Υψηλό - Χαμηλό - Επείγον χαμηλό - Παλιά δεδομένα - Επείγον παλιά δεδομένα Οριακή τιμή για παλιά δεδομένα [min] Επείγουσα οριακή τιμή για παλιά δεδομένα [min] Εσωτερικά διαστήματα για autosense [h] diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 2193c826d8..7afa8894ec 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -441,12 +441,6 @@ Cambio de perfil Edad batería bomba Opciones alarma - Urgente alto - Alto - Bajo - Urgente bajo - Datos anticuados - Datos antiguos urgentes Datos antiguos limite [min] Datos antiguos urgentes limite [min] Intervalo para autosens [h] diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index ce6f943445..74f3b85a88 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -469,12 +469,6 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Changer de profil Age batterie pompe Options d\'alarme - Haute urgent - Haute - Basse - Basse urgent - Données obsolètes - Urgent données obsolètes Seuil sans nouvelle donnée Glyc. [min] Seuil d\'urgence pour les données obsolètes [min] Plage pour Autosens [h] @@ -852,6 +846,10 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Enreg. alertes Activer l’émulation de DBT Utilisez des Bolus étendus au lieu de DBTs pour contourner la limite de 250%% + Désactiver les vibrations des bolus manuels + Concerne les bolus et bolus étendus (disponible uniquement pour les firmwares 3.x) + Désactiver les vibrations des bolus automatiques + Concerne les SMB et les basal temp avec émulation DBT (disponible uniquement pour les firmwares 3.x) Délai de déconnexion [s] Numéro de série Version du logiciel diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index d1ef20a32e..6204534b5b 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -468,12 +468,8 @@ Cambia profilo Età batteria micro Opzioni allarme - Molto alto - Alto - Basso - Molto basso - Dati non aggiornati - Dati non aggiornati da molto tempo + Crea notifiche da allarmi NS + Crea notifiche da avvisi NS Soglia dati non aggiornati [min] Soglia dati non aggiornati da molto tempo [min] Intervallo per autosens [h] @@ -851,6 +847,10 @@ Registra avvisi Abilita emulazione TBR Usa i bolli estesi invece dei TBR per aggirare il limite del 250%% + Erogazione bolo manuale: disabilita vibrazioni + Per bolo e bolo esteso (disponibile solo con firmware Insight 3.x) + Erogazione bolo automatica: disabilita vibrazioni + Per SMB e basale temporanea con emulazione TBR (disponibile solo con firmware Insight 3.x) Ritardo disconnessione [s] Numero seriale Versione Release software diff --git a/app/src/main/res/values-ko-rKR/strings.xml b/app/src/main/res/values-ko-rKR/strings.xml index 0c04ecd8ab..f89d6cb1ab 100644 --- a/app/src/main/res/values-ko-rKR/strings.xml +++ b/app/src/main/res/values-ko-rKR/strings.xml @@ -408,12 +408,6 @@ 프로파일 변경 실행 펌프배터리사용기간 알람 옵션 - 위험 고혈당 - 고혈당 - 저혈당 - 위험 저혈당 - 누락 데이터 - 위험 누락 데이터 누락 데이터 기준값 [min] 위험 누락 데이터 기준값 [min] autosens 시간 [h] diff --git a/app/src/main/res/values-lt-rLT/strings.xml b/app/src/main/res/values-lt-rLT/strings.xml index 6445d65195..2be090e0be 100644 --- a/app/src/main/res/values-lt-rLT/strings.xml +++ b/app/src/main/res/values-lt-rLT/strings.xml @@ -450,12 +450,6 @@ Profilio keitimas Baterija Aliarmų nustatymai - Kritiškai aukštas - Aukštas - Žemas - Kritiškai žemas - Seni duomenys - Kritiškai seni duomenys Seni duomenys, riba [min] Kritiškai seni duomenys, riba [min] Autosens intervalas [h] diff --git a/app/src/main/res/values-nl-rNL/strings.xml b/app/src/main/res/values-nl-rNL/strings.xml index 3c4f8dbd28..0ba8a69c9d 100644 --- a/app/src/main/res/values-nl-rNL/strings.xml +++ b/app/src/main/res/values-nl-rNL/strings.xml @@ -408,12 +408,6 @@ Profiel wissel uitvoeren Ouderdom batterij Alarm opties - Zeer hoog - Hoog - Laag - Zeer laag - Oude gegevens - Dringend oude gegevens vernieuwen Oude gegevens sinds [min] Alarm oude gegevens sinds [min] Interval voor autosens [uur] @@ -895,6 +889,7 @@ Herhaal tijd Elke Nooit + %1$dmin Voorwaarde: Actie: IOB [E]: diff --git a/app/src/main/res/values-pl-rPL/strings.xml b/app/src/main/res/values-pl-rPL/strings.xml index 14f82463e8..e9f466ba22 100644 --- a/app/src/main/res/values-pl-rPL/strings.xml +++ b/app/src/main/res/values-pl-rPL/strings.xml @@ -459,12 +459,6 @@ Zmień profil Czas baterii pompy Opcje alarmu - Uwaga wysoki - Wysoki - Niski - Uwaga niski - Nieaktualne dane - Uwaga, nieaktualne dane Próg nieaktualne dane [min] Próg uwaga nieaktualne dane [min] Przedział czasowy dla autosens [h] diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 59ef0d4a69..9dabcc46a9 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -171,8 +171,8 @@ Este valor é chamado max basal no contexto do OpenAPS Basal Máxima IOB que OpenAPS pode dar [U] Este valor é denominado Max IOB em contexto OpenAPS \nEste é o valor máximo de insulina em [U] que APS pode dar de uma vez. - Será perguntado pela password mestre, que será usada para encriptar preferências exportadas. - Será perguntado pela password mestre, que será necessária para desencriptar preferências importadas. + Será perguntado pela senha mestre, que será usada para encriptar preferências exportadas. + Será perguntado pela senha mestre, que será necessária para desencriptar preferências importadas. Exportação cancelada! Preferências NÃO foram exportadas! Importação cancelada! Preferências NÃO foram importadas! Seleccione o ficheiro para importação @@ -205,11 +205,11 @@ Ficheiro de configurações é seguro A usar um formato de configurações não seguro e não encriptado Erro de formato JSON, campo necessário ausente (formato, conteúdo, metadados ou segurança) - Erro ao desencriptar, a password inserida não pode desencriptar o ficheiro + Erro ao desencriptar, a senha inserida não pode desencriptar o ficheiro Ficheiro de verificação (hash) em falta, não é possível verificar a autenticidade de configurações! Ficheiro foi modificado após exportação! Erro Desencriptação, a análise de preferências falhou! - Erro de Desencriptação, a password é inválida ou configurações de arquivo foram modificadas! Pode acontecer que o ficheiro importado foi exportado com uma Password Mestre diferente. + Erro de Desencriptação, a senha é inválida ou configurações de arquivo foram modificadas! Pode acontecer que o ficheiro importado foi exportado com uma Senha Mestre diferente. Configuração de encriptação ausente, formato de configurações é inválido! Algoritmo de encriptação não suportado ou não especificado! exportado hoje @@ -226,7 +226,7 @@ Números de telefone permitidos +XXXXXXXXXX;+YYYYYYYYYY Para dar bolus %1$.2fU responder com código %2$s - Para dar bólus %1$.2fU responder com código %2$s + Para administrar bólus %1$.2fU responder com código %2$s Para definir o Alvo Tempo %1$s responda com o código %2$s Para cancelar Alvo Temp responda com o código %1$s Para desactivar o Serviço Remoto SMS de responda com o código %1$s.\n\nTenha em mente que será capaz de o reactivar directamente apenas a partir do telemóvel mestre do AAPS. @@ -239,7 +239,7 @@ Bolus %1$.2fU entregue com sucesso Vão ser administradas %1$.2fU Bólus %1$.2fU enviado com êxito - Bólus de refeição %1$.2fU entregue com sucesso + Bólus de refeição %1$.2fU administrado com sucesso Alvo %1$s para %2$d minutos Alvo %1$s para %2$d minutos definido com sucesso Alvo Temp cancelado com êxito @@ -468,12 +468,6 @@ Fazer Mudança De Perfil Idade bateria bomba Opções Alarme - Urgência hiperglicemia - Alta - Baixa - Urgência hipoglicemia - Dados Obsoletos - Dados obsoletos urgentes Tempo limite para dados obsoletos [min] Tempo limite para Urgência por dados obsoletos [min] Intervalo para autosens [h] @@ -1247,9 +1241,9 @@ a partir da app Autenticador para: %1$s Activar Autenticador - Autenticar comandos usando Uma-Password-Única que sejam geradas pelo Google Authenticator ou app 2FA similar. + Autenticar comandos usando Uma-Senha-Única que sejam geradas pelo Google Authenticator ou app 2FA similar. PIN adicional no token final - Dígitos adicionais que devem ser memorizados e colados no final de cada Uma-Password-Única que seja gerada + Dígitos adicionais que devem ser memorizados e colados no final de cada Uma-Senha-Única que seja gerada Configuração do Autenticador OTP para verificar: Repor Autenticadores @@ -1258,7 +1252,7 @@ Nova Chave do Autenticador foi gerada! Por favor, use o QRCode actualizado para os autenticadores. 1. Instalar Autenticador 2. Pesquise o código para configurar os códigos OTP do AndroidAPS - 3. Teste Uma-Password-Única + 3. Testar Uma-Senha-Única Repor Autenticadores Instalar uma app Autenticador que suporte Tokens RFC 6238 TOTP em cada telefone seguidor. Populares aplicativos gratuitos são:\n • Authy\n • o Google Authenticator\n • LastPass Autenticador\n • FreeOTP Autenticador NÃO PARTILHE este código online!\nUse-o apenas para a instalação da app Autenticador nos telefones seguidores. @@ -1269,9 +1263,9 @@ Desvio de inclinação Falha na autorização Insulina absoluta - Password Mestre é usada para encriptação da cópia de segurança e substituir segurança na aplicação. Lembre-se dela ou guarde-a em um lugar seguro. - As passwords não coincidem - Password Mestre actual + Senha Mestre é usada para encriptação da cópia de segurança e substituir segurança na aplicação. Lembre-se dela ou guarde-a em um lugar seguro. + As senhas não coincidem + Senha Mestre actual Luzes de Estado Copiar definições do NS Copiar definições do NS (se existir)? @@ -1280,11 +1274,13 @@ Tema gráfico + Integração de bomba para Omnipod, requer RileyLink (com pelo menos firmware 2.0) dispositivo. - Beep Bólus Activado - Beep Basal Activado - Beep SMB Activado - Beep DBT Activado + Sinal Bólus Activado + Sinal Basal Activado + Sinal SMB Activado + Sinal DBT Activado + Opções de Depuração do Pod habilitadas Detecção de DST/Fuso Horário Activado Gestão Pod @@ -1301,8 +1297,27 @@ Omnipod (433.91 MHz) + A operação não é possível.\n\nPrecisa configurar o Omnipod primeiro, antes de pode usar esta operação. + A operação não é possível.\n\n Precisa de esperar alguns minutos, até que AAPS tente definir o perfil para a primeira vez. + PodInitActionType Ilegal: %1$s Nenhum Pod Activo. A verificação do comando falhou. + Ocorreu um erro inesperado. Por favor reporte! (digite: %1$s). + Falha na comunicação: foram recebidos parâmetros de entrada inválidos. + Falha na comunicação: tempo limite. + Falha na comunicação: ocorreu um erro inesperado. Por favor, reporte! + Falha na comunicação: mensagem de falha de verificação de integridade. + Falha na comunicação: recebeu um pacote inválido do Pod. + Falha na comunicação: o Pod está em um estado errado. + Falha na comunicação: recebeu uma resposta inválida do Pod. + Falha na comunicação: recebeu uma mensagem com número de sequência inválido do Pod. + Falha na comunicação: recebeu uma mensagem com um endereço inválido do Pod. + Falha na comunicação: falha ao descodificar a mensagem do Pod. + Falha na comunicação: nonce resync falhou. + Falha na comunicação: nonce fora de sincronização. + Falha na comunicação: não há dados suficientes recebidos do Pod. + Uma falha de Pod (%1$03d %2$s) foi detectada. Por favor, desactive o Pod e inicie um novo. + Falha na comunicação: o Pod devolveu uma resposta de erro. Gestão Pod Iniciar Pod @@ -1326,19 +1341,29 @@ %1$.1f U %1$.1f U, HC=%2$.1f g Taxa: %1$.1f U, Duração: %2$d min + Se pressionar OK, o estado do Pod vai ser forçado a redefinir e você não será capaz de comunicar mais com o Pod. Faça isso somente se você não pode comunicar mais com o Pod. Se ainda pode comunicar com o Pod, por favor, use o Desactivar Pod opção. + Histórico do Pod não disponível no momento. Encher o Pod + \nPreencher o novo Pod com insulina suficiente para 3 dias.\n\nOuvir dois sinais sonoros a partir do Pod durante o processo de enchimento. Isso indica que a quantidade mínima de 85U foi inserida. Certifique-se de esvaziar completamente a seringa, mesmo depois de ouvir dois sinais sonoros.\n\nDepois de preencher o Pod, por favor, pressione Próximo.\n\nNota: não remova a tampa da agulha do Pod neste momento. A Purgar + A tentar emparelhar com o novo Pod e purgá-lo.\n\nQuando todos os itens forem verificados, pode pressionar Próximo.\n\nNota: por favor, mantenha o Pod muito perto do RileyLink neste momento. Anexar o Pod + \nPrepare o local de infusão. Remova a tampa da agulha do Pod e o adesivo e fixe o Pod no local de infusão.\n\nSe a canula sair, por favor, pressione Cancelar e descarte o seu Pod.\n\nPressione Próximo para inserir a canula e começar a administração da basal. A inserir canula + A tentar definir um plano da basal inicial e inserir canula.\n\nQuando todos os itens estiverem verificados, pode pressionar Próximo. Info Pod + \nO Pod está agora activo.\n\nO seu plano de basal foi programado e a canula foi inserida.\n\nPor favor, verifique se a canula foi inserida correctamente e substitua o seu Pod se você se sente que não. Desactivar Pod + \nPressione Próximo para desactivar o Pod.\n\nNota: Isto irá suspender toda a administração de insulina e desactivar o Pod. A Desactivar Pod + A desactivar o Pod.\n\nQuando todos os itens forem verificados, pode pressionar Próximo.\n\nNota: Se desactivar falhar continuamente, por favor, pressione Cancelar e use o Repor Pod opção para forçar a repor o estado do Pod. + Pod desactivado.\n\nPor favor, remova o Pod do seu corpo e descarte-o. Emparelhar Pod Purgar Pod Enchimento de Canula Definir Perfil Basal Cancelar Administração - Desacitvar Pod + Desactivar Pod Integração da Bomba para Omnipod Dash. @@ -1349,6 +1374,10 @@ Encerramento iminente Reservatório baixo Alerta desconhecido + Pode ter falhado ao definir perfil da basal. A administração pode estar suspensa! Por favor, actualize o estado do Pod. + Pode ter falhado ao definir basal temporária. Se houve uma basal temporária já em execução, pode ter sido cancelada! Por favor, actualize o estado do Pod. + Pode ter falhado ao definir a hora. A administração pode estar suspensa! Por favor, actualize o estado do Pod. + Não é possível verificar se o bólus foi bem-sucedido. Por favor, verifique se o Pod está administrar ou cancelar o bólus. Estatísticas RL Registo de Pulse diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index f496fef1ea..6d7acb563b 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -468,12 +468,6 @@ Fazer Mudança De Perfil Idade bateria bomba Opções Alarme - Urgência hiperglicemia - Alto - Baixo - Urgência hipoglicemia - Dados Obsoletos - Dados obsoletos urgentes Tempo limite para dados obsoletos [min] Tempo limite para Urgência por dados obsoletos [min] Intervalo para autosens [h] diff --git a/app/src/main/res/values-ro-rRO/strings.xml b/app/src/main/res/values-ro-rRO/strings.xml index bd7dedb65d..9a71eb6ffd 100644 --- a/app/src/main/res/values-ro-rRO/strings.xml +++ b/app/src/main/res/values-ro-rRO/strings.xml @@ -383,12 +383,6 @@ Vechime insulină Vechime baterie pompă Opțiuni alarmare - Hiper urgent - Hiper - Hipo - Hipo urgent - Date învechite - Date mult prea vechi Prag vechime date [min] Prag date mult prea vechi [min] Interval pentru autosens [o] diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index 85fd15c298..e25728c0ba 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -468,12 +468,6 @@ Переключить профиль Батарея помпы работает опции оповещения - Тревога выс - Высокий - Низкий - Тревога низкий - Устаревшие данные - Тревога! устаревшие данные Порог оповещения об устаревших данных [min] (мин) Порог тревоги об устаревших данных [min] (мин) Интервал для autosens [h] (ч) @@ -853,6 +847,10 @@ Context | Edit Context Журнал оповещений Включить эмуляцию TBR Использовать пролонгированные болюсы вместо временных базалов TBR чтобы обойти лимит в 250%% + Отключение вибраций при ручном болюсе + Для болюса и пролонгированного болюса (доступно только для Insight прошивки 3.х) + Отключение вибрации при ручном болюсе + Для микроболюсов SMB и временных базалов с эмуляцией TBR (доступно только для Insight с прошивкой версии 3.x) Задержка разъединения [s] Серийный номер Версия ПО diff --git a/app/src/main/res/values-sk-rSK/strings.xml b/app/src/main/res/values-sk-rSK/strings.xml index 4102738d1d..f696bd3f2c 100644 --- a/app/src/main/res/values-sk-rSK/strings.xml +++ b/app/src/main/res/values-sk-rSK/strings.xml @@ -468,12 +468,6 @@ Vykonajte zmenu profilu Vek batérie v pumpe Nastavenie alarmov - Veľmi vysoká - Vysoká - Nízka - Veľmi nízka - Zastaralé dáta - Veľmi zastaralé dáta Hraničná hodnota pre zastaralé dáta [min] Vysoká hraničná hodnota pre zastaralé dáta [min] Interval pre automatickú detekciu citlivosti [h] diff --git a/app/src/main/res/values-sv-rSE/strings.xml b/app/src/main/res/values-sv-rSE/strings.xml index 0f432004a8..f49188b9ff 100644 --- a/app/src/main/res/values-sv-rSE/strings.xml +++ b/app/src/main/res/values-sv-rSE/strings.xml @@ -469,12 +469,6 @@ Eversense-appen. Genomför profilbyte Pumpbatteri ålder Larminställningar - Akut hög - Hög - Låg - Akut låg - BG-data saknas - BG-data saknas (akut larm) Första varning efter [min] Akut varning efter [min] Intervall för autosens [tim] diff --git a/app/src/main/res/values-tr-rTR/strings.xml b/app/src/main/res/values-tr-rTR/strings.xml index 3b916dda38..738a52ea2e 100644 --- a/app/src/main/res/values-tr-rTR/strings.xml +++ b/app/src/main/res/values-tr-rTR/strings.xml @@ -355,12 +355,6 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d İnsülin yaşı Pompa pil yaşı Alarm türleri - Aşırı yüksek - Yüksek - Düşük - Çok düşük - Eski veriler - Acil durum verileri Eski veri eşiği [min] Acil durum verileri eşiği [min] Autosens [h] için aralık diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index b642819c55..295bc3b9f1 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -378,12 +378,6 @@ 胰岛素使用时间 泵电池使用时间 报警选项 - 紧急高 - - - 紧急低 - 陈旧数据 - 紧急陈旧数据 陈旧数据阈值 [min] 紧急陈旧数据阈值 [min] Autosens间隔的 [h] diff --git a/core/src/main/res/values-de-rDE/strings.xml b/core/src/main/res/values-de-rDE/strings.xml index dd1063e8c7..712b2c3534 100644 --- a/core/src/main/res/values-de-rDE/strings.xml +++ b/core/src/main/res/values-de-rDE/strings.xml @@ -124,25 +124,24 @@ %1$s: ∑: %2$.2f Bol: %3$.2f Bas: %4$.2f]]> - BZ Test + BZ-Test Ankündigung Notiz Frage Bewegung - Pumpenkatheter Wechsel + Pumpenkatheter-Wechsel CGM-Sensor gesetzt CGM-Sensor Start - Insulinreservoir Wechsel + Insulinreservoir-Wechsel Profilwechsel - Snack Bolus - Mahlzeiten Bolus - Korrektur Bolus - Combo Bolus - TBR Start + Snack-Bolus + Mahlzeiten-Bolus + Korrektur-Bolus + Combo-Bolus TBR Ende - Kohlenhydrat Korrektur + Kohlenhydrat-Korrektur OpenAPS offline - Pumpenbatterie Wechsel + Pumpenbatterie-Wechsel Temporäres Ziel Temporäres Ziel abbrechen Finger diff --git a/dana/src/main/res/values-cs-rCZ/strings.xml b/dana/src/main/res/values-cs-rCZ/strings.xml index 54cb889cc2..695e20aefe 100644 --- a/dana/src/main/res/values-cs-rCZ/strings.xml +++ b/dana/src/main/res/values-cs-rCZ/strings.xml @@ -29,6 +29,9 @@ Baterie v pumpě vybitá Okluze Prázdný zásobník + Zkontrolovat hřídel + Max. bazál + Max. denní Výstraha měření glykémie Zbývající inzulín Chybějící bolus diff --git a/dana/src/main/res/values-fr-rFR/strings.xml b/dana/src/main/res/values-fr-rFR/strings.xml index 7da5f10834..2c45d91871 100644 --- a/dana/src/main/res/values-fr-rFR/strings.xml +++ b/dana/src/main/res/values-fr-rFR/strings.xml @@ -29,6 +29,8 @@ Batterie Pompe Déchargée Occlusion Réservoir vide + Basal max + Quotidien max Alerte de mesure de glycémie Niveau d\'insuline restant Bolus manqués diff --git a/dana/src/main/res/values-it-rIT/strings.xml b/dana/src/main/res/values-it-rIT/strings.xml index 3ffadabd3b..11329423d5 100644 --- a/dana/src/main/res/values-it-rIT/strings.xml +++ b/dana/src/main/res/values-it-rIT/strings.xml @@ -29,6 +29,9 @@ Batteria del micro scarica Occlusione Serbatoio vuoto + Controlla asta meccanica (shaft) + Max basale + Max giornaliero Avviso misurazione glicemia Livello insulina rimanente Bolo perso diff --git a/dana/src/main/res/values-ru-rRU/strings.xml b/dana/src/main/res/values-ru-rRU/strings.xml index 964feb4428..b62cc03edd 100644 --- a/dana/src/main/res/values-ru-rRU/strings.xml +++ b/dana/src/main/res/values-ru-rRU/strings.xml @@ -29,6 +29,9 @@ батарея помпы разряжена закупорка Резервуар пуст + Проверьте шток помпы + Макс. шаг базала + Максимум в день Предупреждение при измерении уровня СК Уровень оставшегося инсулина Недоставленный болюс From 8a731a9187982dab3dd26fa5718e8b427f436af1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 24 May 2020 23:40:51 +0200 Subject: [PATCH 36/45] SMSCommunicator LOOP command auth --- .../smsCommunicator/SmsCommunicatorPlugin.kt | 45 ++++++++++++++----- app/src/main/res/values/strings.xml | 3 ++ .../SmsCommunicatorPluginTest.kt | 23 ++++++++-- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 7aa94f1dcc..1c8f44e0a8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -308,13 +308,20 @@ class SmsCommunicatorPlugin @Inject constructor( when (splitted[1].toUpperCase(Locale.getDefault())) { "DISABLE", "STOP" -> { if (loopPlugin.isEnabled(PluginType.LOOP)) { - loopPlugin.setPluginEnabled(PluginType.LOOP, false) - commandQueue.cancelTempBasal(true, object : Callback() { + val passCode = generatePasscode() + val reply = String.format(resourceHelper.gs(R.string.smscommunicator_loopdisablereplywithcode), passCode) + receivedSms.processed = true + messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - rxBus.send(EventRefreshOverview("SMS_LOOP_STOP")) - val replyText = resourceHelper.gs(R.string.smscommunicator_loophasbeendisabled) + " " + - resourceHelper.gs(if (result.success) R.string.smscommunicator_tempbasalcanceled else R.string.smscommunicator_tempbasalcancelfailed) - sendSMS(Sms(receivedSms.phoneNumber, replyText)) + loopPlugin.setPluginEnabled(PluginType.LOOP, false) + commandQueue.cancelTempBasal(true, object : Callback() { + override fun run() { + rxBus.send(EventRefreshOverview("SMS_LOOP_STOP")) + val replyText = resourceHelper.gs(R.string.smscommunicator_loophasbeendisabled) + " " + + resourceHelper.gs(if (result.success) R.string.smscommunicator_tempbasalcanceled else R.string.smscommunicator_tempbasalcancelfailed) + sendSMS(Sms(receivedSms.phoneNumber, replyText)) + } + }) } }) } else @@ -324,9 +331,16 @@ class SmsCommunicatorPlugin @Inject constructor( "ENABLE", "START" -> { if (!loopPlugin.isEnabled(PluginType.LOOP)) { - loopPlugin.setPluginEnabled(PluginType.LOOP, true) - sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled))) - rxBus.send(EventRefreshOverview("SMS_LOOP_START")) + val passCode = generatePasscode() + val reply = String.format(resourceHelper.gs(R.string.smscommunicator_loopenablereplywithcode), passCode) + receivedSms.processed = true + messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { + override fun run() { + loopPlugin.setPluginEnabled(PluginType.LOOP, true) + sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled))) + rxBus.send(EventRefreshOverview("SMS_LOOP_START")) + } + }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loopisenabled))) receivedSms.processed = true @@ -343,9 +357,16 @@ class SmsCommunicatorPlugin @Inject constructor( } "RESUME" -> { - rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME")) - loopPlugin.createOfflineEvent(0) - sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loopresumed))) + val passCode = generatePasscode() + val reply = String.format(resourceHelper.gs(R.string.smscommunicator_loopresumereplywithcode), passCode) + receivedSms.processed = true + messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { + override fun run() { + rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME")) + loopPlugin.createOfflineEvent(0) + sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loopresumed))) + } + }) } "SUSPEND" -> { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4908f7d04f..33cf3f2cc4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -308,6 +308,9 @@ To enter %1$dg at %2$s reply with code %3$s To start basal %1$d%% for %2$d min reply with code %3$s To suspend loop for %1$d minutes reply with code %2$s + To resume loop reply with code %1$s + To enable loop reply with code %1$s + To disable loop reply with code %1$s Temp basal %1$.2fU/h for %2$d min started successfully Extended bolus %1$.2fU for %2$d min started successfully Carbs %1$dg entered successfully diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index 1e4d27804d..7321131e30 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -223,6 +223,9 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { `when`(resourceHelper.gs(R.string.smscommunicator_mealbolusdelivered_tt)).thenReturn("Target %1\$s for %2\$d minutes") `when`(resourceHelper.gs(R.string.sms_actualbg)).thenReturn("BG:") `when`(resourceHelper.gs(R.string.sms_lastbg)).thenReturn("Last BG:") + `when`(resourceHelper.gs(R.string.smscommunicator_loopdisablereplywithcode)).thenReturn("To disable loop reply with code %1\$s") + `when`(resourceHelper.gs(R.string.smscommunicator_loopenablereplywithcode)).thenReturn("To enable loop reply with code %1\$s") + `when`(resourceHelper.gs(R.string.smscommunicator_loopresumereplywithcode)).thenReturn("To resume loop reply with code %1\$s") } @Test @@ -344,7 +347,11 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { smsCommunicatorPlugin.processSms(sms) Assert.assertFalse(sms.ignored) Assert.assertEquals("LOOP DISABLE", smsCommunicatorPlugin.messages[0].text) - Assert.assertEquals("Loop has been disabled Temp basal canceled", smsCommunicatorPlugin.messages[1].text) + Assert.assertTrue(smsCommunicatorPlugin.messages[1].text.contains("To disable loop reply with code ")) + var passCode: String = smsCommunicatorPlugin.messageToConfirm?.confirmCode!! + smsCommunicatorPlugin.processSms(Sms("1234", passCode)) + Assert.assertEquals(passCode, smsCommunicatorPlugin.messages[2].text) + Assert.assertEquals("Loop has been disabled Temp basal canceled", smsCommunicatorPlugin.messages[3].text) Assert.assertTrue(hasBeenRun) //LOOP ENABLE : already enabled @@ -368,7 +375,11 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { smsCommunicatorPlugin.processSms(sms) Assert.assertFalse(sms.ignored) Assert.assertEquals("LOOP ENABLE", smsCommunicatorPlugin.messages[0].text) - Assert.assertEquals("Loop has been enabled", smsCommunicatorPlugin.messages[1].text) + Assert.assertTrue(smsCommunicatorPlugin.messages[1].text.contains("To enable loop reply with code ")) + passCode = smsCommunicatorPlugin.messageToConfirm?.confirmCode!! + smsCommunicatorPlugin.processSms(Sms("1234", passCode)) + Assert.assertEquals(passCode, smsCommunicatorPlugin.messages[2].text) + Assert.assertEquals("Loop has been enabled", smsCommunicatorPlugin.messages[3].text) Assert.assertTrue(hasBeenRun) //LOOP RESUME : already enabled @@ -377,7 +388,11 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { smsCommunicatorPlugin.processSms(sms) Assert.assertFalse(sms.ignored) Assert.assertEquals("LOOP RESUME", smsCommunicatorPlugin.messages[0].text) - Assert.assertEquals("Loop resumed", smsCommunicatorPlugin.messages[1].text) + Assert.assertTrue(smsCommunicatorPlugin.messages[1].text.contains("To resume loop reply with code ")) + passCode = smsCommunicatorPlugin.messageToConfirm?.confirmCode!! + smsCommunicatorPlugin.processSms(Sms("1234", passCode)) + Assert.assertEquals(passCode, smsCommunicatorPlugin.messages[2].text) + Assert.assertEquals("Loop resumed", smsCommunicatorPlugin.messages[3].text) //LOOP SUSPEND 1 2: wrong format smsCommunicatorPlugin.messages = ArrayList() @@ -402,7 +417,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { Assert.assertFalse(sms.ignored) Assert.assertEquals("LOOP SUSPEND 100", smsCommunicatorPlugin.messages[0].text) Assert.assertTrue(smsCommunicatorPlugin.messages[1].text.contains("To suspend loop for 100 minutes reply with code ")) - var passCode: String = smsCommunicatorPlugin.messageToConfirm?.confirmCode!! + passCode = smsCommunicatorPlugin.messageToConfirm?.confirmCode!! smsCommunicatorPlugin.processSms(Sms("1234", passCode)) Assert.assertEquals(passCode, smsCommunicatorPlugin.messages[2].text) Assert.assertEquals("Loop suspended Temp basal canceled", smsCommunicatorPlugin.messages[3].text) From 7a086450b5c2cfda091a44dd9f3e482f814758cf Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 25 May 2020 08:59:56 +0200 Subject: [PATCH 37/45] typo --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 33cf3f2cc4..c3a821332c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1677,7 +1677,7 @@ Pump integration for Omnipod Dash. Finish pairing reminder Finish setup reminder - Pod wil expire soon + Pod will expire soon Pod will expire soon Shutdown is imminent Low reservoir From a4c5ecb9996d60f4e467917afd5f6934f4cfa766 Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Mon, 25 May 2020 22:04:53 +1200 Subject: [PATCH 38/45] Update message --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a2fd3d82be..c0b38da8cc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -738,7 +738,7 @@ enableSMB_with_high_temptarget set_neutral_temps Set neutral temp basals - If enabled, it sets basal to neutral before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. + If enabled, it will cancel a temporary basal before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. Enable SMB always Enable SMB always independently to boluses. Possible only with BG source with nice filtering of data like G5 Enable SMB after carbs From ec3ebd17dbdc17ba436e2dd7925e63224d933375 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 25 May 2020 13:53:59 +0200 Subject: [PATCH 39/45] History activity performance improvement --- .../historyBrowser/HistoryBrowseActivity.kt | 181 ++++++++++-------- .../iobCobCalculator/IobCobOref1Thread.java | 2 + .../iob/iobCobCalculator/IobCobThread.java | 2 + .../events/EventAutosensBgLoaded.kt | 6 + .../androidaps/utils/FabricPrivacy.kt | 1 + 5 files changed, 113 insertions(+), 79 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventAutosensBgLoaded.kt diff --git a/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt b/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt index 5d0df4dbf3..f484c086a3 100644 --- a/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt @@ -3,7 +3,6 @@ package info.nightscout.androidaps.historyBrowser import android.app.DatePickerDialog import android.graphics.Color import android.os.Bundle -import android.os.SystemClock import android.util.DisplayMetrics import android.view.ViewGroup import android.widget.LinearLayout @@ -15,12 +14,13 @@ import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.events.EventCustomCalculationFinished import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.overview.OverviewMenus import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensBgLoaded import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.utils.DateUtil @@ -33,6 +33,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable +import io.reactivex.schedulers.Schedulers import kotlinx.android.synthetic.main.activity_historybrowse.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -74,12 +75,10 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { historybrowse_left.setOnClickListener { start -= T.hours(rangeToDisplay.toLong()).msecs() - updateGUI("onClickLeft") runCalculation("onClickLeft") } historybrowse_right.setOnClickListener { start += T.hours(rangeToDisplay.toLong()).msecs() - updateGUI("onClickRight") runCalculation("onClickRight") } historybrowse_end.setOnClickListener { @@ -90,13 +89,12 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { calendar[Calendar.MINUTE] = 0 calendar[Calendar.HOUR_OF_DAY] = 0 start = calendar.timeInMillis - updateGUI("onClickEnd") runCalculation("onClickEnd") } historybrowse_zoom.setOnClickListener { rangeToDisplay += 6 rangeToDisplay = if (rangeToDisplay > 24) 6 else rangeToDisplay - updateGUI("rangeChange") + updateGUI("rangeChange", false) } historybrowse_zoom.setOnLongClickListener { val calendar = Calendar.getInstance() @@ -106,7 +104,6 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { calendar[Calendar.MINUTE] = 0 calendar[Calendar.HOUR_OF_DAY] = 0 start = calendar.timeInMillis - updateGUI("resetToMidnight") runCalculation("onLongClickZoom") true } @@ -120,7 +117,6 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { cal.set(Calendar.DAY_OF_MONTH, dayOfMonth) start = cal.timeInMillis historybrowse_date?.text = dateUtil.dateAndTimeString(start) - updateGUI("onClickDate") runCalculation("onClickDate") } @@ -144,6 +140,11 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { overviewMenus.setupChartMenu(overview_chartMenuButton) prepareGraphs() + savedInstanceState?.let { bundle -> + rangeToDisplay = bundle.getInt("rangeToDisplay", 0) + start = bundle.getLong("start", 0) + } + } public override fun onPause() { @@ -156,12 +157,21 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { super.onResume() disposable.add(rxBus .toObservable(EventAutosensCalculationFinished::class.java) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe({ event: EventAutosensCalculationFinished -> + .observeOn(Schedulers.io()) + .subscribe({ // catch only events from iobCobCalculatorPluginHistory - if (event.cause === eventCustomCalculationFinished) { - aapsLogger.debug(LTag.AUTOSENS, "EventAutosensCalculationFinished") - updateGUI("EventAutosensCalculationFinished") + if (it.cause is EventCustomCalculationFinished) { + updateGUI("EventAutosensCalculationFinished", bgOnly = false) + } + }) { fabricPrivacy::logException } + ) + disposable.add(rxBus + .toObservable(EventAutosensBgLoaded::class.java) + .observeOn(Schedulers.io()) + .subscribe({ + // catch only events from iobCobCalculatorPluginHistory + if (it.cause is EventCustomCalculationFinished) { + updateGUI("EventAutosensCalculationFinished", bgOnly = true) } }) { fabricPrivacy::logException } ) @@ -174,21 +184,32 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { .toObservable(EventRefreshOverview::class.java) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ - prepareGraphs() - updateGUI("EventRefreshOverview") + if (it.now) { + prepareGraphs() + updateGUI("EventRefreshOverview", bgOnly = false) + } }) { fabricPrivacy::logException } ) - // set start of current day - val calendar = Calendar.getInstance() - calendar.timeInMillis = System.currentTimeMillis() - calendar[Calendar.MILLISECOND] = 0 - calendar[Calendar.SECOND] = 0 - calendar[Calendar.MINUTE] = 0 - calendar[Calendar.HOUR_OF_DAY] = 0 - start = calendar.timeInMillis - runCalculation("onResume") - SystemClock.sleep(1000) - updateGUI("onResume") + if (start == 0L) { + // set start of current day + val calendar = Calendar.getInstance() + calendar.timeInMillis = System.currentTimeMillis() + calendar[Calendar.MILLISECOND] = 0 + calendar[Calendar.SECOND] = 0 + calendar[Calendar.MINUTE] = 0 + calendar[Calendar.HOUR_OF_DAY] = 0 + start = calendar.timeInMillis + runCalculation("onResume") + } else { + updateGUI("onResume", bgOnly = false) + } + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + outState.putInt("rangeToDisplay", rangeToDisplay) + outState.putLong("start", start) + } private fun prepareGraphs() { @@ -221,29 +242,30 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { } private fun runCalculation(from: String) { - treatmentsPluginHistory.initializeData(start - T.hours(8).msecs()) - val end = start + T.hours(rangeToDisplay.toLong()).msecs() - iobCobCalculatorPluginHistory.stopCalculation(from) - iobCobCalculatorPluginHistory.clearCache() - iobCobCalculatorPluginHistory.runCalculation(from, end, true, false, eventCustomCalculationFinished) + GlobalScope.launch(Dispatchers.Default) { + treatmentsPluginHistory.initializeData(start - T.hours(8).msecs()) + val end = start + T.hours(rangeToDisplay.toLong()).msecs() + iobCobCalculatorPluginHistory.stopCalculation(from) + iobCobCalculatorPluginHistory.clearCache() + iobCobCalculatorPluginHistory.runCalculation(from, end, true, false, eventCustomCalculationFinished) + } } - @Synchronized - fun updateGUI(from: String) { + fun updateGUI(from: String, bgOnly: Boolean) { aapsLogger.debug(LTag.UI, "updateGUI from: $from") val pump = activePlugin.activePump val profile = profileFunction.getProfile() - historybrowse_noprofile?.visibility = (profile == null).toVisibility() - profile ?: return - val lowLine = defaultValueHelper.determineLowLine() val highLine = defaultValueHelper.determineHighLine() - historybrowse_date?.text = dateUtil.dateAndTimeString(start) - historybrowse_zoom?.text = rangeToDisplay.toString() GlobalScope.launch(Dispatchers.Main) { + historybrowse_noprofile?.visibility = (profile == null).toVisibility() + profile ?: return@launch + historybrowse_bggraph ?: return@launch + historybrowse_date?.text = dateUtil.dateAndTimeString(start) + historybrowse_zoom?.text = rangeToDisplay.toString() val graphData = GraphData(injector, historybrowse_bggraph, iobCobCalculatorPluginHistory, treatmentsPluginHistory) val secondaryGraphsData: ArrayList = ArrayList() @@ -263,61 +285,62 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { // set manual x bounds to have nice steps graphData.formatAxis(fromTime, toTime) - // Treatments - graphData.addTreatments(fromTime, toTime) - if (overviewMenus.setting[0][OverviewMenus.CharType.ACT.ordinal]) - graphData.addActivity(fromTime, toTime, false, 0.8) - - // add basal data - if (pump.pumpDescription.isTempBasalCapable && overviewMenus.setting[0][OverviewMenus.CharType.BAS.ordinal]) { - graphData.addBasals(fromTime, toTime, lowLine / graphData.maxY / 1.2) - } - // add target line graphData.addTargetLine(fromTime, toTime, profile, null) // **** NOW line **** graphData.addNowLine(pointer) - // ------------------ 2nd graph - for (g in 0 until secondaryGraphs.size) { - val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobCalculatorPluginHistory, treatmentsPluginHistory) - var useIobForScale = false - var useCobForScale = false - var useDevForScale = false - var useRatioForScale = false - var useDSForScale = false - var useIAForScale = false - var useABSForScale = false - when { - overviewMenus.setting[g + 1][OverviewMenus.CharType.IOB.ordinal] -> useIobForScale = true - overviewMenus.setting[g + 1][OverviewMenus.CharType.COB.ordinal] -> useCobForScale = true - overviewMenus.setting[g + 1][OverviewMenus.CharType.DEV.ordinal] -> useDevForScale = true - overviewMenus.setting[g + 1][OverviewMenus.CharType.SEN.ordinal] -> useRatioForScale = true - overviewMenus.setting[g + 1][OverviewMenus.CharType.ACT.ordinal] -> useIAForScale = true - overviewMenus.setting[g + 1][OverviewMenus.CharType.ABS.ordinal] -> useABSForScale = true - overviewMenus.setting[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] -> useDSForScale = true + if (!bgOnly) { + // Treatments + graphData.addTreatments(fromTime, toTime) + if (overviewMenus.setting[0][OverviewMenus.CharType.ACT.ordinal]) + graphData.addActivity(fromTime, toTime, false, 0.8) + + // add basal data + if (pump.pumpDescription.isTempBasalCapable && overviewMenus.setting[0][OverviewMenus.CharType.BAS.ordinal]) { + graphData.addBasals(fromTime, toTime, lowLine / graphData.maxY / 1.2) } + // ------------------ 2nd graph + for (g in 0 until secondaryGraphs.size) { + val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobCalculatorPluginHistory, treatmentsPluginHistory) + var useIobForScale = false + var useCobForScale = false + var useDevForScale = false + var useRatioForScale = false + var useDSForScale = false + var useIAForScale = false + var useABSForScale = false + when { + overviewMenus.setting[g + 1][OverviewMenus.CharType.IOB.ordinal] -> useIobForScale = true + overviewMenus.setting[g + 1][OverviewMenus.CharType.COB.ordinal] -> useCobForScale = true + overviewMenus.setting[g + 1][OverviewMenus.CharType.DEV.ordinal] -> useDevForScale = true + overviewMenus.setting[g + 1][OverviewMenus.CharType.SEN.ordinal] -> useRatioForScale = true + overviewMenus.setting[g + 1][OverviewMenus.CharType.ACT.ordinal] -> useIAForScale = true + overviewMenus.setting[g + 1][OverviewMenus.CharType.ABS.ordinal] -> useABSForScale = true + overviewMenus.setting[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] -> useDSForScale = true + } - if (overviewMenus.setting[g + 1][OverviewMenus.CharType.IOB.ordinal]) secondGraphData.addIob(fromTime, toTime, useIobForScale, 1.0, overviewMenus.setting[g + 1][OverviewMenus.CharType.PRE.ordinal]) - if (overviewMenus.setting[g + 1][OverviewMenus.CharType.COB.ordinal]) secondGraphData.addCob(fromTime, toTime, useCobForScale, if (useCobForScale) 1.0 else 0.5) - if (overviewMenus.setting[g + 1][OverviewMenus.CharType.DEV.ordinal]) secondGraphData.addDeviations(fromTime, toTime, useDevForScale, 1.0) - if (overviewMenus.setting[g + 1][OverviewMenus.CharType.SEN.ordinal]) secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1.0) - if (overviewMenus.setting[g + 1][OverviewMenus.CharType.ACT.ordinal]) secondGraphData.addActivity(fromTime, toTime, useIAForScale, 0.8) - if (overviewMenus.setting[g + 1][OverviewMenus.CharType.ABS.ordinal]) secondGraphData.addAbsIob(fromTime, toTime, useABSForScale, 1.0) - if (overviewMenus.setting[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] && buildHelper.isDev()) secondGraphData.addDeviationSlope(fromTime, toTime, useDSForScale, 1.0) + if (overviewMenus.setting[g + 1][OverviewMenus.CharType.IOB.ordinal]) secondGraphData.addIob(fromTime, toTime, useIobForScale, 1.0, overviewMenus.setting[g + 1][OverviewMenus.CharType.PRE.ordinal]) + if (overviewMenus.setting[g + 1][OverviewMenus.CharType.COB.ordinal]) secondGraphData.addCob(fromTime, toTime, useCobForScale, if (useCobForScale) 1.0 else 0.5) + if (overviewMenus.setting[g + 1][OverviewMenus.CharType.DEV.ordinal]) secondGraphData.addDeviations(fromTime, toTime, useDevForScale, 1.0) + if (overviewMenus.setting[g + 1][OverviewMenus.CharType.SEN.ordinal]) secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1.0) + if (overviewMenus.setting[g + 1][OverviewMenus.CharType.ACT.ordinal]) secondGraphData.addActivity(fromTime, toTime, useIAForScale, 0.8) + if (overviewMenus.setting[g + 1][OverviewMenus.CharType.ABS.ordinal]) secondGraphData.addAbsIob(fromTime, toTime, useABSForScale, 1.0) + if (overviewMenus.setting[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] && buildHelper.isDev()) secondGraphData.addDeviationSlope(fromTime, toTime, useDSForScale, 1.0) - // set manual x bounds to have nice steps - secondGraphData.formatAxis(fromTime, toTime) - secondGraphData.addNowLine(pointer) - secondaryGraphsData.add(secondGraphData) + // set manual x bounds to have nice steps + secondGraphData.formatAxis(fromTime, toTime) + secondGraphData.addNowLine(pointer) + secondaryGraphsData.add(secondGraphData) + } } } // finally enforce drawing of graphs in UI thread graphData.performUpdate() for (g in 0 until secondaryGraphs.size) { secondaryGraphsLabel[g].text = overviewMenus.enabledTypes(g + 1) - secondaryGraphs[g].visibility = ( + secondaryGraphs[g].visibility = (!bgOnly && ( overviewMenus.setting[g + 1][OverviewMenus.CharType.IOB.ordinal] || overviewMenus.setting[g + 1][OverviewMenus.CharType.COB.ordinal] || overviewMenus.setting[g + 1][OverviewMenus.CharType.DEV.ordinal] || @@ -325,7 +348,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { overviewMenus.setting[g + 1][OverviewMenus.CharType.ACT.ordinal] || overviewMenus.setting[g + 1][OverviewMenus.CharType.ABS.ordinal] || overviewMenus.setting[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] - ).toVisibility() + )).toVisibility() secondaryGraphsData[g].performUpdate() } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java index ef891ff62c..eb2e4841bc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java @@ -30,6 +30,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensBgLoaded; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress; import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin; @@ -114,6 +115,7 @@ public class IobCobOref1Thread extends Thread { if (bgDataReload) { iobCobCalculatorPlugin.loadBgData(end); iobCobCalculatorPlugin.createBucketedData(); + rxBus.send(new EventAutosensBgLoaded(cause)); } List bucketed_data = iobCobCalculatorPlugin.getBucketedData(); LongSparseArray autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java index d5af67e3b8..6ea2b7f8b3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java @@ -28,6 +28,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensBgLoaded; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress; import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin; @@ -111,6 +112,7 @@ public class IobCobThread extends Thread { if (bgDataReload) { iobCobCalculatorPlugin.loadBgData(end); iobCobCalculatorPlugin.createBucketedData(); + rxBus.send(new EventAutosensBgLoaded(cause)); } List bucketed_data = iobCobCalculatorPlugin.getBucketedData(); LongSparseArray autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventAutosensBgLoaded.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventAutosensBgLoaded.kt new file mode 100644 index 0000000000..b02e96b67f --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventAutosensBgLoaded.kt @@ -0,0 +1,6 @@ +package info.nightscout.androidaps.plugins.iob.iobCobCalculator.events + +import info.nightscout.androidaps.events.Event +import info.nightscout.androidaps.events.EventLoop + +class EventAutosensBgLoaded(var cause: Event) : EventLoop() diff --git a/core/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.kt b/core/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.kt index 9468f21bd4..c5e16878f5 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.kt @@ -79,6 +79,7 @@ class FabricPrivacy @Inject constructor( try { val crashlytics = Crashlytics.getInstance() crashlytics.core.logException(throwable) + aapsLogger.debug(LTag.CORE, "Exception: ", throwable) } catch (e: NullPointerException) { aapsLogger.debug(LTag.CORE, "Ignoring opted out non-initialized log: $throwable") } catch (e: IllegalStateException) { From b9806d0ea900e449ee146e63f2c01b9f90e71f4e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 25 May 2020 17:43:34 +0200 Subject: [PATCH 40/45] RS user options fix --- .../androidaps/dana/activities/DanaUserOptionsActivity.kt | 2 +- .../info/nightscout/androidaps/danars/services/DanaRSService.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt index fd9c50fb48..fafebe603d 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt @@ -82,7 +82,7 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() { danar_screentimeout.setParams(danaPump.lcdOnTimeSec.toDouble(), 5.0, 240.0, 5.0, DecimalFormat("1"), false, save_user_options) danar_backlight.setParams(danaPump.backlightOnTimeSec.toDouble(), minBacklight.toDouble(), 60.0, 1.0, DecimalFormat("1"), false, save_user_options) danar_shutdown.setParams(danaPump.shutdownHour.toDouble(), 0.0, 24.0, 1.0, DecimalFormat("1"), true, save_user_options) - danar_lowreservoir.setParams(danaPump.lowReservoirRate.toDouble(), 10.0, 60.0, 10.0, DecimalFormat("10"), false, save_user_options) + danar_lowreservoir.setParams(danaPump.lowReservoirRate.toDouble(), 10.0, 50.0, 10.0, DecimalFormat("10"), false, save_user_options) when (danaPump.beepAndAlarm) { 0x01 -> danar_pumpalarm_sound.isChecked = true 0x02 -> danar_pumpalarm_vibrate.isChecked = true diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt b/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt index b1f472decf..469eb2188d 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt @@ -239,7 +239,7 @@ class DanaRSService : DaggerService() { } fun setUserSettings(): PumpEnactResult { - sendMessage(DanaRS_Packet_Option_Get_User_Option(injector)) + sendMessage(DanaRS_Packet_Option_Set_User_Option(injector)) return PumpEnactResult(injector).success(true) } From f7793a77f9359b653a36c91d9c131c8dd2e6e17f Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Mon, 25 May 2020 22:32:00 +0100 Subject: [PATCH 41/45] - there are some fields hidden between implementatuon of MedtronicCommunicationManager and RileyLinkCommunicationManager (it becomes visible only if there is error in packets, which at the moment only happens with MySentry packets, which we don;t support. --- .../pump/medtronic/comm/MedtronicCommunicationManager.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java index a8405ea00d..3737dd0226 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java @@ -61,14 +61,11 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; */ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager { - @Inject AAPSLogger aapsLogger; @Inject MedtronicPumpStatus medtronicPumpStatus; @Inject MedtronicPumpPlugin medtronicPumpPlugin; @Inject MedtronicConverter medtronicConverter; @Inject MedtronicUtil medtronicUtil; @Inject MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder; - @Inject RileyLinkServiceData rileyLinkServiceData; - @Inject ServiceTaskExecutor serviceTaskExecutor; private final int MAX_COMMAND_TRIES = 3; private final int DEFAULT_TIMEOUT = 2000; From 3bbbeed07d05a4b57eb4cfb588499d2238e626de Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Mon, 25 May 2020 22:40:55 +0100 Subject: [PATCH 42/45] - There are few fields hidden between implementations MedtronicCommunicationManager and RileyLinkCommunicationManager. If there is error in packet (if MySentry is configugured on Pump), there is NPE when trying to write to log. --- .../pump/medtronic/comm/MedtronicCommunicationManager.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java index a8405ea00d..3737dd0226 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java @@ -61,14 +61,11 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; */ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager { - @Inject AAPSLogger aapsLogger; @Inject MedtronicPumpStatus medtronicPumpStatus; @Inject MedtronicPumpPlugin medtronicPumpPlugin; @Inject MedtronicConverter medtronicConverter; @Inject MedtronicUtil medtronicUtil; @Inject MedtronicPumpHistoryDecoder medtronicPumpHistoryDecoder; - @Inject RileyLinkServiceData rileyLinkServiceData; - @Inject ServiceTaskExecutor serviceTaskExecutor; private final int MAX_COMMAND_TRIES = 3; private final int DEFAULT_TIMEOUT = 2000; From c5aa12c5badb36d809e0e0c8c73228b49c7f65d2 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 26 May 2020 19:58:50 +0200 Subject: [PATCH 43/45] double SMB fix --- .../automation/triggers/TriggerBolusAgo.kt | 2 +- .../plugins/treatments/TreatmentService.java | 25 ++++++++++++ .../plugins/treatments/TreatmentsPlugin.java | 40 ++++++++----------- .../triggers/TriggerBolusAgoTest.kt | 4 +- ...Packet_Bolus_Get_Step_Bolus_Information.kt | 6 ++- ...aRS_Packet_General_Get_More_Information.kt | 4 +- 6 files changed, 52 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt index db57bb159a..4b7a56771a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt @@ -35,7 +35,7 @@ class TriggerBolusAgo(injector: HasAndroidInjector) : Trigger(injector) { } override fun shouldRun(): Boolean { - val lastBolusTime = treatmentsPlugin.getLastBolusTime(false) + val lastBolusTime = treatmentsPlugin.getLastBolusTime(true) if (lastBolusTime == 0L) return if (comparator.value == Comparator.Compare.IS_NOT_AVAILABLE) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java index 60bd9b9b8c..18d997178e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java @@ -45,6 +45,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin; import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData; +import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.JsonHelper; import io.reactivex.disposables.CompositeDisposable; @@ -588,6 +589,30 @@ public class TreatmentService extends OrmLiteBaseService { } } + /** + * Returns the newest record with insulin > 0 + */ + @Nullable + public Treatment getLastBolus(boolean excludeSMB) { + try { + QueryBuilder queryBuilder = getDao().queryBuilder(); + Where where = queryBuilder.where(); + where.gt("insulin", 0); + where.and().le("date", DateUtil.now()); + where.and().eq("isValid", true); + if (excludeSMB) where.and().eq("isSMB", false); + queryBuilder.orderBy("date", false); + queryBuilder.limit(1L); + + List result = getDao().query(queryBuilder.prepare()); + if (result.isEmpty()) + return null; + return result.get(0); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + public void deleteNS(JSONObject json) { String _id = JsonHelper.safeGetString(json, "_id"); if (_id != null && !_id.isEmpty()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java index 0af7ac8d33..8d723cea71 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java @@ -335,33 +335,27 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface @Override public long getLastBolusTime() { - long now = System.currentTimeMillis(); - long last = 0; - synchronized (treatments) { - for (Treatment t : treatments) { - if (!t.isValid) - continue; - if (t.date > last && t.insulin > 0 && t.date <= now) - last = t.date; - } + Treatment last = getService().getLastBolus(false); + if (last == null) { + getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: NOTHING FOUND"); + return 0; + } + else { + getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: " + dateUtil.dateAndTimeString(last.date)); + return last.date; } - getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: " + dateUtil.dateAndTimeString(last)); - return last; } - public long getLastBolusTime(boolean isSMB) { - long now = System.currentTimeMillis(); - long last = 0; - synchronized (treatments) { - for (Treatment t : treatments) { - if (!t.isValid) - continue; - if (t.date > last && t.insulin > 0 && t.date <= now && isSMB == t.isSMB) - last = t.date; - } + public long getLastBolusTime(boolean excludeSMB) { + Treatment last = getService().getLastBolus(excludeSMB); + if (last == null) { + getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: NOTHING FOUND"); + return 0; + } + else { + getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: " + dateUtil.dateAndTimeString(last.date)); + return last.date; } - getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: " + dateUtil.dateAndTimeString(last)); - return last; } @Override diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt index fbc4cd8a8b..a1400ae55f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt @@ -30,7 +30,7 @@ class TriggerBolusAgoTest : TriggerTestBase() { @Test fun shouldRunTest() { - `when`(treatmentsPlugin.getLastBolusTime(false)).thenReturn(now) // Set last bolus time to now + `when`(treatmentsPlugin.getLastBolusTime(true)).thenReturn(now) // Set last bolus time to now `when`(DateUtil.now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min var t = TriggerBolusAgo(injector).setValue(110).comparator(Comparator.Compare.IS_EQUAL) Assert.assertEquals(110, t.minutesAgo.value) @@ -53,7 +53,7 @@ class TriggerBolusAgoTest : TriggerTestBase() { Assert.assertTrue(t.shouldRun()) t = TriggerBolusAgo(injector).setValue(390).comparator(Comparator.Compare.IS_EQUAL_OR_LESSER) Assert.assertTrue(t.shouldRun()) - PowerMockito.`when`(treatmentsPlugin.getLastBolusTime(false)).thenReturn(0L) // Set last bolus time to 0 + PowerMockito.`when`(treatmentsPlugin.getLastBolusTime(true)).thenReturn(0L) // Set last bolus time to 0 t = TriggerBolusAgo(injector).comparator(Comparator.Compare.IS_NOT_AVAILABLE) Assert.assertTrue(t.shouldRun()) } diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt index d6d7801acc..7cc2d3aa65 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.kt @@ -1,10 +1,11 @@ package info.nightscout.androidaps.danars.comm import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption +import info.nightscout.androidaps.logging.LTag import org.joda.time.DateTime +import org.joda.time.DateTimeZone import javax.inject.Inject class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( @@ -24,7 +25,8 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( danaPump.initialBolusAmount = intFromBuff(data, 2, 2) / 100.0 val hours = intFromBuff(data, 4, 1) val minutes = intFromBuff(data, 5, 1) - danaPump.lastBolusTime = DateTime.now().withHourOfDay(hours).withMinuteOfHour(minutes).millis + if (danaPump.usingUTC) danaPump.lastBolusTime = DateTime.now().withZone(DateTimeZone.UTC).withHourOfDay(hours).withMinuteOfHour(minutes).millis + else danaPump.lastBolusTime = DateTime.now().withHourOfDay(hours).withMinuteOfHour(minutes).millis danaPump.lastBolusAmount = intFromBuff(data, 6, 2) / 100.0 danaPump.maxBolus = intFromBuff(data, 8, 2) / 100.0 danaPump.bolusStep = intFromBuff(data, 10, 1) / 100.0 diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_More_Information.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_More_Information.kt index 4f9d15410e..0d110deb71 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_More_Information.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_General_Get_More_Information.kt @@ -5,6 +5,7 @@ import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.danars.encryption.BleEncryption import org.joda.time.DateTime +import org.joda.time.DateTimeZone import javax.inject.Inject class DanaRS_Packet_General_Get_More_Information( @@ -30,7 +31,8 @@ class DanaRS_Packet_General_Get_More_Information( // val remainRate = intFromBuff(data, 7, 2) / 100.0 val hours = intFromBuff(data, 9, 1) val minutes = intFromBuff(data, 10, 1) - danaPump.lastBolusTime = DateTime.now().withHourOfDay(hours).withMinuteOfHour(minutes).millis + if (danaPump.usingUTC) danaPump.lastBolusTime = DateTime.now().withZone(DateTimeZone.UTC).withHourOfDay(hours).withMinuteOfHour(minutes).millis + else danaPump.lastBolusTime = DateTime.now().withHourOfDay(hours).withMinuteOfHour(minutes).millis danaPump.lastBolusAmount = intFromBuff(data, 11, 2) / 100.0 // On DanaRS DailyUnits can't be more than 160 if (danaPump.dailyTotalUnits > 160) failed = true From 6f7932f1c7b9d8e26857bb48aa75a9d92e7f37b2 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 26 May 2020 20:29:59 +0200 Subject: [PATCH 44/45] New Crowdin translations (#2671) * New translations strings.xml (German) * New translations strings.xml (German) * New translations strings.xml (German) * New translations strings.xml (German) * New translations strings.xml (Portuguese, Brazilian) * New translations strings.xml (Swedish) * New translations strings.xml (Slovak) * New translations strings.xml (Russian) * New translations strings.xml (Portuguese) * New translations strings.xml (French) * New translations strings.xml (Italian) * New translations strings.xml (German) * New translations strings.xml (Russian) * New translations strings.xml (Czech) * New translations strings.xml (Czech) * New translations strings.xml (German) * New translations strings.xml (German) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Czech) --- app/src/main/res/values-cs-rCZ/strings.xml | 43 ++++++++++++++ app/src/main/res/values-de-rDE/strings.xml | 69 +++++++++++----------- app/src/main/res/values-fr-rFR/strings.xml | 1 - app/src/main/res/values-it-rIT/strings.xml | 3 + app/src/main/res/values-pt-rBR/strings.xml | 1 - app/src/main/res/values-pt-rPT/strings.xml | 1 - app/src/main/res/values-ru-rRU/strings.xml | 7 ++- app/src/main/res/values-sk-rSK/strings.xml | 1 - app/src/main/res/values-sv-rSE/strings.xml | 1 - 9 files changed, 88 insertions(+), 39 deletions(-) diff --git a/app/src/main/res/values-cs-rCZ/strings.xml b/app/src/main/res/values-cs-rCZ/strings.xml index 691837ca7e..aa081ca187 100644 --- a/app/src/main/res/values-cs-rCZ/strings.xml +++ b/app/src/main/res/values-cs-rCZ/strings.xml @@ -264,6 +264,9 @@ Pro zadání %1$dg na %2$s odpovězte pomocí SMS s kódem %3$s Pro spuštění bazálu %1$d%% na %2$d min odpovězte SMS s kódem %3$s K pozastavení smyčky na %1$d minut odpověz SMS s kódem %2$s + Chcete-li obnovit smyčku, odpovězte SMS s kódem %1$s + Chcete-li povolit smyčku, odpovězte SMS s kódem %1$s + Chcete-li zakázat smyčku, odpovězte SMS s kódem %1$s Dočasný bazál %1$.2fU/h na %2$d minut spuštěn Prodloužený bolus %1$.2fU na %2$d min úspěšně spuštěn Sacharidy %1$dg byly úspěšně zadány @@ -468,6 +471,8 @@ Proveďte přepnutí profilu Stáří baterie v pumpě Nastavení alarmů + Vytvořit oznámení z alarmů NS + Vytvořit oznámení z NS upozornění Mezní hodnota pro zastaralá data [min] Urgentní mezní hodnota pro zastaralá data [min] Interval pro detekci senzitivity [h] @@ -845,6 +850,10 @@ Zaznamenat výstrahy Povolit emulaci dočasných bazálů Používat prodloužené bolusy na obejití limitu dočasných bazálů 250%% + Zakázat vibrace při ručním podání bolusu + Pro bolus a prodloužený bolus (dostupné pouze s Insight firmware 3.x) + Zakázat vibrace při automatickém podání bolusu + Pro SMB a Dočasný bazál s emulací TBR (k dispozici pouze s Insight firmware 3.x) Limit pro odpojení [s] Sériové číslo Verze softwaru @@ -1341,9 +1350,43 @@ %1$.1f U %1$.1f U, Sach=%2$.1f g Rychlost: %1$.1f U, doba trvání: %2$d min + Pokud stisknete OK, stav Podu bude vynuceně resetován a již nebudete moci komunikovat s Podem. Udělejte to pouze v případě, že s Podem již nelze komunikovat. Pokud stále můžete komunikovat s Podem, použijte volbu Deaktivovat Pod. + Historie Podu není v daném okamžiku k dispozici. + Naplňte Pod + \nNaplňte nový Pod dostatkem inzulínu na 3 dny.\n\nSledujte dvě pípnutí z Podu během procesu plnění. Tyto ukazují, že minimální množství 85U bylo naplněno. Ujistěte se, že stříkačka je zcela vyprázdněná a to i po vyslechnutí dvou pípnutí.\n\nPo naplnění Podu, prosím, stiskněte Další.\n\nPoznámka: prozatím nesundavejte kryt jehly. + Plnění + Snažím se spárovat s novým Podem a naplnit ho.\n\nJakmile budou zaškrtnuty všechny položky, můžete stisknout Další.\n\nPoznámka: ponechte prosím Pod velmi blízko RileyLinku. + Nasaďte Pod + \nPřipravte infuzní místo. Odstraňte krytku jehly a náplasti a nalepte Pod.\n\nPokud se kanyla odlepí, stiskněte Zrušit a zahoďte Pod.\n\nStiskněte Další pro vložení kanyly a spuštění bazálů. + Vkládání kanyly + Snažím se nastavit počáteční základní bazální plán a vložit kanylu.\n\nPři zaškrtnutí všech položek můžete stisknout tlačítko Další. + Pod Info + \nPod je nyní aktivní.\n\nVáš bazál byl naprogramován a kanyla byla vložena.\n\nOvěřte, prosím, že kanyla byla vložena správně a případně vyměňte Pod. Deaktivovat Pod + \nStiskněte Další pro deaktivaci Podu.\n\nPoznámka: Zastavíte veškerý výdej inzulínu a deaktivujete Pod. + Deaktivace Podu + Deaktivace Podu.\n\nKdyž jsou zaškrtnuty všechny položky, můžete stisknout Další.\n\nPoznámka: Pokud deaktivace nepřetržitě selhává, prosím stiskněte Zrušit a použijte možnost Resetovat Pod pro resetování stavu Podu. + Pod deaktivován.\n\nOdstraňte Pod z těla a znehodnoťte jej. + Párování Podu + Plnění Podu + Plnění kanyly Nastavit bazální profil + Zrušit podávání Deaktivovat Pod + Integrace pumpy pro Omnipod Dash. + Upomínka dokončení párování + Upomínka dokončení nastavení + Životnost Podu brzy skončí + Pod brzy vyprší + Blíží se vypnutí + Nízký stav zásobníku + Neznámá výstraha + Nastavení bazálního profilu se možná nezdařilo. Výdej může být pozastaven! Obnovte prosím stav Podu. + Nastavení dočasného bazálu mohlo být neúspěšné. Pokud je dočasný bazál již spuštěn, mohl by být zrušen! Aktualizujte prosím stav Podu. + Nastavení času se možná nezdařilo. Výdej může být pozastaven! Obnovte prosím stav Podu. + Nelze ověřit, zda byl bolus úspěšný. Ověřte prosím, zda Váš Pod dodává bolus nebo ho zrušte. + Statistika RL + Pulse Log diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index e084f0475b..380b19dc9e 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -18,7 +18,7 @@ Einige Schaltflächen, um auf häufig verwendete Funktionen zugreifen zu können. Dient zum Konfigurieren der aktiven Plugins Das Programm kennenlernen - Zeigt die Essens-Vorlagen aus Nightscout an + Zeigt die Essensvorlagen aus Nightscout an Insulinprofil für Humalog und NovoRapid / NovoLog Insulinprofil für Fiasp Erlaubt dir, das Wirkmaximum der Insulinaktivität zu definieren, und sollte nur von erfahrenen Anwendern genutzt werden @@ -27,26 +27,26 @@ Stand des Algorithmus in 2016 Stand des Algorithmus in 2017 Der aktuellste Algorithmus für erfahrene Nutzer - Zeigt den aktuellen Status deines Loops und Knöpfe für die geläufigsten Aktionen an + Zeigt den aktuellen Status deines Loops und Schaltflächen für die geläufigsten Aktionen an Zeigt eine fortlaufende Benachrichtigung mit einer kurzen Übersicht darüber, was dein Loop derzeit tut Definiere ein Profil, was auch offline verfügbar ist. Stellt das Profil zur Verfügung, das in Nightscout definiert ist Definiere ein Profil mit nur einem Zeitblock. Pumpen-Integration für Accu-Chek Combo Pumpen; erfordert, dass ruffy installiert ist - Pumpen-Integration für Personen, die täglich mehrere Injektionen für ihre Diabetestherapie vornehmen - Pumpen-Integration für Pumpen, die noch nicht über einen Treiber verfügen (Open Loop) + Pumpenintegration für Personen, die täglich mehrere Injektionen für ihre Diabetestherapie vornehmen + Pumpenintegration für Pumpen, die noch nicht über einen Treiber verfügen (Open Loop) Die Sensitivität wird genauso wie bei Oref0 berechnet, aber Du kannst dafür ein Zeitfenster bestimmen. Die minimale Kohlenhydrat-Absorptionsrate wird aus der maximalen Absorptionsdauer aus den Einstellungen abgeleitet. Die Sensitivität wird aus den Daten der letzten 8 Stunden berechnet und Kohlenhydrate (falls nicht bereits absorbiert) werden nach der in den Einstellungen angegebenen Zeit als absorbiert betrachtet. Das Plugin bezieht Zeiträume, in denen UAM annimmt, dass Kohlenhydrate aktiv waren, nicht mit in die Berechnung ein. Die Sensitivität wird aus den Abweichungen errechnet. Dabei werden neuere Abweichungen stärker gewichtet als ältere. Die minimale Kohlenhydrat-Aufnahme wird aus der in den Präferenzen angegebenen maximalen Kohlenhydrat-Resorptionszeit abgeleitet. Dieser Algorithmus reagiert am schnellsten auf Änderungen der Empfindlichkeit. - Empfange BZ-Werte von der gepatchten Eversense App. - Empfange Blutzucker-Werte von Glimp. - Empfange Blutzucker-Werte vom 600SeriesAndroidUploader. - Lade Blutzucker-Daten von Nightscout - Empfange Blutzucker-Werte von xDrip. + Empfange BZ-Werte von der gepatchten Eversense-App. + Empfange Blutzuckerwerte von Glimp. + Empfange Blutzuckerwerte vom 600SeriesAndroidUploader. + Lade Blutzuckerdaten von Nightscout + Empfange Blutzuckerwerte von xDrip. Speichert alle eingegebenen Behandlungen Überwache und steuere AndroidAPS mit Deiner WearOS-Smartwatch. Zeige Loop-Informationen auf Deinem xDrip+-Watchface. - Steuere AndroiAPS fern mittels SMS-Anweisungen. + AndroidAPS mit SMS-Befehlen fernsteuern. Insulin: Kohlenhydrate: IOB: @@ -72,7 +72,7 @@ Aktuelle TBR IOB-Daten Profil - Mahlzeiten-Daten + Mahlzeitendaten Ergebnis Ergebnis: %1$s %2$s Keine BZ-Werte verfügbar @@ -94,7 +94,7 @@ Profil Welches Profil soll AndroidAPS nutzen? APS - Welcher APS-Algorithmus soll Therapie-Anpassungen vornehmen? + Welcher APS-Algorithmus soll Therapieanpassungen vornehmen? Allgemein Dies sind einige generelle Plugins, die Du vielleicht hilfreich findest. Welche Beschränkungen werden angewendet? @@ -117,7 +117,7 @@ Akzeptiere neue TBR: Bolus Rechner - Beschränkungen angewendet! + Beschränkung angewendet! Bestätigung Bolus Bolus: @@ -135,7 +135,7 @@ Deaktiviere Loop Aktiviere Loop Neue Empfehlung verfügbar - Nicht unterstütze Nightscout-Version + Nicht unterstützte Nightscout-Version LOOP DEAKTIVIERT DURCH BESCHRÄNKUNGEN Basal-IOB Bolus-Beschränkung angewendet @@ -151,10 +151,10 @@ Prozent Absolut Notiz - Ereignis-Zeit + Ereigniszeit Profil Eingegeben durch - Glukose-Art + Glukoseart Bisher noch kein Profil von Nightscout geladen TBR Verzögerter Bolus @@ -167,10 +167,10 @@ Datei nicht gefunden Einstellungen exportieren Einstellungen importieren - Max IE/h, die als TBR gesetzt werden können + Max. IE/h, die als TBR gesetzt werden können Dieser Wert wird \"max basal\" in OpenAPS genannt. Maximales Basal-IOB, das OpenAPS abgeben darf [IE] - Maximale Menge von nicht Bolus-IOB, die OpenAPs abgeben kann. + Maximale Menge von Nicht-Bolus-IOB, die OpenAPS abgeben kann. Du wirst nach dem Master-Passwort gefragt. Mit diesem werden die exportierten Einstellungen verschlüsselt. Du wirst nach dem Master-Passwort gefragt. Mit diesem werden die importierten Einstellungen entschlüsselt. Export abgebrochen! Einstellungen wurden NICHT exportiert! @@ -201,7 +201,7 @@ Neues verschlüsseltes Format Neues Debugformat (unverschlüsselt) Unbekanntes Export-Format - Einstellungen-Datei wurde manipuliert. + Konfigurationsdatei wurde manipuliert. Einstellungsdatei ist sicher. Nicht sicheres, unverschlüsseltes Einstellungsformat verwenden Fehler im JSON-Format, fehlendes erforderliches Feld (Format, Inhalt, Metadaten oder Sicherheit) @@ -218,23 +218,23 @@ vor weniger als einer Stunde exportiert in Verzeichnis: %1$s Endbenutzervereinbarung - DAS PROGRAMM DARF NICHT FÜR MEDIZINISCHE ENTSCHEIDUNGEN BENUTZT WERDEN. ES GIBT IN DIESEM PROJEKT KEINE GEWÄHRLEISTUNG ODER GARANTIERTE UNTERSTÜTZUNG IN IRGENDEINER ART. WENN DU DICH ENTSCHEIDEST, ES ZU NUTZEN, HÄNGT DIE QUALITÄT UND LEISTUNGSFÄHIGKEIT DIESES PROJEKTES VON DIR SELBST AB. ES WIRD \"WIE BESEHEN\" ZUR VERFÜGUNG GESTELLT. SOLLTE SICH DAS PROGRAMM ALS FEHLERHAFT ERWEISEN, ÜBERNEHMEN SIE ALLE NOTWENDIGEN KRANKHEITSKOSTEN, SERVICELEISTUNGEN, REPARATUREN ODER KORREKTUREN. + DAS PROGRAMM DARF NICHT FÜR MEDIZINISCHE ENTSCHEIDUNGEN BENUTZT WERDEN. ES GIBT IN DIESEM PROJEKT KEINE GEWÄHRLEISTUNG ODER GARANTIERTE UNTERSTÜTZUNG IN IRGENDEINER ART. WENN DU DICH ENTSCHEIDEST, ES ZU NUTZEN, HÄNGT DIE QUALITÄT UND LEISTUNGSFÄHIGKEIT DIESES PROJEKTES VON DIR SELBST AB. ES WIRD \"WIE BESEHEN\" ZUR VERFÜGUNG GESTELLT. SOLLTE SICH DAS PROGRAMM ALS FEHLERHAFT ERWEISEN, ÜBERNIMMST DU ALLE NOTWENDIGEN KRANKHEITSKOSTEN, SERVICELEISTUNGEN, REPARATUREN ODER KORREKTUREN. Ich verstehe und stimme zu. Speichern Profil neuladen SMS-Kommunikator Erlaubte Telefonnummern +XXXXXXXXXX;+YYYYYYYYYY - Um einen Bolus von %1$.2f IE abzugeben, antworte mit dem Code %2$s. + Um einen Bolus von %1$.2f IE abzugeben, antworte mit dem Code %2$s. Um einen Mahlzeitenbolus von %1$.2f IE abzugeben, antworte mit dem Code %2$s. - Um ein Temp Target von %1$s zu setzen, antworte mit dem Code %2$s + Um ein temporäres Ziel von %1$s zu setzen, antworte mit dem Code %2$s Um das temporäre Ziel zu stoppen, antworte mit dem Code %1$s - Um den SMS Remote Service zu deaktivieren, antworte mit dem Code %1$s.\n\nBeachte, dass Du diesen nur am AAPS Master Smartphone wieder aktivieren kannst. - SMS Remote Service gestoppt. Verwende das AAPS Master, um ihn wieder zu aktivieren. + Um die SMS-Fernsteuerung zu deaktivieren, antworte mit dem Code %1$s\n\nBeachte, dass Du diesen nur am AAPS-Master-Smartphone wieder aktivieren kannst. + SMS-Fernsteuerung gestoppt. Verwende das AAPS-Master-Smartphone, um sie wieder zu aktivieren. Um die Kalibrierung %1$.2f zu senden, antworte mit dem Code %2$s. Bolus fehlgeschlagen - Minimale Dauer in Minuten, die nach einem Remote Bolus verstrichen sein muss, bevor ein neuer abgegeben werden kann. - Anzahl Minuten, die mindestens zwischen zwei Bolusgaben liegen müssen. + Minimale Dauer in Minuten, die nach einem Remote-Bolus verstrichen sein muss, bevor ein neuer abgegeben werden kann. + Anzahl der Minuten, die mindestens zwischen zwei Remote-Bolusabgaben liegen müssen. Aus Sicherheitsgründen musst Du mindestens zwei Telefonnummern eintragen, um diese Voreinstellung zu ändern. Bolus %1$.2fIE erfolgreich abgegeben Werde %1$.2fIE abgeben @@ -243,7 +243,7 @@ Ziel %1$s für %2$d Minuten Ziel %1$s für %2$d Minuten erfolgreich gesetzt. Temporäres Ziel wurde erfolgreich abgebrochen - Erlaube externe Befehle per SMS + Erlaube Fernsteuerung per SMS DanaR Profil-Einstellungen DIA [h] Dauer der Insulinwirkung @@ -264,6 +264,9 @@ Um %1$dg Kohlenhydrate um %2$s einzugeben, antworte mit dem Code %3$s Um die Basalrate von %1$d%% für %2$d Minuten zu setzen, antworte mit dem Code %3$s Um das Loopen für %1$d Minuten zu pausieren, antworte mit dem Code %2$s. + Um den Loop fortzusetzen, antworte mit dem Code %1$s + Um den Loop zu aktivieren, antworte mit dem Code %1$s + Um den Loop zu deaktivieren, antworte mit dem Code %1$s TBR mit %1$.2f IE/h für %2$d min wurde erfolgreich gestartet. Der erweiterte Bolus %1$.2f IE/h für %2$d Minuten wurde erfolgreich gestartet %1$dg Kohlenhydrate erfolgreich erfasst. @@ -276,7 +279,7 @@ TBR abgebrochen Die Abgabe des erweiterten Bolus wurde abgebrochen. Das Abbrechen der TBR ist fehlgeschlagen. - Der Abbruch des erweiterten Bolus ist fehlgeschlagen + Der Abbruch des erweiterten Bolus ist fehlgeschlagen. Unbekannter Befehl oder falsche Antwort QuickWizard QuickWizard-Einstellungen @@ -352,7 +355,7 @@ Profil Standardwert: 3\nDies ist eine wichtige Sicherheitseinstellung. Sie begrenzt das maximale Basal-IOB auf die dreifache Menge (im Standardfall) deiner größten Basalrate. In der Regel solltest Du diesen Wert nicht ändern. Aber Du solltest wissen, was \"3x max daily, 4x current\" als Sicherheitseinstellung bedeutet. Standardwert: 4\nDies ist die andere wichtige Sicherheitseinstellung, die zweite Hälfte von \"3x max daily, 4x current\". Diese Grenze beschränkt das Basal-IOB auf die (im Standardfall) vierfache Menge der aktuellen Basalrate. Dies ist wichtig, um Nutzer davor zu bewahren, zuviel Basal-Insulin zu verabreichen. Nochmals, der Standardwert ist 4x. Die meisten Nutzer werden niemals diese Einstellung verändern, sondern andere Einstellungen anpassen, um sich nicht dieser Sicherheitsgrenze zu nähern. - Standardwert: 1.2\nDies ist eine Sicherheitsgrenze für Autosens (und bald auch Autotune), die besagt, wie hoch Autosens Basalraten anpassen darf und wie niedrig der ISF (Insulin-Sensitivitäts-Faktor) und der BZ-Zielwert eingestellt werden können. 1.2 ist dabei der Multiplikationsfaktor und erlaubt eine Anpassung um 20%%. + Standardwert: 1.2\nDies ist eine Sicherheitsgrenze für Autosens (und bald auch Autotune), die besagt, wie stark Autosens Basalraten erhöhen darf und wie niedrig der ISF (Insulin-Sensitivitäts-Faktor) und der BZ-Zielwert eingestellt werden können. 1.2 ist dabei der Multiplikationsfaktor und erlaubt eine Anpassung um 20%%. Standardwert: 0.7\nDies ist die andere Sicherheitsgrenze für autosens. Sie beschränkt, wie weit Basalraten abgesenkt und wie sehr ISF und BZ-Zielwerte erhöht werden können. Autosens passt Zielwerte ebenfalls an Vorgabe: erlaubt.\nErlaubt Autosens den Ziel-BZ-Bereich in Verbindung mit ISF und Basal anzupassen. @@ -401,7 +404,7 @@ Insulinresistenter Erwachsener Bitte wähle das Patientenalter, um die Sicherheits-Limits festzulegen Name des Patienten - Gib den Namen des Patienten oder einen Spitznamen für die Unterscheidung zwischen mehreren Setups an. + Bitte gib den Namen des Patienten oder einen Spitznamen an, um mehrere Setups unterscheiden zu können. Nutzer Glimp %1$s benötigt eine deaktivierte Akku-Leistungsoptimierung, um korrekt arbeiten zu können. @@ -502,7 +505,7 @@ Abbrechen Es sind nicht alle Profile geladen! Werte nicht gespeichert! - Aktiviere die Datenübertragung zu anderen Apps (z.B. xDrip). Nicht aktivieren falls Du mehr als eine Instanz von AAPS oder NSClient installiert hast! + Aktiviere die Datenübertragung zu anderen Apps (z.B. xDrip). Nicht aktivieren, falls Du mehr als eine Instanz von AAPS oder NSClient installiert hast! Aktiviere lokale Broadcasts AKTIVITÄT & FEEDBACK CARBS & BOLUS @@ -557,10 +560,10 @@ BZ Upload Einstellungen Zeige detailliertes Delta Delta wird mit Dezimalstelle angezeigt. - Wie häufig SMBs angegeben werden (in Min.) + Wie häufig SMBs abgegeben werden (in Min.) SMB max. Minuten SMB Basal-Limit in Minuten - UAM SMB max minutes + UAM SMB max. Minuten SMB Basal-Limit in Minuten für UAM Schwellenwert für KH-Empfehlung Sende BZ-Werte zu xDrip+ diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 74f3b85a88..cf85eb4cbc 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -1374,7 +1374,6 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Intégration de la pompe Omnipod Dash. Rappel fin d\'appairage Rappel fin de configuration - Le Pod expire bientôt Le Pod expire bientôt Arrêt imminent Réservoir bas diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index 6204534b5b..7b83a52d8b 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -264,6 +264,9 @@ Per inserire %1$dg a %2$s rispondi col codice %3$s Per avviare la basale %1$d%% per %2$d min rispondi col codice %3$s Per sospendere il loop per %1$d minuti rispondi col codice %2$s + Per riprendere il loop rispondi col codice %1$s + Per abilitare il loop rispondi col codice %1$s + Per disabilitare il loop rispondi col codice %1$s Basale temporanea %1$.2fU/h per %2$d min avviata con successo Bolo esteso %1$.2fU/h per %2$d min avviato con successo CHO %1$dg inseriti con successo diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 9dabcc46a9..2d3d87cb2b 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1369,7 +1369,6 @@ Integração da Bomba para Omnipod Dash. Lembrete Concluir Emparelhamento Lembrete Terminar Configuração - Pod vai expirar em breve Pod vai expirar em breve Encerramento iminente Reservatório baixo diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 6d7acb563b..9cc2bd4367 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -1369,7 +1369,6 @@ Integração da Bomba para Omnipod Dash. Lembrete Concluir Emparelhamento Lembrete Terminar Configuração - Pod vai expirar em breve Pod vai expirar em breve Encerramento iminente Reservatório baixo diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index e25728c0ba..9fd0272030 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -264,6 +264,9 @@ Чтобы ввести %1$d г в %2$s ответьте кодом %3$s Для начала подачи базала %1$d%% на %2$d мин. ответьте кодом %3$s для приостановки цикла на %1$d мин ответьте кодом %2$s + Чтобы возобновить цикл ответьте кодом %1$s + Чтобы включить цикл ответьте кодом %1$s + Чтобы отключить цикл ответьте кодом %1$s врем базал %1$.2fU/h на %2$d мин начат успешно Пролонгированный болюс %1$.2fед. на %2$d мин. начат успешно Углеводы %1$d г введены успешно @@ -468,6 +471,8 @@ Переключить профиль Батарея помпы работает опции оповещения + Создать уведомления из оповещений NS + Создать уведомления из оповещений NS Порог оповещения об устаревших данных [min] (мин) Порог тревоги об устаревших данных [min] (мин) Интервал для autosens [h] (ч) @@ -1375,7 +1380,7 @@ Context | Edit Context Интеграция с помпой Omnompod Dash. Напоминание о завершении сопряжения Напоминание о завершении настройки - Срок Pod\'a истекает в ближайшее время + Срок работы Pod\'a истекает Срок Pod\'a истекает в ближайшее время Остановка неизбежна В резервуаре мало инсулина diff --git a/app/src/main/res/values-sk-rSK/strings.xml b/app/src/main/res/values-sk-rSK/strings.xml index f696bd3f2c..e2e47f5a97 100644 --- a/app/src/main/res/values-sk-rSK/strings.xml +++ b/app/src/main/res/values-sk-rSK/strings.xml @@ -1369,7 +1369,6 @@ Integrácia pumpy pre Omnipod Dash. Pripomienka ukončenia párovania Pripomienka ukončenia nastavenia - Pod čoskoro expiruje Pod čoskoro expiruje Vypnutie je bezprostredné Nízka hladina zásobníka diff --git a/app/src/main/res/values-sv-rSE/strings.xml b/app/src/main/res/values-sv-rSE/strings.xml index f49188b9ff..5e43c9f113 100644 --- a/app/src/main/res/values-sv-rSE/strings.xml +++ b/app/src/main/res/values-sv-rSE/strings.xml @@ -1370,7 +1370,6 @@ Eversense-appen. Pumpintegration för Omnipod Dash. Påminnelse att slutföra parkoppling Påminnelse att slutföra installation - Pod kommer att gå ut inom kort Pod kommer att gå ut inom kort Pod kommer snart att stängas av Låg reservoar From 3354bb7da400c4c4a226182e7b85516bd27f7c5f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 27 May 2020 22:57:12 +0200 Subject: [PATCH 45/45] OKDialogs ok button guard --- .../androidaps/utils/alertDialogs/OKDialog.kt | 138 ++++++++++++------ .../utils/alertDialogs/WarningDialog.kt | 36 +++-- 2 files changed, 112 insertions(+), 62 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/OKDialog.kt b/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/OKDialog.kt index 2d45d2910d..c0fc646258 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/OKDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/OKDialog.kt @@ -12,6 +12,7 @@ import info.nightscout.androidaps.utils.extensions.runOnUiThread object OKDialog { @SuppressLint("InflateParams") fun show(context: Context, title: String, message: String, runnable: Runnable? = null) { + var okClicked = false var notEmptytitle = title if (notEmptytitle.isEmpty()) notEmptytitle = context.getString(R.string.message) @@ -19,18 +20,21 @@ object OKDialog { .setCustomTitle(AlertDialogHelper.buildCustomTitle(context, notEmptytitle)) .setMessage(message) .setPositiveButton(context.getString(R.string.ok)) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - runOnUiThread(runnable) + if (okClicked) return@setPositiveButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + runOnUiThread(runnable) + } } .show() .setCanceledOnTouchOutside(false) } @SuppressLint("InflateParams") - @JvmStatic - @JvmOverloads fun show(activity: Activity, title: String, message: Spanned, runnable: Runnable? = null) { + var okClicked = false var notEmptytitle = title if (notEmptytitle.isEmpty()) notEmptytitle = activity.getString(R.string.message) @@ -38,9 +42,13 @@ object OKDialog { .setCustomTitle(AlertDialogHelper.buildCustomTitle(activity, notEmptytitle)) .setMessage(message) .setPositiveButton(activity.getString(R.string.ok)) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - runnable?.let { activity.runOnUiThread(it) } + if (okClicked) return@setPositiveButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + runnable?.let { activity.runOnUiThread(it) } + } } .show() .setCanceledOnTouchOutside(false) @@ -57,71 +65,89 @@ object OKDialog { } @SuppressLint("InflateParams") - @JvmStatic - @JvmOverloads fun showConfirmation(activity: Activity, title: String, message: Spanned, ok: Runnable?, cancel: Runnable? = null) { + var okClicked = false AlertDialogHelper.Builder(activity) .setMessage(message) .setCustomTitle(AlertDialogHelper.buildCustomTitle(activity, title)) .setPositiveButton(android.R.string.ok) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - ok?.let { activity.runOnUiThread(it) } + if (okClicked) return@setPositiveButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + ok?.let { activity.runOnUiThread(it) } + } } .setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - cancel?.let { activity.runOnUiThread(it) } + if (okClicked) return@setNegativeButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + cancel?.let { activity.runOnUiThread(it) } + } } - .setNegativeButton(android.R.string.cancel, null) .show() .setCanceledOnTouchOutside(false) } @SuppressLint("InflateParams") - @JvmStatic fun showConfirmation(activity: Activity, title: String, message: String, ok: Runnable?, cancel: Runnable? = null) { + var okClicked = false AlertDialogHelper.Builder(activity) .setMessage(message) .setCustomTitle(AlertDialogHelper.buildCustomTitle(activity, title)) .setPositiveButton(android.R.string.ok) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - ok?.let { activity.runOnUiThread(it) } + if (okClicked) return@setPositiveButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + ok?.let { activity.runOnUiThread(it) } + } } .setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - cancel?.let { activity.runOnUiThread(it) } + if (okClicked) return@setNegativeButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + cancel?.let { activity.runOnUiThread(it) } + } } .show() .setCanceledOnTouchOutside(false) } - @JvmStatic - @JvmOverloads fun showConfirmation(context: Context, message: Spanned, ok: Runnable?, cancel: Runnable? = null) { showConfirmation(context, context.getString(R.string.confirmation), message, ok, cancel) } @SuppressLint("InflateParams") - @JvmStatic - @JvmOverloads fun showConfirmation(context: Context, title: String, message: Spanned, ok: Runnable?, cancel: Runnable? = null) { + var okClicked = false AlertDialogHelper.Builder(context) .setMessage(message) .setCustomTitle(AlertDialogHelper.buildCustomTitle(context, title)) .setPositiveButton(android.R.string.ok) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - runOnUiThread(ok) + if (okClicked) return@setPositiveButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + runOnUiThread(ok) + } } .setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - runOnUiThread(cancel) + if (okClicked) return@setNegativeButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + runOnUiThread(cancel) + } } - .setNegativeButton(android.R.string.cancel, null) .show() .setCanceledOnTouchOutside(false) } @@ -136,18 +162,27 @@ object OKDialog { @JvmStatic @JvmOverloads fun showConfirmation(context: Context, title: String, message: String, ok: Runnable?, cancel: Runnable? = null) { + var okClicked = false AlertDialogHelper.Builder(context) .setMessage(message) .setCustomTitle(AlertDialogHelper.buildCustomTitle(context, title)) .setPositiveButton(android.R.string.ok) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - runOnUiThread(ok) + if (okClicked) return@setPositiveButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + runOnUiThread(ok) + } } .setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - runOnUiThread(cancel) + if (okClicked) return@setNegativeButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + runOnUiThread(cancel) + } } .show() .setCanceledOnTouchOutside(false) @@ -157,18 +192,27 @@ object OKDialog { @JvmStatic @JvmOverloads fun showConfirmation(context: Context, title: String, message: String, ok: DialogInterface.OnClickListener?, cancel: DialogInterface.OnClickListener? = null) { + var okClicked = false AlertDialogHelper.Builder(context) .setMessage(message) .setCustomTitle(AlertDialogHelper.buildCustomTitle(context, title)) .setPositiveButton(android.R.string.ok) { dialog: DialogInterface, which: Int -> - dialog.dismiss() - SystemClock.sleep(100) - ok?.onClick(dialog, which) + if (okClicked) return@setPositiveButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + ok?.onClick(dialog, which) + } } .setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, which: Int -> - dialog.dismiss() - SystemClock.sleep(100) - cancel?.onClick(dialog, which) + if (okClicked) return@setNegativeButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + cancel?.onClick(dialog, which) + } } .show() .setCanceledOnTouchOutside(false) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/WarningDialog.kt b/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/WarningDialog.kt index 847287d57a..2894f1b8d4 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/WarningDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/WarningDialog.kt @@ -13,31 +13,37 @@ import info.nightscout.androidaps.utils.extensions.runOnUiThread object WarningDialog { @SuppressLint("InflateParams") - @JvmStatic - @JvmOverloads fun showWarning(context: Context, title: String, message: String, @StringRes positiveButton: Int = -1, ok: (() -> Unit)? = null, cancel: (() -> Unit)? = null) { - + var okClicked = false val builder = AlertDialogHelper.Builder(context, R.style.AppThemeWarningDialog) .setMessage(message) .setCustomTitle(AlertDialogHelper.buildCustomTitle(context, title, R.drawable.ic_header_warning, R.style.AppThemeWarningDialog)) .setNegativeButton(R.string.dismiss) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - if (cancel != null) { - runOnUiThread(Runnable { - cancel() - }) + if (okClicked) return@setNegativeButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + if (cancel != null) { + runOnUiThread(Runnable { + cancel() + }) + } } } if (positiveButton != -1) { builder.setPositiveButton(positiveButton) { dialog: DialogInterface, _: Int -> - dialog.dismiss() - SystemClock.sleep(100) - if (ok != null) { - runOnUiThread(Runnable { - ok() - }) + if (okClicked) return@setPositiveButton + else { + okClicked = true + dialog.dismiss() + SystemClock.sleep(100) + if (ok != null) { + runOnUiThread(Runnable { + ok() + }) + } } } }