From d49356a9221af3c85317fc234166ea8dedb42e58 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 24 Jul 2017 15:17:06 +0200 Subject: [PATCH 01/27] Logging: Print filename and line instead of logger name. --- app/src/main/assets/logback.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/logback.xml b/app/src/main/assets/logback.xml index 1e18709044..c34ff08b80 100644 --- a/app/src/main/assets/logback.xml +++ b/app/src/main/assets/logback.xml @@ -15,7 +15,7 @@ 120 - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + %d{HH:mm:ss.SSS} [%thread] %-5level [%file:%line]: %msg%n @@ -24,7 +24,7 @@ %logger{0} - [%thread] %-5level %logger{36} - %msg%n + [%thread] %-5level [%file:%line]: %msg%n From 2d2ccde6e4e0717508eec11783f0f196e829654b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 14 Aug 2017 12:11:53 +0200 Subject: [PATCH 02/27] log Bundle --- .../androidaps/Services/DataService.java | 3 ++- .../info/nightscout/utils/BundleLogger.java | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/info/nightscout/utils/BundleLogger.java diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java index 3b04c30d94..39eb023cb3 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java @@ -37,6 +37,7 @@ import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin; import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin; import info.nightscout.androidaps.receivers.DataReceiver; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus; +import info.nightscout.utils.BundleLogger; import info.nightscout.utils.SP; @@ -56,7 +57,7 @@ public class DataService extends IntentService { @Override protected void onHandleIntent(final Intent intent) { if (Config.logFunctionCalls) - log.debug("onHandleIntent " + intent); + log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras())); if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceXdripPlugin.class)) { xDripEnabled = true; diff --git a/app/src/main/java/info/nightscout/utils/BundleLogger.java b/app/src/main/java/info/nightscout/utils/BundleLogger.java new file mode 100644 index 0000000000..ba6ffff869 --- /dev/null +++ b/app/src/main/java/info/nightscout/utils/BundleLogger.java @@ -0,0 +1,21 @@ +package info.nightscout.utils; + +import android.os.Bundle; + +/** + * Created by mike on 14.08.2017. + */ + +public class BundleLogger { + public static String log(Bundle bundle) { + if (bundle == null) { + return null; + } + String string = "Bundle{"; + for (String key : bundle.keySet()) { + string += " " + key + " => " + bundle.get(key) + ";"; + } + string += " }Bundle"; + return string; + } +} From b8496e3208230f424531d8779a18e20a30aea728 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 00:43:49 +0200 Subject: [PATCH 03/27] insulincurves - working with default params --- .../info/nightscout/androidaps/MainApp.java | 2 + .../InsulinRapidActingOrefFragment.java | 57 ++++++++ .../InsulinRapidActingOrefPlugin.java | 134 ++++++++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefFragment.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefPlugin.java diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 817b0adafb..ba2f14a2de 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -32,6 +32,7 @@ import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesFragme import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin; import info.nightscout.androidaps.plugins.InsulinFastacting.InsulinFastactingFragment; import info.nightscout.androidaps.plugins.InsulinFastactingProlonged.InsulinFastactingProlongedFragment; +import info.nightscout.androidaps.plugins.InsulinRapidActingOref.InsulinRapidActingOrefFragment; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.Loop.LoopFragment; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment; @@ -113,6 +114,7 @@ public class MainApp extends Application { if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin()); pluginsList.add(InsulinFastactingFragment.getPlugin()); pluginsList.add(InsulinFastactingProlongedFragment.getPlugin()); + pluginsList.add(InsulinRapidActingOrefFragment.getPlugin()); pluginsList.add(SensitivityOref0Plugin.getPlugin()); pluginsList.add(SensitivityAAPSPlugin.getPlugin()); pluginsList.add(SensitivityWeightedAveragePlugin.getPlugin()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefFragment.java new file mode 100644 index 0000000000..52e805c05c --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefFragment.java @@ -0,0 +1,57 @@ +package info.nightscout.androidaps.plugins.InsulinRapidActingOref; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.InsulinFastacting.ActivityGraph; + +/** + * Created by mike on 17.04.2017. + */ + +public class InsulinRapidActingOrefFragment extends Fragment { + static InsulinRapidActingOrefPlugin insulinRapidActingOrefPlugin = new InsulinRapidActingOrefPlugin(); + + static public InsulinRapidActingOrefPlugin getPlugin() { + return insulinRapidActingOrefPlugin; + } + + TextView insulinName; + TextView insulinComment; + TextView insulinDia; + ActivityGraph insulinGraph; + + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.insulin_fragment, container, false); + + insulinName = (TextView) view.findViewById(R.id.insulin_name); + insulinComment = (TextView) view.findViewById(R.id.insulin_comment); + insulinDia = (TextView) view.findViewById(R.id.insulin_dia); + insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph); + + updateGUI(); + + return view; + } + + @Override + public void onResume() { + super.onResume(); + updateGUI(); + } + + private void updateGUI() { + insulinName.setText(insulinRapidActingOrefPlugin.getFriendlyName()); + insulinComment.setText(insulinRapidActingOrefPlugin.getComment()); + insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinRapidActingOrefPlugin.getDia()).toString() + "h"); + insulinGraph.show(insulinRapidActingOrefPlugin); + } + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefPlugin.java new file mode 100644 index 0000000000..bdb92334ee --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefPlugin.java @@ -0,0 +1,134 @@ +package info.nightscout.androidaps.plugins.InsulinRapidActingOref; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.Iob; +import info.nightscout.androidaps.db.Treatment; +import info.nightscout.androidaps.interfaces.InsulinInterface; +import info.nightscout.androidaps.interfaces.PluginBase; + +/** + * Created by mike on 17.04.2017. + */ + +public class InsulinRapidActingOrefPlugin implements PluginBase, InsulinInterface { + + private static boolean fragmentEnabled = false; + private static boolean fragmentVisible = false; + + @Override + public int getType() { + return INSULIN; + } + + @Override + public String getFragmentClass() { + return InsulinRapidActingOrefFragment.class.getName(); + } + + @Override + public String getName() { + return "Rapid-Acting Oref"; + } + + @Override + public String getNameShort() { + return MainApp.sResources.getString(R.string.insulin_shortname); + } + + @Override + public boolean isEnabled(int type) { + return type == INSULIN && fragmentEnabled; + } + + @Override + public boolean isVisibleInTabs(int type) { + return type == INSULIN && fragmentVisible; + } + + @Override + public boolean canBeHidden(int type) { + return true; + } + + @Override + public boolean hasFragment() { + return true; + } + + @Override + public boolean showInList(int type) { + return true; + } + + @Override + public void setFragmentEnabled(int type, boolean fragmentEnabled) { + if (type == INSULIN) this.fragmentEnabled = fragmentEnabled; + } + + @Override + public void setFragmentVisible(int type, boolean fragmentVisible) { + if (type == INSULIN) this.fragmentVisible = fragmentVisible; + } + + // Insulin interface + @Override + public int getId() { + return FASTACTINGINSULINPROLONGED; + } + + @Override + public String getFriendlyName() { + return "Rapid-Acting Oref"; + } + + @Override + public String getComment() { + return MainApp.sResources.getString(R.string.fastactinginsulincomment); + } + + @Override + public double getDia() { + //TODO: dynamic dia fetching + return 6d; + //return MainApp.getConfigBuilder().getProfile() != null ? MainApp.getConfigBuilder().getProfile().getDia() : Constants.defaultDIA; + } + + @Override + public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) { + Iob result = new Iob(); + + + //curveDefaults + + int peak= 75; + + + if (treatment.insulin != 0d) { + + long bolusTime = treatment.date; + double t = (time - bolusTime) / 1000d / 60d; + + double td = getDia()*60; + + if(getDia() < 5){ + //TODO: Check that DIA is > 5 hours for this plugin! + td = 300; + } + + double tp = peak; + + + // force the IOB to 0 if over 5 hours have passed + if (t < td) { + double tau = tp * (1 - tp / td) / (1 - 2 * tp / td); + double a = 2 * tau / td; + double S = 1 / (1 - a + (1 + a) * Math.exp(-td / tau)); + result.activityContrib = treatment.insulin * (S / Math.pow(tau, 2)) * t * (1 - t / td) * Math.exp(-t / tau); + result.iobContrib = treatment.insulin * (1 - S * (1 - a) * ((Math.pow(t, 2) / (tau * td * (1 - a)) - t / tau - 1) * Math.exp(-t / tau) + 1)); + + } + } + return result; + } +} From 8adff150f7e483385eeba1e28b009e644e253e00 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 01:14:11 +0200 Subject: [PATCH 04/27] AdriAPS diaadaption From a538160e76fc439d5d46ff3e5ba40cca039d977a Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 11:44:34 +0200 Subject: [PATCH 05/27] insulincurves - rapid and ultra both with adjustable dia --- .../info/nightscout/androidaps/MainApp.java | 6 +- .../interfaces/InsulinInterface.java | 4 + .../InsulinOrefBaseFragment.java} | 17 +-- .../InsulinOrefBasePlugin.java | 83 +++++++++++ .../InsulinOrefRapidActingFragment.java | 57 ++++++++ .../InsulinOrefRapidActingPlugin.java | 66 +++++++++ .../InsulinOrefUltraRapidActingFragment.java | 58 ++++++++ .../InsulinOrefUltraRapidActingPlugin.java | 66 +++++++++ .../InsulinRapidActingOrefPlugin.java | 134 ------------------ 9 files changed, 345 insertions(+), 146 deletions(-) rename app/src/main/java/info/nightscout/androidaps/plugins/{InsulinRapidActingOref/InsulinRapidActingOrefFragment.java => InsulinOrefCurves/InsulinOrefBaseFragment.java} (66%) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingFragment.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingFragment.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefPlugin.java diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index ba2f14a2de..4012dbc20a 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -32,7 +32,8 @@ import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesFragme import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin; import info.nightscout.androidaps.plugins.InsulinFastacting.InsulinFastactingFragment; import info.nightscout.androidaps.plugins.InsulinFastactingProlonged.InsulinFastactingProlongedFragment; -import info.nightscout.androidaps.plugins.InsulinRapidActingOref.InsulinRapidActingOrefFragment; +import info.nightscout.androidaps.plugins.InsulinOrefCurves.InsulinOrefRapidActingFragment; +import info.nightscout.androidaps.plugins.InsulinOrefCurves.InsulinOrefUltraRapidActingFragment; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.Loop.LoopFragment; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment; @@ -114,7 +115,8 @@ public class MainApp extends Application { if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin()); pluginsList.add(InsulinFastactingFragment.getPlugin()); pluginsList.add(InsulinFastactingProlongedFragment.getPlugin()); - pluginsList.add(InsulinRapidActingOrefFragment.getPlugin()); + pluginsList.add(InsulinOrefRapidActingFragment.getPlugin()); + pluginsList.add(InsulinOrefUltraRapidActingFragment.getPlugin()); pluginsList.add(SensitivityOref0Plugin.getPlugin()); pluginsList.add(SensitivityAAPSPlugin.getPlugin()); pluginsList.add(SensitivityWeightedAveragePlugin.getPlugin()); diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java index 20c563dede..0803f65373 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java @@ -12,6 +12,10 @@ import info.nightscout.androidaps.db.Treatment; public interface InsulinInterface { final int FASTACTINGINSULIN = 0; final int FASTACTINGINSULINPROLONGED = 1; + final int OREF_RAPID_ACTING = 2; + final int OREF_ULTRA_RAPID_ACTING = 3; + final int OREF_FREE_PEAK = 4; + int getId(); String getFriendlyName(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBaseFragment.java similarity index 66% rename from app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefFragment.java rename to app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBaseFragment.java index 52e805c05c..d9cd795792 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBaseFragment.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.InsulinRapidActingOref; +package info.nightscout.androidaps.plugins.InsulinOrefCurves; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -15,12 +15,9 @@ import info.nightscout.androidaps.plugins.InsulinFastacting.ActivityGraph; * Created by mike on 17.04.2017. */ -public class InsulinRapidActingOrefFragment extends Fragment { - static InsulinRapidActingOrefPlugin insulinRapidActingOrefPlugin = new InsulinRapidActingOrefPlugin(); +public abstract class InsulinOrefBaseFragment extends Fragment { - static public InsulinRapidActingOrefPlugin getPlugin() { - return insulinRapidActingOrefPlugin; - } + static InsulinOrefBasePlugin insulinPlugin = null; TextView insulinName; TextView insulinComment; @@ -48,10 +45,10 @@ public class InsulinRapidActingOrefFragment extends Fragment { } private void updateGUI() { - insulinName.setText(insulinRapidActingOrefPlugin.getFriendlyName()); - insulinComment.setText(insulinRapidActingOrefPlugin.getComment()); - insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinRapidActingOrefPlugin.getDia()).toString() + "h"); - insulinGraph.show(insulinRapidActingOrefPlugin); + insulinName.setText(insulinPlugin.getFriendlyName()); + insulinComment.setText(insulinPlugin.getComment()); + insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinPlugin.getDia()).toString() + "h"); + insulinGraph.show(insulinPlugin); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java new file mode 100644 index 0000000000..0cb2362a2d --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java @@ -0,0 +1,83 @@ +package info.nightscout.androidaps.plugins.InsulinOrefCurves; + +import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.Iob; +import info.nightscout.androidaps.db.Treatment; +import info.nightscout.androidaps.interfaces.InsulinInterface; +import info.nightscout.androidaps.interfaces.PluginBase; + +/** + * Created by adrian on 13.08.2017. + */ + +public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterface { + + public static double MIN_DIA = 5; + + @Override + public int getType() { + return INSULIN; + } + + @Override + public String getNameShort() { + return MainApp.sResources.getString(R.string.insulin_shortname); + } + + @Override + public boolean canBeHidden(int type) { + return true; + } + + @Override + public boolean hasFragment() { + return true; + } + + @Override + public boolean showInList(int type) { + return true; + } + + @Override + public double getDia() { + double dia = MainApp.getConfigBuilder().getProfile() != null ? MainApp.getConfigBuilder().getProfile().getDia() : Constants.defaultDIA; + return Math.max(MIN_DIA, dia); + //TODO: show on chart if restriction applied + } + + @Override + public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) { + Iob result = new Iob(); + + + //curveDefaults + + int peak = getPeak(); + + + if (treatment.insulin != 0d) { + + long bolusTime = treatment.date; + double t = (time - bolusTime) / 1000d / 60d; + + double td = getDia()*60; //getDIA() always > 5 + double tp = peak; + + // force the IOB to 0 if over DIA hours have passed + if (t < td) { + double tau = tp * (1 - tp / td) / (1 - 2 * tp / td); + double a = 2 * tau / td; + double S = 1 / (1 - a + (1 + a) * Math.exp(-td / tau)); + result.activityContrib = treatment.insulin * (S / Math.pow(tau, 2)) * t * (1 - t / td) * Math.exp(-t / tau); + result.iobContrib = treatment.insulin * (1 - S * (1 - a) * ((Math.pow(t, 2) / (tau * td * (1 - a)) - t / tau - 1) * Math.exp(-t / tau) + 1)); + } + } + return result; + } + + abstract int getPeak(); + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingFragment.java new file mode 100644 index 0000000000..ef11435805 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingFragment.java @@ -0,0 +1,57 @@ +package info.nightscout.androidaps.plugins.InsulinOrefCurves; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.InsulinFastacting.ActivityGraph; + +/** + * Created by adrian on 14/08/17. + */ + +public class InsulinOrefRapidActingFragment extends Fragment { + + static InsulinOrefRapidActingPlugin insulinPlugin = new InsulinOrefRapidActingPlugin(); + + static public InsulinOrefRapidActingPlugin getPlugin() { + return insulinPlugin; + } + + TextView insulinName; + TextView insulinComment; + TextView insulinDia; + ActivityGraph insulinGraph; + + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.insulin_fragment, container, false); + + insulinName = (TextView) view.findViewById(R.id.insulin_name); + insulinComment = (TextView) view.findViewById(R.id.insulin_comment); + insulinDia = (TextView) view.findViewById(R.id.insulin_dia); + insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph); + + updateGUI(); + + return view; + } + + @Override + public void onResume() { + super.onResume(); + updateGUI(); + } + + private void updateGUI() { + insulinName.setText(insulinPlugin.getFriendlyName()); + insulinComment.setText(insulinPlugin.getComment()); + insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinPlugin.getDia()).toString() + "h"); + insulinGraph.show(insulinPlugin); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java new file mode 100644 index 0000000000..93ba75ebde --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java @@ -0,0 +1,66 @@ +package info.nightscout.androidaps.plugins.InsulinOrefCurves; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; + +/** + * Created by adrian on 14/08/17. + */ + +public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin { + + private static boolean fragmentEnabled = false; + private static boolean fragmentVisible = false; + + public static final int PEAK = 75; + + @Override + public int getId() { + return OREF_RAPID_ACTING; + } + + @Override + public String getName() { + return "Rapid-Acting Oref"; + } + + @Override + public String getFragmentClass() { + return InsulinOrefRapidActingFragment.class.getName(); + } + + @Override + public String getFriendlyName() { + return "Rapid-Acting Oref"; + } + + @Override + public String getComment() { + return MainApp.sResources.getString(R.string.fastactinginsulincomment); + } + + @Override + public boolean isEnabled(int type) { + return type == INSULIN && fragmentEnabled; + } + + @Override + public boolean isVisibleInTabs(int type) { + return type == INSULIN && fragmentVisible; + } + + @Override + public void setFragmentEnabled(int type, boolean fragmentEnabled) { + if (type == INSULIN) this.fragmentEnabled = fragmentEnabled; + } + + @Override + public void setFragmentVisible(int type, boolean fragmentVisible) { + if (type == INSULIN) this.fragmentVisible = fragmentVisible; + } + + @Override + int getPeak() { + return PEAK; + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingFragment.java new file mode 100644 index 0000000000..f09ba4e01d --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingFragment.java @@ -0,0 +1,58 @@ +package info.nightscout.androidaps.plugins.InsulinOrefCurves; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.InsulinFastacting.ActivityGraph; + +/** + * Created by adrian on 14/08/17. + */ + +public class InsulinOrefUltraRapidActingFragment extends Fragment { + + static InsulinOrefUltraRapidActingPlugin insulinPlugin = new InsulinOrefUltraRapidActingPlugin(); + + static public InsulinOrefUltraRapidActingPlugin getPlugin() { + return insulinPlugin; + } + + TextView insulinName; + TextView insulinComment; + TextView insulinDia; + ActivityGraph insulinGraph; + + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.insulin_fragment, container, false); + + insulinName = (TextView) view.findViewById(R.id.insulin_name); + insulinComment = (TextView) view.findViewById(R.id.insulin_comment); + insulinDia = (TextView) view.findViewById(R.id.insulin_dia); + insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph); + + updateGUI(); + + return view; + } + + @Override + public void onResume() { + super.onResume(); + updateGUI(); + } + + private void updateGUI() { + insulinName.setText(insulinPlugin.getFriendlyName()); + insulinComment.setText(insulinPlugin.getComment()); + insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinPlugin.getDia()).toString() + "h"); + insulinGraph.show(insulinPlugin); + } + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java new file mode 100644 index 0000000000..d538d1d470 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java @@ -0,0 +1,66 @@ +package info.nightscout.androidaps.plugins.InsulinOrefCurves; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; + +/** + * Created by adrian on 14/08/17. + */ + +public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin { + + private static boolean fragmentEnabled = false; + private static boolean fragmentVisible = false; + + public static final int PEAK = 55; + + @Override + public int getId() { + return OREF_ULTRA_RAPID_ACTING; + } + + @Override + public String getName() { + return "Ultra-Rapid-Acting Oref"; + } + + @Override + public String getFragmentClass() { + return InsulinOrefUltraRapidActingFragment.class.getName(); + } + + @Override + public String getFriendlyName() { + return "Ultra-Rapid-Acting Oref"; + } + + @Override + public String getComment() { + return "Fiasp"; + } + + @Override + public boolean isEnabled(int type) { + return type == INSULIN && fragmentEnabled; + } + + @Override + public boolean isVisibleInTabs(int type) { + return type == INSULIN && fragmentVisible; + } + + @Override + public void setFragmentEnabled(int type, boolean fragmentEnabled) { + if (type == INSULIN) this.fragmentEnabled = fragmentEnabled; + } + + @Override + public void setFragmentVisible(int type, boolean fragmentVisible) { + if (type == INSULIN) this.fragmentVisible = fragmentVisible; + } + + @Override + int getPeak() { + return PEAK; + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefPlugin.java deleted file mode 100644 index bdb92334ee..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinRapidActingOref/InsulinRapidActingOrefPlugin.java +++ /dev/null @@ -1,134 +0,0 @@ -package info.nightscout.androidaps.plugins.InsulinRapidActingOref; - -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.Iob; -import info.nightscout.androidaps.db.Treatment; -import info.nightscout.androidaps.interfaces.InsulinInterface; -import info.nightscout.androidaps.interfaces.PluginBase; - -/** - * Created by mike on 17.04.2017. - */ - -public class InsulinRapidActingOrefPlugin implements PluginBase, InsulinInterface { - - private static boolean fragmentEnabled = false; - private static boolean fragmentVisible = false; - - @Override - public int getType() { - return INSULIN; - } - - @Override - public String getFragmentClass() { - return InsulinRapidActingOrefFragment.class.getName(); - } - - @Override - public String getName() { - return "Rapid-Acting Oref"; - } - - @Override - public String getNameShort() { - return MainApp.sResources.getString(R.string.insulin_shortname); - } - - @Override - public boolean isEnabled(int type) { - return type == INSULIN && fragmentEnabled; - } - - @Override - public boolean isVisibleInTabs(int type) { - return type == INSULIN && fragmentVisible; - } - - @Override - public boolean canBeHidden(int type) { - return true; - } - - @Override - public boolean hasFragment() { - return true; - } - - @Override - public boolean showInList(int type) { - return true; - } - - @Override - public void setFragmentEnabled(int type, boolean fragmentEnabled) { - if (type == INSULIN) this.fragmentEnabled = fragmentEnabled; - } - - @Override - public void setFragmentVisible(int type, boolean fragmentVisible) { - if (type == INSULIN) this.fragmentVisible = fragmentVisible; - } - - // Insulin interface - @Override - public int getId() { - return FASTACTINGINSULINPROLONGED; - } - - @Override - public String getFriendlyName() { - return "Rapid-Acting Oref"; - } - - @Override - public String getComment() { - return MainApp.sResources.getString(R.string.fastactinginsulincomment); - } - - @Override - public double getDia() { - //TODO: dynamic dia fetching - return 6d; - //return MainApp.getConfigBuilder().getProfile() != null ? MainApp.getConfigBuilder().getProfile().getDia() : Constants.defaultDIA; - } - - @Override - public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) { - Iob result = new Iob(); - - - //curveDefaults - - int peak= 75; - - - if (treatment.insulin != 0d) { - - long bolusTime = treatment.date; - double t = (time - bolusTime) / 1000d / 60d; - - double td = getDia()*60; - - if(getDia() < 5){ - //TODO: Check that DIA is > 5 hours for this plugin! - td = 300; - } - - double tp = peak; - - - // force the IOB to 0 if over 5 hours have passed - if (t < td) { - double tau = tp * (1 - tp / td) / (1 - 2 * tp / td); - double a = 2 * tau / td; - double S = 1 / (1 - a + (1 + a) * Math.exp(-td / tau)); - result.activityContrib = treatment.insulin * (S / Math.pow(tau, 2)) * t * (1 - t / td) * Math.exp(-t / tau); - result.iobContrib = treatment.insulin * (1 - S * (1 - a) * ((Math.pow(t, 2) / (tau * td * (1 - a)) - t / tau - 1) * Math.exp(-t / tau) + 1)); - - } - } - return result; - } -} From 63d46aed569dc88ce364af07d8bc5c84e59a44e6 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 12:38:01 +0200 Subject: [PATCH 06/27] insulincurves - minimum 5 --- .../InsulinOrefBasePlugin.java | 22 ++++++++++++++----- .../InsulinOrefRapidActingPlugin.java | 2 +- .../InsulinOrefUltraRapidActingPlugin.java | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java index 0cb2362a2d..17a28f04c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java @@ -43,18 +43,18 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf @Override public double getDia() { - double dia = MainApp.getConfigBuilder().getProfile() != null ? MainApp.getConfigBuilder().getProfile().getDia() : Constants.defaultDIA; + double dia = getUserDefinedDia(); return Math.max(MIN_DIA, dia); - //TODO: show on chart if restriction applied + } + + public double getUserDefinedDia() { + return MainApp.getConfigBuilder().getProfile() != null ? MainApp.getConfigBuilder().getProfile().getDia() : Constants.defaultDIA; } @Override public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) { Iob result = new Iob(); - - //curveDefaults - int peak = getPeak(); @@ -78,6 +78,18 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf return result; } + @Override + public String getComment() { + String comment = commentStandardText(); + double userDia = getUserDefinedDia(); + if(userDia < MIN_DIA){ + comment += "\n" + String.format("DIA of %s too short - using %s instead!", userDia, MIN_DIA); + } + return comment; + } + abstract int getPeak(); + abstract String commentStandardText(); + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java index 93ba75ebde..0643fd24a0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java @@ -35,7 +35,7 @@ public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin { } @Override - public String getComment() { + public String commentStandardText() { return MainApp.sResources.getString(R.string.fastactinginsulincomment); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java index d538d1d470..0e0f34efb4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java @@ -35,7 +35,7 @@ public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin { } @Override - public String getComment() { + public String commentStandardText() { return "Fiasp"; } From 085caddeee0fa70ccd39f2286367cb473d492e64 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 13:20:09 +0200 Subject: [PATCH 07/27] insulincurves - freepeak --- .../info/nightscout/androidaps/MainApp.java | 2 + .../androidaps/PreferencesActivity.java | 6 ++ .../InsulinOrefFreePeakFragment.java | 58 ++++++++++++++++ .../InsulinOrefFreePeakPlugin.java | 66 +++++++++++++++++++ app/src/main/res/values/strings.xml | 5 ++ .../main/res/xml/pref_insulinoreffreepeak.xml | 21 ++++++ 6 files changed, 158 insertions(+) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakFragment.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java create mode 100644 app/src/main/res/xml/pref_insulinoreffreepeak.xml diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 4012dbc20a..f83f47d299 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -32,6 +32,7 @@ import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesFragme import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin; import info.nightscout.androidaps.plugins.InsulinFastacting.InsulinFastactingFragment; import info.nightscout.androidaps.plugins.InsulinFastactingProlonged.InsulinFastactingProlongedFragment; +import info.nightscout.androidaps.plugins.InsulinOrefCurves.InsulinOrefFreePeakFragment; import info.nightscout.androidaps.plugins.InsulinOrefCurves.InsulinOrefRapidActingFragment; import info.nightscout.androidaps.plugins.InsulinOrefCurves.InsulinOrefUltraRapidActingFragment; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; @@ -117,6 +118,7 @@ public class MainApp extends Application { pluginsList.add(InsulinFastactingProlongedFragment.getPlugin()); pluginsList.add(InsulinOrefRapidActingFragment.getPlugin()); pluginsList.add(InsulinOrefUltraRapidActingFragment.getPlugin()); + pluginsList.add(InsulinOrefFreePeakFragment.getPlugin()); pluginsList.add(SensitivityOref0Plugin.getPlugin()); pluginsList.add(SensitivityAAPSPlugin.getPlugin()); pluginsList.add(SensitivityWeightedAveragePlugin.getPlugin()); diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java index c5d8769639..d486e898ce 100644 --- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java @@ -14,6 +14,7 @@ import android.preference.PreferenceManager; import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.interfaces.PluginBase; +import info.nightscout.androidaps.plugins.InsulinOrefCurves.InsulinOrefFreePeakPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.BluetoothDevicePreference; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; @@ -139,6 +140,11 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre if (virtualPumpPlugin != null && virtualPumpPlugin.isEnabled(PluginBase.PUMP)) { addPreferencesFromResource(R.xml.pref_virtualpump); } + InsulinOrefFreePeakPlugin insulinOrefFreePeakPlugin = (InsulinOrefFreePeakPlugin) MainApp.getSpecificPlugin(InsulinOrefFreePeakPlugin.class); + if(insulinOrefFreePeakPlugin.isEnabled(PluginBase.INSULIN)){ + addPreferencesFromResource(R.xml.pref_insulinoreffreepeak); + } + NSClientInternalPlugin nsClientInternalPlugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class); if (nsClientInternalPlugin != null && nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) { addPreferencesFromResource(R.xml.pref_nsclientinternal); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakFragment.java new file mode 100644 index 0000000000..5db351fea5 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakFragment.java @@ -0,0 +1,58 @@ +package info.nightscout.androidaps.plugins.InsulinOrefCurves; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.InsulinFastacting.ActivityGraph; + +/** + * Created by adrian on 14/08/17. + */ + +public class InsulinOrefFreePeakFragment extends Fragment { + + static InsulinOrefFreePeakPlugin insulinPlugin = new InsulinOrefFreePeakPlugin(); + + static public InsulinOrefFreePeakPlugin getPlugin() { + return insulinPlugin; + } + + TextView insulinName; + TextView insulinComment; + TextView insulinDia; + ActivityGraph insulinGraph; + + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.insulin_fragment, container, false); + + insulinName = (TextView) view.findViewById(R.id.insulin_name); + insulinComment = (TextView) view.findViewById(R.id.insulin_comment); + insulinDia = (TextView) view.findViewById(R.id.insulin_dia); + insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph); + + updateGUI(); + + return view; + } + + @Override + public void onResume() { + super.onResume(); + updateGUI(); + } + + private void updateGUI() { + insulinName.setText(insulinPlugin.getFriendlyName()); + insulinComment.setText(insulinPlugin.getComment()); + insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinPlugin.getDia()).toString() + "h"); + insulinGraph.show(insulinPlugin); + } + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java new file mode 100644 index 0000000000..9d0c50f06e --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java @@ -0,0 +1,66 @@ +package info.nightscout.androidaps.plugins.InsulinOrefCurves; + +import info.nightscout.androidaps.R; +import info.nightscout.utils.SP; + +/** + * Created by adrian on 14/08/17. + */ + +public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin { + + private static boolean fragmentEnabled = false; + private static boolean fragmentVisible = false; + + public static final int DEFAULT_PEAK = 75; + + @Override + public int getId() { + return OREF_FREE_PEAK; + } + + @Override + public String getName() { + return "Free-Peak Oref"; + } + + @Override + public String getFragmentClass() { + return InsulinOrefFreePeakFragment.class.getName(); + } + + @Override + public String getFriendlyName() { + return "Free-Peak Oref"; + } + + @Override + public String commentStandardText() { + return "Fiasp"; + } + + @Override + public boolean isEnabled(int type) { + return type == INSULIN && fragmentEnabled; + } + + @Override + public boolean isVisibleInTabs(int type) { + return type == INSULIN && fragmentVisible; + } + + @Override + public void setFragmentEnabled(int type, boolean fragmentEnabled) { + if (type == INSULIN) this.fragmentEnabled = fragmentEnabled; + } + + @Override + public void setFragmentVisible(int type, boolean fragmentVisible) { + if (type == INSULIN) this.fragmentVisible = fragmentVisible; + } + + @Override + int getPeak() { + return SP.getInt(R.string.key_insulin_oref_peak, DEFAULT_PEAK); + } +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a422d85ca7..45462ef14f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -689,5 +689,10 @@ PUMP Basal value [U/h] Duration [min] + insulin_oref_peak + IOB Curve Peak + Peak [min] + + diff --git a/app/src/main/res/xml/pref_insulinoreffreepeak.xml b/app/src/main/res/xml/pref_insulinoreffreepeak.xml new file mode 100644 index 0000000000..f8ccf1846e --- /dev/null +++ b/app/src/main/res/xml/pref_insulinoreffreepeak.xml @@ -0,0 +1,21 @@ + + + + + + + + \ No newline at end of file From 13cd7dbda1b95eff71d5ac1690c1cd420ab623b6 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 13:44:53 +0200 Subject: [PATCH 08/27] insulincurves - ActivityGraph fix double plotting --- .../androidaps/plugins/InsulinFastacting/ActivityGraph.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/ActivityGraph.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/ActivityGraph.java index a2181a3a15..5458337782 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/ActivityGraph.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/ActivityGraph.java @@ -21,7 +21,6 @@ import info.nightscout.androidaps.interfaces.InsulinInterface; */ public class ActivityGraph extends GraphView { - Context context; public ActivityGraph(Context context) { @@ -35,6 +34,8 @@ public class ActivityGraph extends GraphView { } public void show(InsulinInterface insulin) { + removeAllSeries(); + mSecondScale = null; double dia = insulin.getDia(); int hours = (int) Math.floor(dia + 1); From ced1da09cf407d43e34508f64378be38616b02c3 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 15:17:07 +0200 Subject: [PATCH 09/27] insulincurves - i18n --- .../plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java | 2 +- .../InsulinOrefCurves/InsulinOrefFreePeakPlugin.java | 7 ++++--- .../InsulinOrefCurves/InsulinOrefRapidActingPlugin.java | 4 ++-- .../InsulinOrefUltraRapidActingPlugin.java | 6 +++--- app/src/main/res/values/strings.xml | 7 +++++++ 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java index 17a28f04c1..e57b068620 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java @@ -83,7 +83,7 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf String comment = commentStandardText(); double userDia = getUserDefinedDia(); if(userDia < MIN_DIA){ - comment += "\n" + String.format("DIA of %s too short - using %s instead!", userDia, MIN_DIA); + comment += "\n" + String.format(MainApp.sResources.getString(R.string.dia_too_short), userDia, MIN_DIA); } return comment; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java index 9d0c50f06e..4a0c7aaeb9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.InsulinOrefCurves; +import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.utils.SP; @@ -21,7 +22,7 @@ public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin { @Override public String getName() { - return "Free-Peak Oref"; + return MainApp.sResources.getString(R.string.free_peak_oref); } @Override @@ -31,12 +32,12 @@ public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin { @Override public String getFriendlyName() { - return "Free-Peak Oref"; + return MainApp.sResources.getString(R.string.free_peak_oref); } @Override public String commentStandardText() { - return "Fiasp"; + return MainApp.sResources.getString(R.string.insulin_peak) + ": " + getPeak(); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java index 0643fd24a0..6f6973bc58 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefRapidActingPlugin.java @@ -21,7 +21,7 @@ public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin { @Override public String getName() { - return "Rapid-Acting Oref"; + return MainApp.sResources.getString(R.string.rapid_acting_oref); } @Override @@ -31,7 +31,7 @@ public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin { @Override public String getFriendlyName() { - return "Rapid-Acting Oref"; + return MainApp.sResources.getString(R.string.rapid_acting_oref); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java index 0e0f34efb4..975707d38b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefUltraRapidActingPlugin.java @@ -21,7 +21,7 @@ public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin { @Override public String getName() { - return "Ultra-Rapid-Acting Oref"; + return MainApp.sResources.getString(R.string.ultrarapid_oref); } @Override @@ -31,12 +31,12 @@ public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin { @Override public String getFriendlyName() { - return "Ultra-Rapid-Acting Oref"; + return MainApp.sResources.getString(R.string.ultrarapid_oref); } @Override public String commentStandardText() { - return "Fiasp"; + return MainApp.sResources.getString(R.string.ultrafastactinginsulincomment); } @Override diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 45462ef14f..3d5810bf62 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -580,6 +580,7 @@ Insulin Fast Acting Insulin Novorapid, Novolog, Humalog + Fiasp INS Fast Acting Insulin Prolonged key_usersuperbolus @@ -692,6 +693,12 @@ insulin_oref_peak IOB Curve Peak Peak [min] + Free-Peak Oref + Rapid-Acting Oref + Ultra-Rapid Oref + "DIA of %s too short - using %s instead!" + + From 94fbd620f4e7e5779ccd64f366e077288f419084 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 15:53:47 +0200 Subject: [PATCH 10/27] insulincurves - remove unused base fragment --- .../InsulinOrefBaseFragment.java | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBaseFragment.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBaseFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBaseFragment.java deleted file mode 100644 index d9cd795792..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBaseFragment.java +++ /dev/null @@ -1,54 +0,0 @@ -package info.nightscout.androidaps.plugins.InsulinOrefCurves; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.InsulinFastacting.ActivityGraph; - -/** - * Created by mike on 17.04.2017. - */ - -public abstract class InsulinOrefBaseFragment extends Fragment { - - static InsulinOrefBasePlugin insulinPlugin = null; - - TextView insulinName; - TextView insulinComment; - TextView insulinDia; - ActivityGraph insulinGraph; - - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.insulin_fragment, container, false); - - insulinName = (TextView) view.findViewById(R.id.insulin_name); - insulinComment = (TextView) view.findViewById(R.id.insulin_comment); - insulinDia = (TextView) view.findViewById(R.id.insulin_dia); - insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph); - - updateGUI(); - - return view; - } - - @Override - public void onResume() { - super.onResume(); - updateGUI(); - } - - private void updateGUI() { - insulinName.setText(insulinPlugin.getFriendlyName()); - insulinComment.setText(insulinPlugin.getComment()); - insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinPlugin.getDia()).toString() + "h"); - insulinGraph.show(insulinPlugin); - } - -} From 707d5a480c88fdd40b75435fc6c05e75bc1eabc1 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 16:02:07 +0200 Subject: [PATCH 11/27] insulincurves - rename peak to peak time --- app/src/main/res/values/strings.xml | 4 ++-- app/src/main/res/xml/pref_insulinoreffreepeak.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3d5810bf62..864c38bfce 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -691,8 +691,8 @@ Basal value [U/h] Duration [min] insulin_oref_peak - IOB Curve Peak - Peak [min] + IOB Curve Peak Time + Peak Time [min] Free-Peak Oref Rapid-Acting Oref Ultra-Rapid Oref diff --git a/app/src/main/res/xml/pref_insulinoreffreepeak.xml b/app/src/main/res/xml/pref_insulinoreffreepeak.xml index f8ccf1846e..726d0595e2 100644 --- a/app/src/main/res/xml/pref_insulinoreffreepeak.xml +++ b/app/src/main/res/xml/pref_insulinoreffreepeak.xml @@ -14,7 +14,7 @@ android:selectAllOnFocus="true" android:inputType="number" android:maxLines="20" - android:title="@string/insulin_peak" + android:title="@string/insulin_peak_time" android:key="@string/key_insulin_oref_peak" /> From f23c3e7ae1e7467fcf47d77ffbc335d82b613308 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 16:44:39 +0200 Subject: [PATCH 12/27] insulincurves - forgotten string updated --- .../plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java index 4a0c7aaeb9..747eabda5b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefFreePeakPlugin.java @@ -37,7 +37,7 @@ public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin { @Override public String commentStandardText() { - return MainApp.sResources.getString(R.string.insulin_peak) + ": " + getPeak(); + return MainApp.sResources.getString(R.string.insulin_peak_time) + ": " + getPeak(); } @Override From ee7b3cca22f701cf70d7cf80116ec3aa0d0ab7d7 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 14 Aug 2017 20:41:24 +0200 Subject: [PATCH 13/27] insulincurves - notification on short DIA --- .../InsulinOrefCurves/InsulinOrefBasePlugin.java | 15 ++++++++++++++- .../androidaps/plugins/Overview/Notification.java | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java index e57b068620..10dfd5dce5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java @@ -7,6 +7,8 @@ import info.nightscout.androidaps.data.Iob; import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.PluginBase; +import info.nightscout.androidaps.plugins.Overview.Notification; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; /** * Created by adrian on 13.08.2017. @@ -16,6 +18,8 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf public static double MIN_DIA = 5; + long lastWarned = 0; + @Override public int getType() { return INSULIN; @@ -44,7 +48,16 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf @Override public double getDia() { double dia = getUserDefinedDia(); - return Math.max(MIN_DIA, dia); + if(dia >= MIN_DIA){ + return dia; + } else { + if((System.currentTimeMillis() - lastWarned) > 60*1000) { + lastWarned = System.currentTimeMillis(); + Notification notification = new Notification(Notification.SHORT_DIA, String.format(MainApp.sResources.getString(R.string.dia_too_short), dia, MIN_DIA), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + } + return MIN_DIA; + } } public double getUserDefinedDia() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java index 9f35599b36..d3db3c2902 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java @@ -47,6 +47,8 @@ public class Notification { public static final int NSANNOUNCEMENT = 18; public static final int NSALARM = 19; public static final int NSURGENTALARM = 20; + public static final int SHORT_DIA = 21; + public int id; public Date date; From 151165809e642db880ebcbb57f1b240d64bbbd23 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 14 Aug 2017 21:57:49 +0200 Subject: [PATCH 14/27] Dutch language --- app/src/main/res/values-nl/strings.xml | 4 ++++ app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values/arrays.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 8 insertions(+) create mode 100644 app/src/main/res/values-nl/strings.xml diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml new file mode 100644 index 0000000000..c93f92ba38 --- /dev/null +++ b/app/src/main/res/values-nl/strings.xml @@ -0,0 +1,4 @@ + + + AndroidAPS + \ No newline at end of file diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 5b00248db8..91d1dec374 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -581,4 +581,5 @@ Delta: IOB: %dmin sedan + AndroidAPS \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 48db77c158..a564b68e80 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -15,6 +15,7 @@ @string/bg_lang @string/cs_lang @string/de_lang + @string/nl_lang @string/es_lang @string/el_lang @string/it_lang @@ -27,6 +28,7 @@ bg cs de + nl es el it diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a422d85ca7..efe849acbd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -203,6 +203,7 @@ File not found Export settings Import settings + Dutch German Spanish Greek From 6dcdeb2bbc0f67fd3903400573bfd6a09202bd0d Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 15 Aug 2017 14:49:12 +0200 Subject: [PATCH 15/27] Overview: format target using unit specific format. --- .../androidaps/plugins/Overview/OverviewFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index ff6218786e..79d00c9687 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -962,9 +962,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, double low = MainApp.getConfigBuilder().getProfile().getTargetLow(); double high = MainApp.getConfigBuilder().getProfile().getTargetHigh(); if (low == high) - tempTargetView.setText("" + low); + tempTargetView.setText(Profile.toUnitsString(low, Profile.fromMgdlToUnits(low, units), units)); else - tempTargetView.setText(low + " - " + high); + tempTargetView.setText(Profile.toUnitsString(low, Profile.fromMgdlToUnits(low, units), units) + " - " + Profile.toUnitsString(high, Profile.fromMgdlToUnits(high, units), units)); tempTargetView.setVisibility(View.VISIBLE); } if (Config.NSCLIENT && tempTarget == null) { From 754a0097b9fcb32802f15515fff537b9247d76dc Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 15 Aug 2017 15:45:24 +0200 Subject: [PATCH 16/27] Simplify. --- .../androidaps/plugins/Overview/OverviewFragment.java | 8 ++++---- .../androidaps/plugins/Wear/ActionStringHandler.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 79d00c9687..0e6b089744 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -953,18 +953,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground)); tempTargetView.setVisibility(View.VISIBLE); if (tempTarget.low == tempTarget.high) - tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units)); + tempTargetView.setText(Profile.toUnitsString(tempTarget.low, tempTarget.low, units)); else - tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, units), units)); + tempTargetView.setText(Profile.toUnitsString(tempTarget.low, tempTarget.low, units) + " - " + Profile.toUnitsString(tempTarget.high, tempTarget.high, units)); } else { tempTargetView.setTextColor(Color.WHITE); tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground)); double low = MainApp.getConfigBuilder().getProfile().getTargetLow(); double high = MainApp.getConfigBuilder().getProfile().getTargetHigh(); if (low == high) - tempTargetView.setText(Profile.toUnitsString(low, Profile.fromMgdlToUnits(low, units), units)); + tempTargetView.setText(Profile.toUnitsString(low, low, units)); else - tempTargetView.setText(Profile.toUnitsString(low, Profile.fromMgdlToUnits(low, units), units) + " - " + Profile.toUnitsString(high, Profile.fromMgdlToUnits(high, units), units)); + tempTargetView.setText(Profile.toUnitsString(low, low, units) + " - " + Profile.toUnitsString(high, high, units)); tempTargetView.setVisibility(View.VISIBLE); } if (Config.NSCLIENT && tempTarget == null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index 2db941e1c5..aead0fe0eb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -472,7 +472,7 @@ public class ActionStringHandler { //Check for Temp-Target: TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis()); if (tempTarget != null) { - ret += "Temp Target: " + Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits()); + ret += "Temp Target: " + Profile.toUnitsString(tempTarget.low, tempTarget.low, profile.getUnits()) + " - " + Profile.toUnitsString(tempTarget.high, tempTarget.high, profile.getUnits()); ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd()); ret += "\n\n"; } From 759afcec7ab10fba091d9dd614594c42e23434ab Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 15 Aug 2017 16:04:46 +0200 Subject: [PATCH 17/27] Extract method Profile.toTargetRangeString. --- .../info/nightscout/androidaps/data/Profile.java | 5 +++++ .../plugins/Overview/OverviewFragment.java | 12 ++---------- .../androidaps/plugins/Wear/ActionStringHandler.java | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/Profile.java b/app/src/main/java/info/nightscout/androidaps/data/Profile.java index dc49d95455..48081c956c 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/app/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -391,4 +391,9 @@ public class Profile { if (units.equals(Constants.MGDL)) return DecimalFormatter.to0Decimal(valueInMgdl); else return DecimalFormatter.to1Decimal(valueInMmol); } + + public static String toTargetRangeString(double low, double high, String units) { + if (low == high) return toUnitsString(low, low, units); + else return toUnitsString(low, low, units) + " - " + toUnitsString(high, high, units); + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 0e6b089744..c9719427c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -952,19 +952,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, tempTargetView.setTextColor(Color.BLACK); tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground)); tempTargetView.setVisibility(View.VISIBLE); - if (tempTarget.low == tempTarget.high) - tempTargetView.setText(Profile.toUnitsString(tempTarget.low, tempTarget.low, units)); - else - tempTargetView.setText(Profile.toUnitsString(tempTarget.low, tempTarget.low, units) + " - " + Profile.toUnitsString(tempTarget.high, tempTarget.high, units)); + tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, units)); } else { tempTargetView.setTextColor(Color.WHITE); tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground)); - double low = MainApp.getConfigBuilder().getProfile().getTargetLow(); - double high = MainApp.getConfigBuilder().getProfile().getTargetHigh(); - if (low == high) - tempTargetView.setText(Profile.toUnitsString(low, low, units)); - else - tempTargetView.setText(Profile.toUnitsString(low, low, units) + " - " + Profile.toUnitsString(high, high, units)); + tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units)); tempTargetView.setVisibility(View.VISIBLE); } if (Config.NSCLIENT && tempTarget == null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index aead0fe0eb..cbff033fb6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -472,7 +472,7 @@ public class ActionStringHandler { //Check for Temp-Target: TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis()); if (tempTarget != null) { - ret += "Temp Target: " + Profile.toUnitsString(tempTarget.low, tempTarget.low, profile.getUnits()) + " - " + Profile.toUnitsString(tempTarget.high, tempTarget.high, profile.getUnits()); + ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, profile.getUnits()); ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd()); ret += "\n\n"; } From 2e382267d4e4d334906940b56fa46be94db71fe3 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 15 Aug 2017 22:38:48 +0200 Subject: [PATCH 18/27] Overlappinginterfals - find first element --- .../info/nightscout/androidaps/data/OverlappingIntervals.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/OverlappingIntervals.java b/app/src/main/java/info/nightscout/androidaps/data/OverlappingIntervals.java index 608fa8d328..36b06bb7e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/OverlappingIntervals.java +++ b/app/src/main/java/info/nightscout/androidaps/data/OverlappingIntervals.java @@ -31,7 +31,7 @@ public class OverlappingIntervals extends Intervals { @Nullable public synchronized T getValueByInterval(long time) { - for (int index = rawData.size()-1; index > 0; index--) { //begin with newest + for (int index = rawData.size()-1; index >= 0; index--) { //begin with newest T cur = rawData.valueAt(index); if (cur.match(time)){ return cur; From 5fc63d8f166d577508601ae04ef2ad2a24ebdbbc Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 16 Aug 2017 14:17:28 +0200 Subject: [PATCH 19/27] restrict DIA for expectedDelta --- .../plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java | 2 +- .../androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java index 6e1070eac3..66696ac9b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java @@ -208,7 +208,7 @@ public class DetermineBasalAdapterAMAJS { mProfile = new V8Object(mV8rt); mProfile.add("max_iob", maxIob); - mProfile.add("dia", profile.getDia()); + mProfile.add("dia", Math.min(profile.getDia(), 3d)); mProfile.add("type", "current"); mProfile.add("max_daily_basal", profile.getMaxDailyBasal()); mProfile.add("max_basal", maxBasal); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java index 7df122fc92..dc4d2ee70d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java @@ -231,7 +231,7 @@ public class DetermineBasalAdapterMAJS { String units = profile.getUnits(); mProfile.add("max_iob", maxIob); - mProfile.add("dia", profile.getDia()); + mProfile.add("dia", Math.min(profile.getDia(), 3d)); mProfile.add("type", "current"); mProfile.add("max_daily_basal", profile.getMaxDailyBasal()); mProfile.add("max_basal", maxBasal); From e005a6172bbdfa9962faeeab392219ed5eb37f46 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 16 Aug 2017 17:26:58 +0200 Subject: [PATCH 20/27] set pump time only if needed --- .../androidaps/plugins/PumpDanaR/comm/MsgSetTime.java | 4 +++- .../plugins/PumpDanaR/comm/MsgSettingPumpTime.java | 2 +- .../PumpDanaR/services/DanaRExecutionService.java | 11 +++++++++-- .../services/DanaRKoreanExecutionService.java | 10 ++++++++-- .../PumpDanaRv2/services/DanaRv2ExecutionService.java | 11 +++++++++-- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java index aa15a02709..3910d52c97 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java @@ -13,9 +13,11 @@ import info.nightscout.androidaps.Config; public class MsgSetTime extends MessageBase { private static Logger log = LoggerFactory.getLogger(MsgSetTime.class); + private static Date time; public MsgSetTime(Date time) { SetCommand(0x330a); + this.time = time; AddParamDateTime(time); } @@ -23,6 +25,6 @@ public class MsgSetTime extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (Config.logDanaMessageDetail) - log.debug("Result: " + result); + log.debug("Result of setting time: " + time + " is " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingPumpTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingPumpTime.java index 23f0e4560f..3da1451899 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingPumpTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingPumpTime.java @@ -27,7 +27,7 @@ public class MsgSettingPumpTime extends MessageBase { ); if (Config.logDanaMessageDetail) - log.debug("Pump time: " + time); + log.debug("Pump time: " + time + " Phone time: " + new Date()); DanaRPump.getInstance().pumpTime = time; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java index e4e32e39c3..a1d8ecff87 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java @@ -326,11 +326,18 @@ public class DanaRExecutionService extends Service { //0x3201 mSerialIOThread.sendMessage(new MsgSettingMaxValues()); mSerialIOThread.sendMessage(new MsgSettingGlucose()); - mSerialIOThread.sendMessage(new MsgSettingPumpTime()); mSerialIOThread.sendMessage(new MsgSettingActiveProfile()); mSerialIOThread.sendMessage(new MsgSettingProfileRatios()); mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll()); - mSerialIOThread.sendMessage(new MsgSetTime(new Date())); + mSerialIOThread.sendMessage(new MsgSettingPumpTime()); + long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; + log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Math.abs(timeDiff) > 10) { + mSerialIOThread.sendMessage(new MsgSetTime(new Date())); + mSerialIOThread.sendMessage(new MsgSettingPumpTime()); + timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; + log.debug("Pump time difference: " + timeDiff + " seconds"); + } danaRPump.lastSettingsRead = now; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java index d803c17bda..f7ad5976b5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java @@ -322,9 +322,15 @@ public class DanaRKoreanExecutionService extends Service { //0x3201 mSerialIOThread.sendMessage(new MsgSettingMaxValues()); mSerialIOThread.sendMessage(new MsgSettingGlucose()); - mSerialIOThread.sendMessage(new MsgSettingPumpTime()); mSerialIOThread.sendMessage(new MsgSettingProfileRatios()); - mSerialIOThread.sendMessage(new MsgSetTime(new Date())); + long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; + log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Math.abs(timeDiff) > 10) { + mSerialIOThread.sendMessage(new MsgSetTime(new Date())); + mSerialIOThread.sendMessage(new MsgSettingPumpTime()); + timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; + log.debug("Pump time difference: " + timeDiff + " seconds"); + } danaRPump.lastSettingsRead = now; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java index 6527eeebaf..98d869e09c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java @@ -297,11 +297,18 @@ public class DanaRv2ExecutionService extends Service { //0x3201 mSerialIOThread.sendMessage(new MsgSettingMaxValues()); mSerialIOThread.sendMessage(new MsgSettingGlucose()); - mSerialIOThread.sendMessage(new MsgSettingPumpTime()); mSerialIOThread.sendMessage(new MsgSettingActiveProfile()); mSerialIOThread.sendMessage(new MsgSettingProfileRatios()); mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll()); - mSerialIOThread.sendMessage(new MsgSetTime(new Date())); + mSerialIOThread.sendMessage(new MsgSettingPumpTime()); + long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; + log.debug("Pump time difference: " + timeDiff + " seconds"); + if (Math.abs(timeDiff) > 10) { + mSerialIOThread.sendMessage(new MsgSetTime(new Date())); + mSerialIOThread.sendMessage(new MsgSettingPumpTime()); + timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; + log.debug("Pump time difference: " + timeDiff + " seconds"); + } danaRPump.lastSettingsRead = now; } From 63793ed358a550db2eeb751e905f78c8adf46a3a Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 16 Aug 2017 17:56:57 +0200 Subject: [PATCH 21/27] Show profile switch button in profiles Shows the button to trigger a profile switch button in the profile fragments even when the pump basal cannot be written. Instead of "SEND TO PUMP" it will then show "ACTIVATE PROFILE". This has become necessary with the interval logic that needs profile switch events to happen in order to accept a new profile. --- .../CircadianPercentageProfileFragment.java | 6 +++++- .../plugins/ProfileLocal/LocalProfileFragment.java | 6 +++++- .../plugins/ProfileSimple/SimpleProfileFragment.java | 6 +++++- app/src/main/res/values/strings.xml | 3 +-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfileFragment.java index c42f1d0c64..c7d7333aba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfileFragment.java @@ -500,9 +500,13 @@ public class CircadianPercentageProfileFragment extends SubscriberFragment { activity.runOnUiThread(new Runnable() { @Override public void run() { - if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) { + if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) { profileswitchButton.setVisibility(View.GONE); + } else if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) { + profileswitchButton.setText(MainApp.instance().getText(R.string.activate_profile)); + profileswitchButton.setVisibility(View.VISIBLE); } else { + profileswitchButton.setText(MainApp.instance().getText(R.string.send_to_pump)); profileswitchButton.setVisibility(View.VISIBLE); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java index 7161a1d9de..e491a41b1b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java @@ -148,9 +148,13 @@ public class LocalProfileFragment extends SubscriberFragment { activity.runOnUiThread(new Runnable() { @Override public void run() { - if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) { + if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) { profileswitchButton.setVisibility(View.GONE); + } else if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) { + profileswitchButton.setText(MainApp.instance().getText(R.string.activate_profile)); + profileswitchButton.setVisibility(View.VISIBLE); } else { + profileswitchButton.setText(MainApp.instance().getText(R.string.send_to_pump)); profileswitchButton.setVisibility(View.VISIBLE); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java index a4e3a8eecf..5cf36409b6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java @@ -156,9 +156,13 @@ public class SimpleProfileFragment extends SubscriberFragment { activity.runOnUiThread(new Runnable() { @Override public void run() { - if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) { + if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) { profileswitchButton.setVisibility(View.GONE); + } else if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable) { + profileswitchButton.setText(MainApp.instance().getText(R.string.activate_profile)); + profileswitchButton.setVisibility(View.VISIBLE); } else { + profileswitchButton.setText(MainApp.instance().getText(R.string.send_to_pump)); profileswitchButton.setVisibility(View.VISIBLE); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 08d0008156..05cf2a6285 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -698,8 +698,7 @@ Rapid-Acting Oref Ultra-Rapid Oref "DIA of %s too short - using %s instead!" - - + ACTIVATE PROFILE From 7884c98f2f33eb5daf9807a2d2d08864e7cad29b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 16 Aug 2017 18:26:47 +0200 Subject: [PATCH 22/27] fix index --- .../plugins/ConfigBuilder/DetailedBolusInfoStorage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java index c717d62edb..e99c5a8f22 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java @@ -28,7 +28,7 @@ public class DetailedBolusInfoStorage { public static DetailedBolusInfo findDetailedBolusInfo(long bolustime) { DetailedBolusInfo found = null; for (int i = 0; i < store.size(); i++) { - long infoTime = store.get(0).date; + long infoTime = store.get(i).date; log.debug("Existing info: " + new Date(infoTime).toLocaleString()); if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { found = store.get(i); From b93a153b2397bb676d54fc19e9883e951a38d56b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 16 Aug 2017 19:33:41 +0200 Subject: [PATCH 23/27] parse 12h format properly --- app/src/main/java/info/nightscout/utils/DateUtil.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/utils/DateUtil.java b/app/src/main/java/info/nightscout/utils/DateUtil.java index b058450512..bf2c1ba1fd 100644 --- a/app/src/main/java/info/nightscout/utils/DateUtil.java +++ b/app/src/main/java/info/nightscout/utils/DateUtil.java @@ -85,12 +85,16 @@ public class DateUtil { } public static int toSeconds(String hh_colon_mm) { - Pattern p = Pattern.compile("(\\d+):(\\d+)"); + Pattern p = Pattern.compile("(\\d+):(\\d+)( a.m.| p.m.|)"); Matcher m = p.matcher(hh_colon_mm); int retval = 0; if (m.find()) { retval = SafeParse.stringToInt(m.group(1)) * 60 * 60 + SafeParse.stringToInt(m.group(2)) * 60; + if (m.group(3).equals(" .a.m") && m.group(1).equals("12")) + retval -= 12 * 60 * 60; + if (m.group(3).equals(" p.m.") && !m.group(1).equals("12")) + retval += 12 * 60 * 60; } return retval; } From e61d7a44425007923d86169474566e284f1a34ca Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 16 Aug 2017 21:37:33 +0200 Subject: [PATCH 24/27] show notification on toast alarm --- .../androidaps/plugins/Overview/Notification.java | 1 + .../main/java/info/nightscout/utils/ToastUtils.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java index d3db3c2902..13b85e08fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java @@ -48,6 +48,7 @@ public class Notification { public static final int NSALARM = 19; public static final int NSURGENTALARM = 20; public static final int SHORT_DIA = 21; + public static final int TOAST_ALARM = 22; public int id; diff --git a/app/src/main/java/info/nightscout/utils/ToastUtils.java b/app/src/main/java/info/nightscout/utils/ToastUtils.java index dba4fb4202..4e1e4ac4ed 100644 --- a/app/src/main/java/info/nightscout/utils/ToastUtils.java +++ b/app/src/main/java/info/nightscout/utils/ToastUtils.java @@ -6,6 +6,10 @@ import android.os.Handler; import android.os.Looper; import android.widget.Toast; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.plugins.Overview.Notification; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; + public class ToastUtils { public static void showToastInUiThread(final Context ctx, @@ -25,6 +29,13 @@ public class ToastUtils { showToastInUiThread(ctx, string); playSound(ctx, soundID); + new Thread(new Runnable() { + @Override + public void run() { + Notification notification = new Notification(Notification.TOAST_ALARM, string, Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + } + }).start(); } private static void playSound(final Context ctx, final int soundID) { From 8287fe22cf107f60d9133310211345d9f8253fa7 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 16 Aug 2017 23:22:14 +0200 Subject: [PATCH 25/27] AcceptTempButton visible --- app/src/main/res/layout/overview_fragment.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 9468ce5bf2..413350d6eb 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -375,7 +375,8 @@ android:id="@+id/overview_accepttemplayout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal"> + android:orientation="horizontal" + android:visibility="gone">