diff --git a/app/build.gradle b/app/build.gradle
index 0d9ffed984..9bda1ceddc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -48,9 +48,15 @@ android {
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", generateGitBuild()
}
+
+ dexOptions {
+ jumboMode true
+ }
+
lintOptions {
disable 'MissingTranslation'
}
+
buildTypes {
release {
minifyEnabled false
diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java
index 1678b42405..358c4e4d38 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainApp.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java
@@ -22,6 +22,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
+import info.nightscout.androidaps.plugins.InsulinFastactingProlonged.InsulinFastactingProlongedFragment;
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
@@ -88,6 +89,7 @@ public class MainApp extends Application {
pluginsList.add(OverviewFragment.getPlugin());
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
pluginsList.add(InsulinFastactingFragment.getPlugin());
+ pluginsList.add(InsulinFastactingProlongedFragment.getPlugin());
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
if (Config.DANARKOREAN) pluginsList.add(DanaRKoreanFragment.getPlugin());
pluginsList.add(CareportalFragment.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 05261e2916..81359b4329 100644
--- a/app/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java
+++ b/app/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java
@@ -11,6 +11,7 @@ import info.nightscout.androidaps.db.Treatment;
public interface InsulinInterface {
final int FASTACTINGINSULIN = 0;
+ final int FASTACTINGINSULINPROLONGED = 1;
int getId();
String getFriendlyName();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/InsulinFastactingFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/InsulinFastactingFragment.java
index bff8436861..df29240c55 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/InsulinFastactingFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastacting/InsulinFastactingFragment.java
@@ -1,7 +1,18 @@
package info.nightscout.androidaps.plugins.InsulinFastacting;
+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.ImageView;
+import android.widget.TextView;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.Unbinder;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
/**
@@ -15,5 +26,32 @@ public class InsulinFastactingFragment extends Fragment implements FragmentBase
return insulinFastactingPlugin;
}
+ private Unbinder unbinder;
+ @BindView(R.id.insulin_name)
+ TextView insulinName;
+ @BindView(R.id.insulin_comment)
+ TextView insulinComment;
+ @BindView(R.id.insulin_activity)
+ ImageView insulinActivity;
+
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.insulin_fragment, container, false);
+
+ unbinder = ButterKnife.bind(this, view);
+
+ insulinName.setText(insulinFastactingPlugin.getFriendlyName());
+ insulinComment.setText(insulinFastactingPlugin.getComment());
+ insulinActivity.setImageDrawable(MainApp.sResources.getDrawable(insulinFastactingPlugin.getResourcePicture()));
+
+ return view;
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ unbinder.unbind();
+ }
+
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastactingProlonged/InsulinFastactingProlongedFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastactingProlonged/InsulinFastactingProlongedFragment.java
new file mode 100644
index 0000000000..648c47a41b
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastactingProlonged/InsulinFastactingProlongedFragment.java
@@ -0,0 +1,57 @@
+package info.nightscout.androidaps.plugins.InsulinFastactingProlonged;
+
+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.ImageView;
+import android.widget.TextView;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.Unbinder;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.interfaces.FragmentBase;
+
+/**
+ * Created by mike on 17.04.2017.
+ */
+
+public class InsulinFastactingProlongedFragment extends Fragment implements FragmentBase {
+ static InsulinFastactingProlongedPlugin insulinFastactingProlongedPlugin = new InsulinFastactingProlongedPlugin();
+
+ static public InsulinFastactingProlongedPlugin getPlugin() {
+ return insulinFastactingProlongedPlugin;
+ }
+
+ private Unbinder unbinder;
+ @BindView(R.id.insulin_name)
+ TextView insulinName;
+ @BindView(R.id.insulin_comment)
+ TextView insulinComment;
+ @BindView(R.id.insulin_activity)
+ ImageView insulinActivity;
+
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.insulin_fragment, container, false);
+
+ unbinder = ButterKnife.bind(this, view);
+
+ insulinName.setText(insulinFastactingProlongedPlugin.getFriendlyName());
+ insulinComment.setText(insulinFastactingProlongedPlugin.getComment());
+ insulinActivity.setImageDrawable(MainApp.sResources.getDrawable(insulinFastactingProlongedPlugin.getResourcePicture()));
+
+ return view;
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ unbinder.unbind();
+ }
+
+
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastactingProlonged/InsulinFastactingProlongedPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastactingProlonged/InsulinFastactingProlongedPlugin.java
new file mode 100644
index 0000000000..0eeb01f199
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinFastactingProlonged/InsulinFastactingProlongedPlugin.java
@@ -0,0 +1,129 @@
+package info.nightscout.androidaps.plugins.InsulinFastactingProlonged;
+
+import java.util.Date;
+
+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;
+import info.nightscout.androidaps.interfaces.ProfileInterface;
+
+/**
+ * Created by mike on 17.04.2017.
+ */
+
+public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInterface {
+
+ private static boolean fragmentEnabled = true;
+ private static boolean fragmentVisible = false;
+
+ @Override
+ public int getType() {
+ return INSULIN;
+ }
+
+ @Override
+ public String getFragmentClass() {
+ return InsulinFastactingProlongedFragment.class.getName();
+ }
+
+ @Override
+ public String getName() {
+ return MainApp.sResources.getString(R.string.fastactinginsulinprolonged);
+ }
+
+ @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 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 MainApp.sResources.getString(R.string.fastactinginsulinprolonged);
+ }
+
+ @Override
+ public String getComment() {
+ return MainApp.sResources.getString(R.string.fastactinginsulincomment);
+ }
+
+ @Override
+ public int getResourcePicture() {
+ return R.drawable.insulin1;
+ }
+
+ @Override
+ public double getDia() {
+ ProfileInterface profileInterface = MainApp.getConfigBuilder().getActiveProfile();
+ if (profileInterface.getProfile() != null)
+ return profileInterface.getProfile().getDia();
+ return Constants.defaultDIA;
+ }
+
+ @Override
+ public Iob iobCalc(Treatment treatment, Date time, Double dia) {
+ Iob result = new Iob();
+
+ //Double scaleFactor = 3.0 / dia;
+ Double peak = 75d * dia / 6.0;
+ Double tail = 180d * dia / 6.0;
+ Double end = 360d * dia / 6.0;
+ Double Total = 2 * peak + (tail - peak) * 5 / 2 + (end - tail) / 2;
+
+ if (treatment.insulin != 0d) {
+ Long bolusTime = treatment.created_at.getTime();
+ Double minAgo = (time.getTime() - bolusTime) / 1000d / 60d;
+
+ if (minAgo < peak) {
+ Double x1 = 6 / dia * minAgo / 5d + 1;
+ result.iobContrib = treatment.insulin * (1 - 0.0012595 * x1 * x1 + 0.0012595 * x1);
+ // units: BG (mg/dL) = (BG/U) * U insulin * scalar
+ result.activityContrib = treatment.insulin * ((2 * peak / Total) * 2 / peak / peak * minAgo);
+ } else if (minAgo < tail) {
+ Double x2 = (6 / dia * (minAgo - peak)) / 5;
+ result.iobContrib = treatment.insulin * (0.00074 * x2 * x2 - 0.0403 * x2 + 0.69772);
+ result.activityContrib = treatment.insulin * (-((2 * peak / Total) * 2 / peak * 3 / 4) / (tail - peak) * (minAgo - peak) + (2 * peak / Total) * 2 / peak);
+ } else if (minAgo < end) {
+ Double x3 = (6 / dia * (minAgo - tail)) / 5;
+ result.iobContrib = treatment.insulin * (0.0001323 * x3 * x3 - 0.0097 * x3 + 0.17776);
+ result.activityContrib = treatment.insulin * (-((2 * peak / Total) * 2 / peak * 1 / 4) / (end - tail) * (minAgo - tail) + (2 * peak / Total) * 2 / peak / 4);
+ }
+
+ }
+ return result;
+ }
+}
diff --git a/app/src/main/res/drawable/insulin1.png b/app/src/main/res/drawable/insulin1.png
new file mode 100644
index 0000000000..36cc3af463
Binary files /dev/null and b/app/src/main/res/drawable/insulin1.png differ
diff --git a/app/src/main/res/layout/insulin_fragment.xml b/app/src/main/res/layout/insulin_fragment.xml
new file mode 100644
index 0000000000..86fccb49c3
--- /dev/null
+++ b/app/src/main/res/layout/insulin_fragment.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 30046ec0c0..cee9303d4d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -588,4 +588,5 @@
Fast Acting Insulin
Novorapid, Novolog, Humalog
INS
+ Fast Acting Insuin Prolonged