diff --git a/.idea/misc.xml b/.idea/misc.xml
index fbb68289f4..5d19981032 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -37,7 +37,7 @@
-
+
diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java
index 665ca1f253..6c92f385da 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainApp.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java
@@ -16,6 +16,7 @@ import java.util.ArrayList;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.interfaces.PluginBase;
+import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
@@ -62,6 +63,7 @@ public class MainApp extends Application {
pluginsList = new ArrayList<>();
// Register all tabs in app here
pluginsList.add(OverviewFragment.getPlugin());
+ pluginsList.add(ActionsFragment.getPlugin());
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
if (Config.MM640G) pluginsList.add(MM640gFragment.getPlugin());
if (Config.CAREPORTALENABLED) pluginsList.add(CareportalFragment.getPlugin());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java
new file mode 100644
index 0000000000..245d189660
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java
@@ -0,0 +1,65 @@
+package info.nightscout.androidaps.plugins.Actions;
+
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.interfaces.FragmentBase;
+import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
+import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
+import info.nightscout.androidaps.plugins.Actions.dialogs.NewExtendedBolusDialog;
+import info.nightscout.androidaps.plugins.Actions.dialogs.NewTempBasalDialog;
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class ActionsFragment extends Fragment implements FragmentBase, View.OnClickListener {
+
+ static ActionsPlugin actionsPlugin = new ActionsPlugin();
+ static public ActionsPlugin getPlugin() {
+ return actionsPlugin;
+ }
+
+ public ActionsFragment() {
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.actions_fragment, container, false);
+
+ view.findViewById(R.id.actions_profileswitch).setOnClickListener(this);
+ view.findViewById(R.id.actions_extendedbolus).setOnClickListener(this);
+ view.findViewById(R.id.actions_settempbasal).setOnClickListener(this);
+
+ return view;
+ }
+
+ @Override
+ public void onClick(View view) {
+ FragmentManager manager = getFragmentManager();
+ switch (view.getId()) {
+ case R.id.actions_profileswitch:
+ NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
+ final OptionsToShow profileswitch = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch, true, false, false, false, false, false, false, true, false);
+ profileswitch.executeProfileSwitch = true;
+ newDialog.setOptions(profileswitch);
+ newDialog.show(manager, "NewNSTreatmentDialog");
+ break;
+ case R.id.actions_extendedbolus:
+ NewExtendedBolusDialog newExtendedDialog = new NewExtendedBolusDialog();
+ newExtendedDialog.show(manager, "NewExtendedDialog");
+ break;
+ case R.id.actions_settempbasal:
+ NewTempBasalDialog newTempDialog = new NewTempBasalDialog();
+ newTempDialog.show(manager, "NewTempDialog");
+ break;
+ }
+ }
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java
new file mode 100644
index 0000000000..d591f67556
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsPlugin.java
@@ -0,0 +1,56 @@
+package info.nightscout.androidaps.plugins.Actions;
+
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.interfaces.PluginBase;
+
+/**
+ * Created by mike on 05.11.2016.
+ */
+
+public class ActionsPlugin implements PluginBase {
+
+ boolean fragmentEnabled = true;
+ boolean fragmentVisible = true;
+
+ @Override
+ public int getType() {
+ return PluginBase.GENERAL;
+ }
+
+ @Override
+ public String getFragmentClass() {
+ return ActionsFragment.class.getName();
+ }
+
+ @Override
+ public String getName() {
+ return MainApp.sResources.getString(R.string.actions);
+ }
+
+ @Override
+ public boolean isEnabled(int type) {
+ return fragmentEnabled;
+ }
+
+ @Override
+ public boolean isVisibleInTabs(int type) {
+ return fragmentVisible;
+ }
+
+ @Override
+ public boolean canBeHidden(int type) {
+ return true;
+ }
+
+ @Override
+ public void setFragmentEnabled(int type, boolean fragmentEnabled) {
+ this.fragmentEnabled = fragmentEnabled;
+ }
+
+ @Override
+ public void setFragmentVisible(int type, boolean fragmentVisible) {
+ this.fragmentVisible = fragmentVisible;
+ }
+
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewExtendedBolusDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java
similarity index 99%
rename from app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewExtendedBolusDialog.java
rename to app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java
index 8ca775e25f..56ffa69d5f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewExtendedBolusDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java
@@ -1,4 +1,4 @@
-package info.nightscout.androidaps.plugins.Overview.Dialogs;
+package info.nightscout.androidaps.plugins.Actions.dialogs;
import android.content.Context;
import android.content.DialogInterface;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTempBasalDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java
similarity index 97%
rename from app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTempBasalDialog.java
rename to app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java
index 3b27f869d7..f95bdc41b4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTempBasalDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java
@@ -1,4 +1,4 @@
-package info.nightscout.androidaps.plugins.Overview.Dialogs;
+package info.nightscout.androidaps.plugins.Actions.dialogs;
import android.content.Context;
import android.content.DialogInterface;
@@ -151,9 +151,9 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
}
if (!result.success) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
+ builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
builder.setMessage(result.comment);
- builder.setPositiveButton(getContext().getString(R.string.ok), null);
+ builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
builder.show();
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java
index d308363b03..047dd3e7c5 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java
@@ -22,44 +22,6 @@ public class CareportalFragment extends Fragment implements FragmentBase, View.O
return careportalPlugin;
}
- public class OptionsToShow {
- public int eventType;
- public int eventName;
- public boolean bg;
- public boolean insulin;
- public boolean carbs;
- public boolean prebolus;
- public boolean duration;
- public boolean percent;
- public boolean absolute;
- public boolean profile;
- public boolean split;
-
- public OptionsToShow(int eventType,
- int eventName,
- boolean bg,
- boolean insulin,
- boolean carbs,
- boolean prebolus,
- boolean duration,
- boolean percent,
- boolean absolute,
- boolean profile,
- boolean split) {
- this.eventType = eventType;
- this.eventName = eventName;
- this.bg = bg;
- this.insulin = insulin;
- this.carbs = carbs;
- this.prebolus = prebolus;
- this.duration = duration;
- this.percent = percent;
- this.absolute = absolute;
- this.profile = profile;
- this.split = split;
- }
- }
-
// bg,insulin,carbs,prebolus,duration,percent,absolute,profile,split
final OptionsToShow bgcheck = new OptionsToShow(R.id.careportal_bgcheck, R.string.careportal_bgcheck, true, true, true, false, false, false, false, false, false);
final OptionsToShow snackbolus = new OptionsToShow(R.id.careportal_snackbolus, R.string.careportal_snackbolus, true, true, true, true, false, false, false, false, false);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java
index dac8968b64..1011caf40a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java
@@ -2,11 +2,11 @@ package info.nightscout.androidaps.plugins.Careportal.Dialogs;
import android.app.Activity;
-import android.content.Context;
import android.content.DialogInterface;
-import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
@@ -43,13 +43,10 @@ import java.util.Date;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
-import info.nightscout.androidaps.Services.Intents;
-import info.nightscout.androidaps.db.BgReading;
-import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
-import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
+import info.nightscout.androidaps.events.EventNewBasalProfile;
+import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
-import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog;
-import info.nightscout.client.data.DbLogger;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.PlusMinusEditText;
@@ -62,7 +59,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
private FragmentActivity context;
- private static CareportalFragment.OptionsToShow options;
+ private static OptionsToShow options;
NSProfile profile;
String units;
@@ -107,10 +104,23 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
Date eventTime;
- public void setOptions(CareportalFragment.OptionsToShow options) {
+ private static Handler sHandler;
+ private static HandlerThread sHandlerThread;
+
+
+ public void setOptions(OptionsToShow options) {
this.options = options;
}
+ public NewNSTreatmentDialog() {
+ super();
+ if (sHandlerThread == null) {
+ sHandlerThread = new HandlerThread(NewNSTreatmentDialog.class.getSimpleName());
+ sHandlerThread.start();
+ sHandler = new Handler(sHandlerThread.getLooper());
+ }
+ }
+
@Override
public void onAttach(Activity activity) {
context = (FragmentActivity) activity;
@@ -532,6 +542,30 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
ConfigBuilderPlugin.uploadCareportalEntryToNS(data);
+ if (options.executeProfileSwitch) {
+ if (data.has("profile")) {
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ String profile = data.getString("profile");
+ NSProfile nsProfile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
+ nsProfile.setActiveProfile(profile);
+ PumpInterface pump = MainApp.getConfigBuilder();
+ if (pump != null) {
+ pump.setNewBasalProfile(nsProfile);
+ log.debug("Setting new profile: " + profile);
+ MainApp.bus().post(new EventNewBasalProfile(nsProfile));
+ } else {
+ log.error("No active pump selected");
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ }
}
});
builder.setNegativeButton(getContext().getString(R.string.cancel), null);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/OptionsToShow.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/OptionsToShow.java
new file mode 100644
index 0000000000..e5a086c07e
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/OptionsToShow.java
@@ -0,0 +1,46 @@
+package info.nightscout.androidaps.plugins.Careportal;
+
+/**
+ * Created by mike on 05.11.2016.
+ */
+
+public class OptionsToShow {
+ public int eventType;
+ public int eventName;
+ public boolean bg;
+ public boolean insulin;
+ public boolean carbs;
+ public boolean prebolus;
+ public boolean duration;
+ public boolean percent;
+ public boolean absolute;
+ public boolean profile;
+ public boolean split;
+
+ // perform direct actions
+ public boolean executeProfileSwitch = false;
+
+ public OptionsToShow(int eventType,
+ int eventName,
+ boolean bg,
+ boolean insulin,
+ boolean carbs,
+ boolean prebolus,
+ boolean duration,
+ boolean percent,
+ boolean absolute,
+ boolean profile,
+ boolean split) {
+ this.eventType = eventType;
+ this.eventName = eventName;
+ this.bg = bg;
+ this.insulin = insulin;
+ this.carbs = carbs;
+ this.prebolus = prebolus;
+ this.duration = duration;
+ this.percent = percent;
+ this.absolute = absolute;
+ this.profile = profile;
+ this.split = split;
+ }
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java
index d052d80d02..f842ac9a5b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java
@@ -43,7 +43,7 @@ import info.nightscout.androidaps.plugins.Loop.DeviceStatus;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResult;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
-import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog;
+import info.nightscout.androidaps.plugins.Actions.dialogs.NewExtendedBolusDialog;
import info.nightscout.client.data.DbLogger;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DateUtil;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRFragment.java
index 6e4dbcf982..3595193ce1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRFragment.java
@@ -202,7 +202,7 @@ public class DanaRFragment extends Fragment implements FragmentBase {
}
if (DanaRPlugin.getDanaRPump().lastBolusTime.getTime() != 0) {
Long agoMsec = new Date().getTime() - DanaRPlugin.getDanaRPump().lastBolusTime.getTime();
- double agoHours = (int) (agoMsec / 60d / 60d / 1000d);
+ double agoHours = agoMsec / 60d / 60d / 1000d;
if (agoHours < 6) // max 6h back
lastBolusView.setText(formatTime.format(DanaRPlugin.getDanaRPump().lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(danaRPlugin.getDanaRPump().lastBolusAmount) + " U");
else lastBolusView.setText("");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java
index bf433d8e59..58ab564f6e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java
@@ -10,6 +10,7 @@ import org.json.JSONObject;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
+import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.DecimalFormatter;
/**
@@ -20,14 +21,15 @@ public class APSResult implements Parcelable {
public double rate;
public int duration;
public boolean changeRequested = false;
-
@Override
public String toString() {
+ final ConfigBuilderPlugin configBuilder = MainApp.getConfigBuilder();
if (changeRequested) {
if (rate == 0 && duration == 0)
return MainApp.sResources.getString(R.string.canceltemp);
else
- return MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h\n" +
+ return MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " +
+ "(" + DecimalFormatter.to2Decimal(rate/configBuilder.getBaseBasalRate() *100) + "%)\n" +
MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to0Decimal(duration) + " min\n" +
MainApp.sResources.getString(R.string.reason) + ": " + reason;
} else
@@ -35,11 +37,13 @@ public class APSResult implements Parcelable {
}
public Spanned toSpanned() {
+ final ConfigBuilderPlugin configBuilder = MainApp.getConfigBuilder();
if (changeRequested) {
String ret = "";
if (rate == 0 && duration == 0) ret = MainApp.sResources.getString(R.string.canceltemp);
else
- ret = "" + MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h
" +
+ ret = "" + MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " +
+ "(" + DecimalFormatter.to2Decimal(rate/configBuilder.getBaseBasalRate() *100) + "%)
" +
"" + MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to2Decimal(duration) + " min
" +
"" + MainApp.sResources.getString(R.string.reason) + ": " + reason.replace("<", "<").replace(">", ">");
return Html.fromHtml(ret);
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 5592b356a8..6efdfd0b0a 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
@@ -59,8 +59,6 @@ import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
-import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog;
-import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTempBasalDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
import info.nightscout.androidaps.plugins.Overview.GraphSeriesExtension.PointsWithLabelGraphSeries;
@@ -69,7 +67,6 @@ import info.nightscout.utils.BolusWizard;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.Round;
-import info.nightscout.utils.SafeParse;
public class OverviewFragment extends Fragment {
@@ -90,14 +87,11 @@ public class OverviewFragment extends Fragment {
GraphView bgGraph;
LinearLayout cancelTempLayout;
- LinearLayout setTempLayout;
LinearLayout acceptTempLayout;
LinearLayout quickWizardLayout;
Button cancelTempButton;
Button treatmentButton;
Button wizardButton;
- Button setTempButton;
- Button setExtenedButton;
Button acceptTempButton;
Button quickWizardButton;
@@ -130,10 +124,7 @@ public class OverviewFragment extends Fragment {
cancelTempButton = (Button) view.findViewById(R.id.overview_canceltemp);
treatmentButton = (Button) view.findViewById(R.id.overview_treatment);
wizardButton = (Button) view.findViewById(R.id.overview_wizard);
- setExtenedButton = (Button) view.findViewById(R.id.overview_extendedbolus);
- setTempButton = (Button) view.findViewById(R.id.overview_settempbasal);
cancelTempButton = (Button) view.findViewById(R.id.overview_canceltemp);
- setTempLayout = (LinearLayout) view.findViewById(R.id.overview_settemplayout);
cancelTempLayout = (LinearLayout) view.findViewById(R.id.overview_canceltemplayout);
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
@@ -182,23 +173,6 @@ public class OverviewFragment extends Fragment {
}
});
- setTempButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- FragmentManager manager = getFragmentManager();
- NewTempBasalDialog newTempDialog = new NewTempBasalDialog();
- newTempDialog.show(manager, "NewTempDialog");
- }
- });
-
- setExtenedButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- FragmentManager manager = getFragmentManager();
- NewExtendedBolusDialog newExtendedDialog = new NewExtendedBolusDialog();
- newExtendedDialog.show(manager, "NewExtendedDialog");
- }
- });
acceptTempButton.setOnClickListener(new View.OnClickListener() {
@Override
@@ -429,9 +403,18 @@ public class OverviewFragment extends Fragment {
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
if (Config.APS) {
apsModeView.setVisibility(View.VISIBLE);
- if (MainApp.getConfigBuilder().isClosedModeEnabled())
- apsModeView.setText(MainApp.sResources.getString(R.string.closedloop));
- else apsModeView.setText(MainApp.sResources.getString(R.string.openloop));
+ apsModeView.setBackgroundResource(R.drawable.loopmodeborder);
+ LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
+ if(activeloop != null && activeloop.isEnabled(activeloop.getType())) {
+ if (MainApp.getConfigBuilder().isClosedModeEnabled()) {
+ apsModeView.setText(MainApp.sResources.getString(R.string.closedloop));
+ } else {
+ apsModeView.setText(MainApp.sResources.getString(R.string.openloop));
+ }
+ } else {
+ apsModeView.setBackgroundResource(R.drawable.loopmodedisabledborder);
+ apsModeView.setText(MainApp.sResources.getString(R.string.disabledloop));
+ }
} else {
apsModeView.setVisibility(View.GONE);
}
@@ -455,26 +438,20 @@ public class OverviewFragment extends Fragment {
if (pump.isTempBasalInProgress()) {
TempBasal activeTemp = pump.getTempBasal();
cancelTempLayout.setVisibility(View.VISIBLE);
- setTempLayout.setVisibility(View.GONE);
cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + ": " + activeTemp.toString());
runningTempView.setText(activeTemp.toString());
} else {
cancelTempLayout.setVisibility(View.GONE);
- setTempLayout.setVisibility(View.VISIBLE);
Double currentBasal = pump.getBaseBasalRate();
runningTempView.setText(DecimalFormatter.to2Decimal(currentBasal) + " U/h");
}
if (profile == null) {
// disable all treatment buttons because we are not able to check constraints without profile
- setExtenedButton.setVisibility(View.INVISIBLE);
- setTempLayout.setVisibility(View.INVISIBLE);
wizardButton.setVisibility(View.INVISIBLE);
treatmentButton.setVisibility(View.INVISIBLE);
return;
} else {
- setExtenedButton.setVisibility(View.VISIBLE);
- setTempLayout.setVisibility(View.VISIBLE);
wizardButton.setVisibility(View.VISIBLE);
treatmentButton.setVisibility(View.VISIBLE);
}
diff --git a/app/src/main/java/info/nightscout/client/data/NSProfile.java b/app/src/main/java/info/nightscout/client/data/NSProfile.java
index 5b919466ee..c9a0c0723e 100644
--- a/app/src/main/java/info/nightscout/client/data/NSProfile.java
+++ b/app/src/main/java/info/nightscout/client/data/NSProfile.java
@@ -349,6 +349,19 @@ public class NSProfile {
return activeProfile;
}
+ public void setActiveProfile(String newProfile) {
+ try {
+ JSONObject store = json.getJSONObject("store");
+ if (newProfile != null && store.has(newProfile)) {
+ activeProfile = newProfile;
+ } else {
+ log.error("Attempt to set wrong active profile");
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
public Double getMaxDailyBasal() {
Double max = 0d;
for (Integer hour = 0; hour < 24; hour++) {
diff --git a/app/src/main/res/drawable/loopmodedisabledborder.xml b/app/src/main/res/drawable/loopmodedisabledborder.xml
new file mode 100644
index 0000000000..1d312404e0
--- /dev/null
+++ b/app/src/main/res/drawable/loopmodedisabledborder.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/actions_fragment.xml b/app/src/main/res/layout/actions_fragment.xml
new file mode 100644
index 0000000000..daa2f52ecf
--- /dev/null
+++ b/app/src/main/res/layout/actions_fragment.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml
index 2cc040bb57..bac64384b7 100644
--- a/app/src/main/res/layout/overview_fragment.xml
+++ b/app/src/main/res/layout/overview_fragment.xml
@@ -136,39 +136,6 @@
-
-
-
-
-
-
-
Базал
КЗ достъпна в NS
Болус
- Приложено ограничение на болус
+ Приложено ограничение за болус
Откажи
Въглехидрати
Приложено ограничениe за въгл.
@@ -294,8 +294,33 @@
Една седмица успешно дневно използване с редовно въвеждане на въглехидрати
Настройване на базалния инсулин и коефициенти ако е необходимо и активиране на auto-sens
Uploading
- Подава %.2fU
+ Подава %.2fU
Español
Не е избран профил
Korean
+ %s е недопустима стойност
+ Текст на бутон:
+ Корекция
+ Loop забранен
+ Въглехидрати:
+ Валидно:
+ Добави
+ Редактирай
+ Прехахни
+ Бърз болус
+ Настройки за бърз болус
+ Не са позволени отдалечени настройки
+ To start basal %.2fU/h reply with code %s
+ To stop temp basal reply with code %s
+ Loop has been disabled
+ Loop has been enabled
+ Loop is disabled
+ Loop is enabled
+ Позволи команди през SMS
+ Temp basal canceled
+ Canceling temp basal failed
+ Temp basal start failed
+ Temp basal %.2fU/h for %d min started successfully
+ Uknonwn command or wrong reply
+ Болус за хранене
diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml
index 96ca569848..f8e4ee93c1 100644
--- a/app/src/main/res/values-cs/strings.xml
+++ b/app/src/main/res/values-cs/strings.xml
@@ -321,4 +321,5 @@
Bolus
Korean
Korekce
+ Akce
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 5f4d23294a..0fc569b149 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -144,7 +144,7 @@
Objectives
KEIN PROFIL GESETZT
NSClient nicht installiert. Record lost!
- Use absolute basal values instead of percent in upload to NS
+ Verwende absolute statt prozentuelle Basalwerte beim Upload zu NightScout
Bisher noch kein Profil von NS geladen
No change requested
NO APS SELECTED OR PROVIDED RESULT
@@ -238,11 +238,44 @@
Fehler beim aktualisieren der Basalrate
vor h
SMS Kommunikator
- erlaubte TElefonnummern
+ erlaubte Telefonnummern
Nightscout Profil zur Pumpe synchronisieren
auf Pumpenergebnis warten
Kein Bluetoothadapter gefunden
Remote Bolus nicht erlaubt
Um Bolus %.2fU bitte mit %s antworten
Korean
+ Limit erreicht
+ Falsches Pumpen-Passwort!
+ Warte auf Pumpe
+ Korr
+ Abgabe %.2fU
+ %.2fU Bolus erfolgreich abgegeben
+ Alarm
+ Kohlenhydrate
+ Fehler
+ Glucose
+ Historie
+ Alarme
+ Bolus
+ Kohlenhydrate
+ Inslin-Tagesmengen
+ Fehler
+ Glucose
+ Füllmenge
+ Unterbrechungen
+ Pumpen-Passwort
+ Essensbolus
+ Kein Profil gewählt
+ Stop
+ Gestoppt
+ STOP GEDRÜCKT
+ Löschen
+ Hinzufügen
+ Bearbeiten
+ Basal-Stunden
+ Verbindungsaufbau %d s
+ Gültigkeit:
+ Kohlenhydrate
+ QuickWizard Einstellungen
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 1d5e067026..ada5fec74a 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -15,6 +15,7 @@
#47c8ff
#FF478EFF
#FFDD7792
+ #ca77dd
#c45026
#830400
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cc4efc71b0..6a72ca3921 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -132,6 +132,8 @@
Closed Loop
Open Loop
+ Loop Disabled
+
New suggestion available
Unsupported version of NSClient
NSClient not installed. Record lost!
@@ -331,5 +333,6 @@
Meal
Corr
Korean
+ Actions