diff --git a/app/build.gradle b/app/build.gradle
index b1da089c05..f800902ecd 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -44,7 +44,7 @@ android {
minSdkVersion 21
targetSdkVersion 23
versionCode 1500
- version "1.5e"
+ version "1.5f"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", generateGitBuild()
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 74271acb90..7d792556b7 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -56,16 +56,6 @@
android:enabled="true"
android:exported="true">
-
-
-
-
-
-
-
-
-
-
@@ -76,20 +66,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -120,14 +96,6 @@
-
-
-
-
-
pluginsList = null;
+ private static DataReceiver dataReceiver = new DataReceiver();
+ private static NSAlarmReceiver alarmReciever = new NSAlarmReceiver();
+ private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver();
+ private LocalBroadcastManager lbm;
+
@Override
public void onCreate() {
super.onCreate();
@@ -93,6 +104,8 @@ public class MainApp extends Application {
sInstance = this;
sResources = getResources();
+ registerLocalBroadcastReceiver();
+
if (pluginsList == null) {
pluginsList = new ArrayList<>();
// Register all tabs in app here
@@ -157,6 +170,29 @@ public class MainApp extends Application {
}
});
t.start();
+
+ }
+
+ private void registerLocalBroadcastReceiver() {
+ lbm = LocalBroadcastManager.getInstance(this);
+ lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_TREATMENT));
+ lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_CHANGED_TREATMENT));
+ lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_REMOVED_TREATMENT));
+ lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_SGV));
+ lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_PROFILE));
+ lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_STATUS));
+ lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_MBG));
+ lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_DEVICESTATUS));
+ lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_CAL));
+
+ //register alarms
+ lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_ALARM));
+ lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_ANNOUNCEMENT));
+ lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_CLEAR_ALARM));
+ lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_URGENT_ALARM));
+
+ //register ack alarm
+ lbm.registerReceiver(ackAlarmReciever, new IntentFilter(Intents.ACTION_ACK_ALARM));
}
private void startKeepAliveService() {
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 40cbbf3c52..3b04c30d94 100644
--- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
+++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java
@@ -506,7 +506,7 @@ public class DataService extends IntentService {
MainApp.getDbHelper().createCareportalEventFromJsonIfNotExists(trJson);
}
- if (trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) {
+ if (trJson.has("eventType") && trJson.getString("eventType").equals(CareportalEvent.ANNOUNCEMENT)) {
long date = trJson.getLong("mills");
long now = System.currentTimeMillis();
if (date > now - 15 * 60 * 1000L && trJson.has("notes")) {
diff --git a/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java b/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java
index c401c47574..a624310b10 100644
--- a/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java
+++ b/app/src/main/java/info/nightscout/androidaps/db/TemporaryBasal.java
@@ -296,17 +296,17 @@ public class TemporaryBasal implements Interval {
Profile profile = MainApp.getConfigBuilder().getProfile();
Double currentBasalRate = profile.getBasal();
double rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate);
- return DecimalFormatter.to2Decimal(rate) + "U/h ("+DecimalFormatter.to2Decimal(netExtendedRate)+"E) @" +
+ return getCalcuatedPercentageIfNeeded() + DecimalFormatter.to2Decimal(rate) + "U/h ("+DecimalFormatter.to2Decimal(netExtendedRate)+"E) @" +
DateUtil.timeString(date) +
- " " + getRealDuration() + "/" + durationInMinutes + "min";
+ " " + getRealDuration() + "/" + durationInMinutes + "'";
} else if (isAbsolute) {
return DecimalFormatter.to2Decimal(absoluteRate) + "U/h @" +
DateUtil.timeString(date) +
- " " + getRealDuration() + "/" + durationInMinutes + "min";
+ " " + getRealDuration() + "/" + durationInMinutes + "'";
} else { // percent
return percentRate + "% @" +
DateUtil.timeString(date) +
- " " + getRealDuration() + "/" + durationInMinutes + "min";
+ " " + getRealDuration() + "/" + durationInMinutes + "'";
}
}
@@ -337,6 +337,31 @@ public class TemporaryBasal implements Interval {
}
}
+ private String getCalcuatedPercentageIfNeeded(){
+ if (isAbsolute || isFakeExtended) {
+
+ double rate = 0d;
+ if (isFakeExtended) {
+ Profile profile = MainApp.getConfigBuilder().getProfile();
+ Double currentBasalRate = profile.getBasal();
+ rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate);
+ } else if (isAbsolute){
+ rate = absoluteRate;
+ }
+
+ if(SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)){
+ Profile profile = MainApp.getConfigBuilder().getProfile();
+ if(profile != null) {
+ double basal = profile.getBasal();
+ if(basal != 0){
+ return Math.round(rate*100d/basal) + "% ";
+ }
+ }
+ }
+ }
+ return "";
+ }
+
public String toStringVeryShort() {
if (isAbsolute || isFakeExtended) {
diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
index dbbdec2ce1..bb78ea1d0a 100644
--- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
+++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
@@ -34,7 +34,9 @@ public interface PumpInterface {
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes);
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes);
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
- PumpEnactResult cancelTempBasal();
+ //some pumps might set a very short temp close to 100% as canecelling a temp can be noisy
+ //when the cancel request is requested by the user, the pump should always do a real cancel
+ PumpEnactResult cancelTempBasal(boolean userRequested);
PumpEnactResult cancelExtendedBolus();
// Status to be passed to NS
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
index b62674c5ae..c6b278955f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java
@@ -20,6 +20,7 @@ import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.ExtendedBolus;
+import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventRefreshOverview;
@@ -49,6 +50,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
Button extendedBolus;
Button extendedBolusCancel;
Button tempBasal;
+ Button tempBasalCancel;
Button fill;
private static Handler sHandler;
@@ -74,6 +76,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
extendedBolus = (Button) view.findViewById(R.id.actions_extendedbolus);
extendedBolusCancel = (Button) view.findViewById(R.id.actions_extendedbolus_cancel);
tempBasal = (Button) view.findViewById(R.id.actions_settempbasal);
+ tempBasalCancel = (Button) view.findViewById(R.id.actions_canceltempbasal);
fill = (Button) view.findViewById(R.id.actions_fill);
profileSwitch.setOnClickListener(this);
@@ -81,6 +84,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
extendedBolus.setOnClickListener(this);
extendedBolusCancel.setOnClickListener(this);
tempBasal.setOnClickListener(this);
+ tempBasalCancel.setOnClickListener(this);
fill.setOnClickListener(this);
updateGUI();
@@ -114,33 +118,59 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
- if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() == null)
+ if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() == null) {
+ tempTarget.setVisibility(View.GONE);
+ profileSwitch.setVisibility(View.GONE);
+ extendedBolus.setVisibility(View.GONE);
+ extendedBolusCancel.setVisibility(View.GONE);
+ tempBasal.setVisibility(View.GONE);
+ tempBasalCancel.setVisibility(View.GONE);
+ fill.setVisibility(View.GONE);
return;
+ }
boolean allowProfileSwitch = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile().getProfileList().size() > 1;
if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !allowProfileSwitch)
profileSwitch.setVisibility(View.GONE);
else
profileSwitch.setVisibility(View.VISIBLE);
- if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() || MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
+
+
+ if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) {
extendedBolus.setVisibility(View.GONE);
- else {
- extendedBolus.setVisibility(View.VISIBLE);
- }
- if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() || MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
extendedBolusCancel.setVisibility(View.GONE);
- else {
- extendedBolusCancel.setVisibility(View.VISIBLE);
- ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
- extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString());
+ } else {
+ if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
+ extendedBolus.setVisibility(View.GONE);
+ extendedBolusCancel.setVisibility(View.VISIBLE);
+ ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
+ extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString());
+ } else {
+ extendedBolus.setVisibility(View.VISIBLE);
+ extendedBolusCancel.setVisibility(View.GONE);
+ }
}
- if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isTempBasalInProgress())
+
+
+ if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) {
tempBasal.setVisibility(View.GONE);
- else
- tempBasal.setVisibility(View.VISIBLE);
+ tempBasalCancel.setVisibility(View.GONE);
+ } else {
+ if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
+ tempBasal.setVisibility(View.GONE);
+ tempBasalCancel.setVisibility(View.VISIBLE);
+ final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
+ tempBasalCancel.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort());
+ } else {
+ tempBasal.setVisibility(View.VISIBLE);
+ tempBasalCancel.setVisibility(View.GONE);
+ }
+ }
+
if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended())
fill.setVisibility(View.GONE);
else
fill.setVisibility(View.VISIBLE);
+
if (!Config.APS)
tempTarget.setVisibility(View.GONE);
else
@@ -184,6 +214,17 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
});
}
break;
+ case R.id.actions_canceltempbasal:
+ if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ pump.cancelTempBasal(true);
+ Answers.getInstance().logCustom(new CustomEvent("CancelTemp"));
+ }
+ });
+ }
+ break;
case R.id.actions_settempbasal:
NewTempBasalDialog newTempDialog = new NewTempBasalDialog();
newTempDialog.show(manager, "NewTempDialog");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java
index 51effccb86..0a379a904d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java
@@ -27,6 +27,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.data.Profile;
+import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.SafeParse;
@@ -35,14 +36,14 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
RadioButton percentRadio;
RadioButton absoluteRadio;
RadioGroup basalTypeRadioGroup;
- RelativeLayout typeSelectorLayout;
+ LinearLayout typeSelectorLayout;
LinearLayout percentLayout;
LinearLayout absoluteLayout;
- PlusMinusEditText basalPercent;
- PlusMinusEditText basalAbsolute;
- PlusMinusEditText duration;
+ NumberPicker basalPercent;
+ NumberPicker basalAbsolute;
+ NumberPicker duration;
Handler mHandler;
public static HandlerThread mHandlerThread;
@@ -65,22 +66,24 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
percentRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_percent_radio);
basalTypeRadioGroup = (RadioGroup) view.findViewById(R.id.overview_newtempbasal_radiogroup);
absoluteRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_absolute_radio);
- typeSelectorLayout = (RelativeLayout) view.findViewById(R.id.overview_newtempbasal_typeselector_layout);
+ typeSelectorLayout = (LinearLayout) view.findViewById(R.id.overview_newtempbasal_typeselector_layout);
PumpDescription pumpDescription = MainApp.getConfigBuilder().getPumpDescription();
- basalPercent = new PlusMinusEditText(view, R.id.overview_newtempbasal_basalpercentinput, R.id.overview_newtempbasal_basalpercent_plus, R.id.overview_newtempbasal_basalpercent_minus,
- 100d, 0d, (double) pumpDescription.maxTempPercent, (double) pumpDescription.tempPercentStep, new DecimalFormat("0"), true);
+ basalPercent = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalpercentinput);
+ double maxTempPercent = pumpDescription.maxTempPercent;
+ double tempPercentStep = pumpDescription.tempPercentStep;
+ basalPercent.setParams(100d, 0d, maxTempPercent, tempPercentStep, new DecimalFormat("0"), true);
Profile profile = MainApp.getConfigBuilder().getProfile();
- Double currentBasal = profile.getBasal();
- basalAbsolute = new PlusMinusEditText(view, R.id.overview_newtempbasal_basalabsoluteinput, R.id.overview_newtempbasal_basalabsolute_plus, R.id.overview_newtempbasal_basalabsolute_minus,
- currentBasal, 0d, pumpDescription.maxTempAbsolute, pumpDescription.tempAbsoluteStep, new DecimalFormat("0.00"), true);
+ Double currentBasal = profile != null ? profile.getBasal() : 0d;
+ basalAbsolute = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalabsoluteinput);
+ basalAbsolute.setParams(currentBasal, 0d, pumpDescription.maxTempAbsolute, pumpDescription.tempAbsoluteStep, new DecimalFormat("0.00"), true);
- double tempDurationStep = MainApp.getConfigBuilder().getPumpDescription().tempDurationStep;
- double tempMaxDuration = MainApp.getConfigBuilder().getPumpDescription().tempMaxDuration;
- duration = new PlusMinusEditText(view, R.id.overview_newtempbasal_duration, R.id.overview_newtempbasal_duration_plus, R.id.overview_newtempbasal_duration_minus,
- tempDurationStep, tempDurationStep, tempMaxDuration, tempDurationStep, new DecimalFormat("0"), false);
+ double tempDurationStep = pumpDescription.tempDurationStep;
+ double tempMaxDuration = pumpDescription.tempMaxDuration;
+ duration = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_duration);
+ duration.setParams(tempDurationStep, tempDurationStep, tempMaxDuration, tempDurationStep, new DecimalFormat("0"), false);
if ((pumpDescription.tempBasalStyle & PumpDescription.PERCENT) == PumpDescription.PERCENT && (pumpDescription.tempBasalStyle & PumpDescription.ABSOLUTE) == PumpDescription.ABSOLUTE) {
// Both allowed
@@ -107,13 +110,6 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
return view;
}
- @Override
- public void onResume() {
- super.onResume();
- if (getDialog() != null)
- getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- }
-
@Override
public void onClick(View view) {
switch (view.getId()) {
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 31907f16dc..ea995d2b6b 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
@@ -509,8 +509,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
}
@Override
- public PumpEnactResult cancelTempBasal() {
- PumpEnactResult result = activePump.cancelTempBasal();
+ public PumpEnactResult cancelTempBasal(boolean userRequested) {
+ PumpEnactResult result = activePump.cancelTempBasal(userRequested);
if (Config.logCongigBuilderActions)
log.debug("cancelTempBasal success: " + result.success + " enacted: " + result.enacted);
return result;
@@ -559,7 +559,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
if (isTempBasalInProgress()) {
if (Config.logCongigBuilderActions)
log.debug("applyAPSRequest: cancelTempBasal()");
- result = cancelTempBasal();
+ result = cancelTempBasal(false);
} else {
result = new PumpEnactResult();
result.absolute = request.rate;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java
index 827023f5b3..b33d1cb2c3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalPlugin.java
@@ -159,7 +159,7 @@ public class NSClientInternalPlugin implements PluginBase {
MainApp.bus().post(new EventNSClientUpdateGUI());
}
- void clearLog() {
+ synchronized void clearLog() {
handler.post(new Runnable() {
@Override
public void run() {
@@ -169,7 +169,7 @@ public class NSClientInternalPlugin implements PluginBase {
});
}
- private void addToLog(final EventNSClientNewLog ev) {
+ private synchronized void addToLog(final EventNSClientNewLog ev) {
handler.post(new Runnable() {
@Override
public void run() {
@@ -183,7 +183,7 @@ public class NSClientInternalPlugin implements PluginBase {
});
}
- static void updateLog() {
+ static synchronized void updateLog() {
try {
StringBuilder newTextLog = new StringBuilder();
List temporaryList = new ArrayList<>(listLog);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java
index 35789a426c..216fa3d19a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAckAlarm.java
@@ -4,12 +4,15 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm;
import info.nightscout.utils.SP;
@@ -22,7 +25,7 @@ public class BroadcastAckAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastAckAlarm.class);
public static void handleClearAlarm(NSAlarm originalAlarm, Context context, long silenceTimeInMsec) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
+
Bundle bundle = new Bundle();
bundle.putInt("level", originalAlarm.getLevel());
bundle.putString("group", originalAlarm.getGroup());
@@ -30,7 +33,18 @@ public class BroadcastAckAlarm {
Intent intent = new Intent(Intents.ACTION_ACK_ALARM);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putInt("level", originalAlarm.getLevel());
+ bundle.putString("group", originalAlarm.getGroup());
+ bundle.putLong("silenceTime", silenceTimeInMsec);
+ intent = new Intent(Intents.ACTION_ACK_ALARM);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java
index 03fe04f8fe..0fee6600bd 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAlarm.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONObject;
import org.slf4j.Logger;
@@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
@@ -21,14 +24,20 @@ public class BroadcastAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastAlarm.class);
public static void handleAlarm(JSONObject alarm, Context context) {
-
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("data", alarm.toString());
Intent intent = new Intent(Intents.ACTION_ALARM);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("data", alarm.toString());
+ intent = new Intent(Intents.ACTION_ALARM);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java
index 3f9a43a14a..9b133c2551 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastAnnouncement.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -12,6 +13,8 @@ import org.slf4j.LoggerFactory;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
@@ -22,14 +25,20 @@ public class BroadcastAnnouncement {
private static Logger log = LoggerFactory.getLogger(BroadcastAnnouncement.class);
public static void handleAnnouncement(JSONObject announcement, Context context) {
-
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("data", announcement.toString());
Intent intent = new Intent(Intents.ACTION_ANNOUNCEMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("data", announcement.toString());
+ intent = new Intent(Intents.ACTION_ANNOUNCEMENT);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java
index 7a7772357c..7580a00088 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastCals.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
import org.slf4j.Logger;
@@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
@@ -22,14 +25,22 @@ public class BroadcastCals {
public static void handleNewCal(JSONArray cals, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("cals", cals.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_CAL);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("cals", cals.toString());
+ bundle.putBoolean("delta", isDelta);
+ intent = new Intent(Intents.ACTION_NEW_CAL);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java
index 4f2716cf85..23406837a7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastClearAlarm.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONObject;
import org.slf4j.Logger;
@@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
@@ -21,14 +24,20 @@ public class BroadcastClearAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastClearAlarm.class);
public static void handleClearAlarm(JSONObject clearalarm, Context context) {
-
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("data", clearalarm.toString());
Intent intent = new Intent(Intents.ACTION_CLEAR_ALARM);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("data", clearalarm.toString());
+ intent = new Intent(Intents.ACTION_CLEAR_ALARM);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java
index 9053c6becb..a912fc5d3c 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastDeviceStatus.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -12,6 +13,8 @@ import org.slf4j.LoggerFactory;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
@@ -26,14 +29,20 @@ public class BroadcastDeviceStatus {
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("devicestatus", status.toString());
+ bundle.putBoolean("delta", isDelta);
+ intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
public static void handleNewDeviceStatus(JSONArray statuses, Context context, boolean isDelta) {
-
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
-
List splitted = BroadcastTreatment.splitArray(statuses);
for (JSONArray part: splitted) {
Bundle bundle = new Bundle();
@@ -42,7 +51,20 @@ public class BroadcastDeviceStatus {
Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+ }
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ splitted = BroadcastTreatment.splitArray(statuses);
+ for (JSONArray part : splitted) {
+ Bundle bundle = new Bundle();
+ bundle.putString("devicestatuses", part.toString());
+ bundle.putBoolean("delta", isDelta);
+ Intent intent = new Intent(Intents.ACTION_NEW_DEVICESTATUS);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java
index f45ade6b32..a715747791 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastMbgs.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
import org.slf4j.Logger;
@@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
@@ -22,14 +25,22 @@ public class BroadcastMbgs {
public static void handleNewMbg(JSONArray mbgs, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("mbgs", mbgs.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_MBG);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("mbgs", mbgs.toString());
+ bundle.putBoolean("delta", isDelta);
+ intent = new Intent(Intents.ACTION_NEW_MBG);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java
index ec62ccbf6f..3802b09657 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastProfile.java
@@ -4,12 +4,15 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.utils.SP;
@@ -23,15 +26,23 @@ public class BroadcastProfile {
public static void handleNewTreatment(ProfileStore profile, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("profile", profile.getData().toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_PROFILE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("profile", profile.getData().toString());
+ bundle.putBoolean("delta", isDelta);
+ intent = new Intent(Intents.ACTION_NEW_PROFILE);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java
index eedeb4574d..abc49be18a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastQueueStatus.java
@@ -5,6 +5,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.PowerManager;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
@@ -14,7 +15,7 @@ import info.nightscout.utils.SP;
public class BroadcastQueueStatus {
public static void handleNewStatus(int size, Context context) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
+ if(!SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) return;
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java
index 29e2031869..d4193f3cb7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastSgvs.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -12,6 +13,8 @@ import org.slf4j.LoggerFactory;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
@@ -23,15 +26,23 @@ public class BroadcastSgvs {
public static void handleNewSgv(JSONObject sgv, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("sgv", sgv.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_SGV);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("sgv", sgv.toString());
+ bundle.putBoolean("delta", isDelta);
+ intent = new Intent(Intents.ACTION_NEW_SGV);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
public static void handleNewSgv(JSONArray sgvs, Context context, boolean isDelta) {
@@ -41,7 +52,17 @@ public class BroadcastSgvs {
Intent intent = new Intent(Intents.ACTION_NEW_SGV);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("sgvs", sgvs.toString());
+ bundle.putBoolean("delta", isDelta);
+ intent = new Intent(Intents.ACTION_NEW_SGV);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java
index 026658afc0..7c6862cb14 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java
@@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -12,6 +13,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
@@ -25,8 +27,6 @@ public class BroadcastStatus {
public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
try {
bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);
@@ -41,6 +41,24 @@ public class BroadcastStatus {
Intent intent = new Intent(Intents.ACTION_NEW_STATUS);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ try {
+ bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName);
+ bundle.putInt("nsclientversioncode", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode);
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ bundle.putString("nightscoutversionname", NSClientService.nightscoutVersionName);
+ bundle.putInt("nightscoutversioncode", NSClientService.nightscoutVersionCode);
+ bundle.putString("status", status.getData().toString());
+ bundle.putBoolean("delta", isDelta);
+ intent = new Intent(Intents.ACTION_NEW_STATUS);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java
index 60540d7613..0d998a2bcd 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java
@@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.TransactionTooLargeException;
+import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
import org.json.JSONException;
@@ -15,9 +16,12 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
import info.nightscout.utils.SP;
+import info.nightscout.utils.ToastUtils;
/**
* Created by mike on 20.02.2016.
@@ -27,21 +31,27 @@ public class BroadcastTreatment {
public static void handleNewTreatment(NSTreatment treatment, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.getData().toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("treatment", treatment.getData().toString());
+ bundle.putBoolean("delta", isDelta);
+ intent = new Intent(Intents.ACTION_NEW_TREATMENT);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
public static void handleNewTreatment(JSONArray treatments, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
List splitted = splitArray(treatments);
for (JSONArray part: splitted) {
Bundle bundle = new Bundle();
@@ -50,42 +60,73 @@ public class BroadcastTreatment {
Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+ }
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)){
+ splitted = splitArray(treatments);
+ for (JSONArray part: splitted) {
+ Bundle bundle = new Bundle();
+ bundle.putString("treatments", part.toString());
+ bundle.putBoolean("delta", isDelta);
+ Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
public void handleChangedTreatment(JSONObject treatment, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
- }
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
- public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
- List splitted = splitArray(treatments);
- for (JSONArray part: splitted) {
- Bundle bundle = new Bundle();
- bundle.putString("treatments", part.toString());
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("treatment", treatment.toString());
bundle.putBoolean("delta", isDelta);
- Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
+ intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
}
- public static void handleRemovedTreatment(JSONObject treatment, Context context, boolean isDelta) {
+ public static void handleChangedTreatment(JSONArray treatments, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
+ List splitted = splitArray(treatments);
+ for (JSONArray part : splitted) {
+ Bundle bundle = new Bundle();
+ bundle.putString("treatments", part.toString());
+ bundle.putBoolean("delta", isDelta);
+ Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+ }
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ splitted = splitArray(treatments);
+ for (JSONArray part : splitted) {
+ Bundle bundle = new Bundle();
+ bundle.putString("treatments", part.toString());
+ bundle.putBoolean("delta", isDelta);
+ Intent intent = new Intent(Intents.ACTION_CHANGED_TREATMENT);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
+ }
+ }
+
+ public static void handleRemovedTreatment(JSONObject treatment, Context context, boolean isDelta) {
Bundle bundle = new Bundle();
bundle.putString("treatment", treatment.toString());
@@ -93,20 +134,40 @@ public class BroadcastTreatment {
Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("treatment", treatment.toString());
+ bundle.putBoolean("delta", isDelta);
+ intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
public static void handleRemovedTreatment(JSONArray treatments, Context context, boolean isDelta) {
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("treatments", treatments.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("treatments", treatments.toString());
+ bundle.putBoolean("delta", isDelta);
+ intent = new Intent(Intents.ACTION_REMOVED_TREATMENT);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java
index 442eb729c0..c332be03af 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastUrgentAlarm.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONObject;
import org.slf4j.Logger;
@@ -11,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List;
+import info.nightscout.androidaps.MainApp;
+import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.utils.SP;
@@ -21,14 +24,20 @@ public class BroadcastUrgentAlarm {
private static Logger log = LoggerFactory.getLogger(BroadcastUrgentAlarm.class);
public static void handleUrgentAlarm(JSONObject urgentalarm, Context context) {
-
- if(!SP.getBoolean("nsclient_localbroadcasts", true)) return;
-
Bundle bundle = new Bundle();
bundle.putString("data", urgentalarm.toString());
Intent intent = new Intent(Intents.ACTION_URGENT_ALARM);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
- context.sendBroadcast(intent);
+ LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
+
+ if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
+ bundle = new Bundle();
+ bundle.putString("data", urgentalarm.toString());
+ intent = new Intent(Intents.ACTION_URGENT_ALARM);
+ intent.putExtras(bundle);
+ intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ context.sendBroadcast(intent);
+ }
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java
index 5d57f3caf1..c68bbb19d7 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java
@@ -313,6 +313,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
}
+ pump.cancelTempBasal(true);
result = pump.setTempBasalAbsolute(0d, 120);
if (!result.success) {
OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror), result.comment, null);
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 71f205551e..7e33d1ff8c 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
@@ -175,7 +175,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
LinearLayoutManager llm;
LinearLayout acceptTempLayout;
- Button cancelTempButton;
Button treatmentButton;
Button wizardButton;
Button calibrationButton;
@@ -269,9 +268,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
- cancelTempButton = (Button) view.findViewById(R.id.overview_canceltempbutton);
- if (cancelTempButton != null)
- cancelTempButton.setOnClickListener(this);
treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
treatmentButton.setOnClickListener(this);
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
@@ -415,7 +411,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
@@ -436,7 +432,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
@@ -450,7 +446,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
@@ -464,7 +460,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
@@ -478,7 +474,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
@@ -492,7 +488,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
@@ -506,6 +502,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
+ MainApp.getConfigBuilder().cancelTempBasal(true);
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 30);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
@@ -520,6 +517,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
+ MainApp.getConfigBuilder().cancelTempBasal(true);
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 60);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
@@ -534,6 +532,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
+ MainApp.getConfigBuilder().cancelTempBasal(true);
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 2 * 60);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
@@ -548,6 +547,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
+ MainApp.getConfigBuilder().cancelTempBasal(true);
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 3 * 60);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
@@ -583,18 +583,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
treatmentDialogFragment.show(manager, "TreatmentDialog");
break;
- case R.id.overview_canceltempbutton:
- final PumpInterface pump = MainApp.getConfigBuilder();
- if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- pump.cancelTempBasal();
- Answers.getInstance().logCustom(new CustomEvent("CancelTemp"));
- }
- });
- }
- break;
case R.id.overview_pumpstatus:
if (MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInitialized())
sHandler.post(new Runnable() {
@@ -1016,15 +1004,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
- if (cancelTempButton != null) {
- if (activeTemp != null) {
- cancelTempButton.setVisibility(View.VISIBLE);
- cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort());
- } else {
- cancelTempButton.setVisibility(View.GONE);
- }
- }
-
String basalText = "";
if (shorttextmode) {
if (activeTemp != null) {
@@ -1053,6 +1032,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
basalText += "(" + DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + "U/h)";
}
}
+ if (activeTemp != null) {
+ baseBasalView.setTextColor(MainApp.sResources.getColor(R.color.basal));
+ } else {
+ baseBasalView.setTextColor(Color.WHITE);
+
+ }
+
baseBasalView.setText(basalText);
final ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java
index 3a7f448309..2625b4699b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java
@@ -18,7 +18,6 @@ import android.support.v4.app.NotificationCompat;
import com.squareup.otto.Subscribe;
-import org.json.JSONException;
import org.json.JSONObject;
import org.monkey.d.ruffy.ruffy.driver.IRuffyService;
import org.slf4j.Logger;
@@ -195,11 +194,14 @@ public class ComboPlugin implements PluginBase, PumpInterface {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
ruffyScripter = new RuffyScripter(IRuffyService.Stub.asInterface(service));
+ ruffyScripter.start();
log.debug("ruffy serivce connected");
}
@Override
public void onServiceDisconnected(ComponentName name) {
+ ruffyScripter.stop();
+ ruffyScripter = null;
log.debug("ruffy service disconnected");
}
};
@@ -485,22 +487,27 @@ public class ComboPlugin implements PluginBase, PumpInterface {
@Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min");
- if (percent % 10 != 0) {
- int rounded = percent;
- while (rounded % 10 != 0) rounded = rounded - 1;
- log.debug("Rounded requested percentage from " + percent + " to " + rounded);
- percent = rounded;
+
+ int adjustedPercent = percent;
+
+ if (adjustedPercent > pumpDescription.maxTempPercent) {
+ log.debug("Reducing requested TBR to the maximum support by the pump: " + percent + " -> " + pumpDescription.maxTempPercent);
+ adjustedPercent = pumpDescription.maxTempPercent;
}
- percent = percent > pumpDescription.maxTempPercent ? pumpDescription.maxTempPercent : percent;
+ if (adjustedPercent % 10 != 0) {
+ Long rounded = Math.round(adjustedPercent / 10d) * 10;
+ log.debug("Rounded requested percentage:" + adjustedPercent + " -> " + rounded);
+ adjustedPercent = rounded.intValue();
+ }
- CommandResult commandResult = runCommand(new SetTbrCommand(percent, durationInMinutes));
+ CommandResult commandResult = runCommand(new SetTbrCommand(adjustedPercent, durationInMinutes));
if (commandResult.enacted) {
TemporaryBasal tempStart = new TemporaryBasal(commandResult.completionTime);
// TODO commandResult.state.tbrRemainingDuration might already display 29 if 30 was set, since 29:59 is shown as 29 ...
// we should check this, but really ... something must be really screwed up if that number was anything different
tempStart.durationInMinutes = durationInMinutes;
- tempStart.percentRate = percent;
+ tempStart.percentRate = adjustedPercent;
tempStart.isAbsolute = false;
tempStart.source = Source.USER;
ConfigBuilderPlugin treatmentsInterface = MainApp.getConfigBuilder();
@@ -514,7 +521,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
pumpEnactResult.isPercent = true;
// Combo would have bailed if this wasn't set properly. Maybe we should
// have the command return this anyways ...
- pumpEnactResult.percent = percent;
+ pumpEnactResult.percent = adjustedPercent;
pumpEnactResult.duration = durationInMinutes;
return pumpEnactResult;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
index 7ee13df40c..7ed4345093 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
@@ -566,7 +566,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
}
@Override
- public PumpEnactResult cancelTempBasal() {
+ public PumpEnactResult cancelTempBasal(boolean userRequested) {
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
return cancelRealTempBasal();
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
index c3bd70c155..e3b6bf3598 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
@@ -570,7 +570,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
}
@Override
- public PumpEnactResult cancelTempBasal() {
+ public PumpEnactResult cancelTempBasal(boolean userRequested) {
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
return cancelRealTempBasal();
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
index 7a0eca5da3..bb944b1165 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
@@ -340,7 +340,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
- return cancelTempBasal();
+ return cancelTempBasal(false);
}
result.success = true;
result.enacted = false;
@@ -507,7 +507,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
}
@Override
- public PumpEnactResult cancelTempBasal() {
+ public PumpEnactResult cancelTempBasal(boolean userRequested) {
PumpEnactResult result = new PumpEnactResult();
if (pump.isTempBasalInProgress) {
sExecutionService.tempBasalStop();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
index b51a0bb66e..ddd05a2e0b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
@@ -196,7 +196,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
}
@Override
- public PumpEnactResult cancelTempBasal() {
+ public PumpEnactResult cancelTempBasal(boolean userRequested) {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
result.comment = MainApp.instance().getString(R.string.pumperror);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java
index 2dfaefe482..b479183b80 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java
@@ -57,7 +57,6 @@ public class VirtualPumpFragment extends SubscriberFragment {
batteryView = (TextView) view.findViewById(R.id.virtualpump_battery);
reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir);
- updateGUI();
return view;
}
@@ -73,8 +72,8 @@ public class VirtualPumpFragment extends SubscriberFragment {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
-
- basaBasalRateView.setText(VirtualPumpPlugin.getInstance().getBaseBasalRate() + "U");
+ VirtualPumpPlugin virtualPump = VirtualPumpPlugin.getInstance();
+ basaBasalRateView.setText(virtualPump.getBaseBasalRate() + "U");
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
} else {
@@ -85,8 +84,8 @@ public class VirtualPumpFragment extends SubscriberFragment {
} else {
extendedBolusView.setText("");
}
- batteryView.setText(VirtualPumpPlugin.getInstance().batteryPercent + "%");
- reservoirView.setText(VirtualPumpPlugin.getInstance().reservoirInUnits + "U");
+ batteryView.setText(virtualPump.batteryPercent + "%");
+ reservoirView.setText(virtualPump.reservoirInUnits + "U");
}
});
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
index b42d1abfd6..7337859c47 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
@@ -204,7 +204,11 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override
public double getBaseBasalRate() {
- return MainApp.getConfigBuilder().getProfile().getBasal();
+ Profile profile = MainApp.getConfigBuilder().getProfile();
+ if (profile != null)
+ return profile.getBasal();
+ else
+ return 0d;
}
@Override
@@ -282,7 +286,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
PumpEnactResult result = new PumpEnactResult();
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
- result = cancelTempBasal();
+ result = cancelTempBasal(false);
if (!result.success)
return result;
}
@@ -333,7 +337,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
}
@Override
- public PumpEnactResult cancelTempBasal() {
+ public PumpEnactResult cancelTempBasal(boolean userRequested) {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
PumpEnactResult result = new PumpEnactResult();
result.success = true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
index ad8679beee..8e5e3bde46 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
@@ -272,7 +272,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
LoopPlugin loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class);
if (loopPlugin != null && loopPlugin.isEnabled(PluginBase.LOOP)) {
loopPlugin.setFragmentEnabled(PluginBase.LOOP, false);
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled)+ " " +
MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed);
@@ -506,7 +506,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
PumpInterface pumpInterface = MainApp.getConfigBuilder();
if (pumpInterface != null) {
danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
- PumpEnactResult result = pumpInterface.cancelTempBasal();
+ PumpEnactResult result = pumpInterface.cancelTempBasal(true);
if (result.success) {
reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled);
if (danaRPlugin != null)
@@ -535,7 +535,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
suspendWaitingForConfirmation.processed = true;
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
activeloop.suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000);
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/Events/EventNewSMS.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventNewSMS.java
similarity index 100%
rename from app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/Events/EventNewSMS.java
rename to app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventNewSMS.java
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/Events/EventSmsCommunicatorUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventSmsCommunicatorUpdateGui.java
similarity index 100%
rename from app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/Events/EventSmsCommunicatorUpdateGui.java
rename to app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventSmsCommunicatorUpdateGui.java
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 02ee924923..bca65dd4b5 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
@@ -189,6 +189,7 @@ public class ActionStringHandler {
boolean useBG = Boolean.parseBoolean(act[2]);
boolean useBolusIOB = Boolean.parseBoolean(act[3]);
boolean useBasalIOB = Boolean.parseBoolean(act[4]);
+ int percentage = Integer.parseInt(act[5]);
Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) {
@@ -203,7 +204,7 @@ public class ActionStringHandler {
}
DecimalFormat format = new DecimalFormat("0.00");
BolusWizard bolusWizard = new BolusWizard();
- bolusWizard.doCalc(profile, carbsAfterConstraints, 0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d, 0d, useBolusIOB, useBasalIOB, false, false);
+ bolusWizard.doCalc(profile, carbsAfterConstraints, 0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d, 0d, percentage, useBolusIOB, useBasalIOB, false, false);
Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(bolusWizard.calculatedTotalInsulin);
if (insulinAfterConstraints - bolusWizard.calculatedTotalInsulin != 0) {
@@ -233,6 +234,9 @@ public class ActionStringHandler {
rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U";
if (useBasalIOB)
rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U";
+ if(percentage != 100){
+ rMessage += "\nPercentage: " +format.format(bolusWizard.totalBeforePercentageAdjustment) + "U * " + percentage + "% -> ~" + format.format(bolusWizard.calculatedTotalInsulin) + "U";
+ }
lastBolusWizard = bolusWizard;
diff --git a/app/src/main/java/info/nightscout/utils/BolusWizard.java b/app/src/main/java/info/nightscout/utils/BolusWizard.java
index e5af535759..f4eb4907ef 100644
--- a/app/src/main/java/info/nightscout/utils/BolusWizard.java
+++ b/app/src/main/java/info/nightscout/utils/BolusWizard.java
@@ -47,9 +47,14 @@ public class BolusWizard {
// Result
public Double calculatedTotalInsulin = 0d;
+ public Double totalBeforePercentageAdjustment = 0d;
public Double carbsEquivalent = 0d;
public Double doCalc(Profile specificProfile, Integer carbs, Double cob, Double bg, Double correction, Boolean includeBolusIOB, Boolean includeBasalIOB, Boolean superBolus, Boolean trend) {
+ return doCalc(specificProfile, carbs, cob, bg, correction, 100d, includeBolusIOB, includeBasalIOB, superBolus, trend);
+ }
+
+ public Double doCalc(Profile specificProfile, Integer carbs, Double cob, Double bg, Double correction, double percentageCorrection, Boolean includeBolusIOB, Boolean includeBasalIOB, Boolean superBolus, Boolean trend) {
this.specificProfile = specificProfile;
this.carbs = carbs;
this.bg = bg;
@@ -103,7 +108,13 @@ public class BolusWizard {
}
// Total
- calculatedTotalInsulin = insulinFromBG + insulinFromTrend + insulinFromCarbs + insulingFromBolusIOB + insulingFromBasalsIOB + insulinFromCorrection + insulinFromSuperBolus + insulinFromCOB;
+ calculatedTotalInsulin = totalBeforePercentageAdjustment = insulinFromBG + insulinFromTrend + insulinFromCarbs + insulingFromBolusIOB + insulingFromBasalsIOB + insulinFromCorrection + insulinFromSuperBolus + insulinFromCOB;
+
+ //percentage
+ if(totalBeforePercentageAdjustment > 0){
+ calculatedTotalInsulin = totalBeforePercentageAdjustment*percentageCorrection/100d;
+ }
+
if (calculatedTotalInsulin < 0) {
carbsEquivalent = -calculatedTotalInsulin * ic;
diff --git a/app/src/main/java/info/nightscout/utils/NSUpload.java b/app/src/main/java/info/nightscout/utils/NSUpload.java
index 4fa5a0d5e2..aeb1f7181d 100644
--- a/app/src/main/java/info/nightscout/utils/NSUpload.java
+++ b/app/src/main/java/info/nightscout/utils/NSUpload.java
@@ -49,7 +49,6 @@ public class NSUpload {
data.put("pumpId", temporaryBasal.pumpId);
data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
- data.put("notes", MainApp.sResources.getString(R.string.androidaps_tempbasalstartnote) + " " + temporaryBasal.absoluteRate + "u/h " + temporaryBasal.durationInMinutes + " min"); // ECOR
if (originalExtendedAmount != null)
data.put("originalExtendedAmount", originalExtendedAmount); // for back synchronization
Bundle bundle = new Bundle();
@@ -88,7 +87,6 @@ public class NSUpload {
data.put("pumpId", temporaryBasal.pumpId);
data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
- data.put("notes", MainApp.sResources.getString(R.string.androidaps_tempbasalstartnote) + " " + temporaryBasal.percentRate + "% " + temporaryBasal.durationInMinutes + " min"); // ECOR
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments");
@@ -111,7 +109,6 @@ public class NSUpload {
data.put("eventType", CareportalEvent.TEMPBASAL);
data.put("created_at", DateUtil.toISOString(time));
data.put("enteredBy", "openaps://" + MainApp.instance().getString(R.string.app_name));
- data.put("notes", MainApp.sResources.getString(R.string.androidaps_tempbasalendnote)); // ECOR
if (isFakedTempBasal)
data.put("isFakedTempBasal", isFakedTempBasal);
if (pumpId != 0)
diff --git a/app/src/main/res/layout/actions_fragment.xml b/app/src/main/res/layout/actions_fragment.xml
index e24f69124d..bc8f416770 100644
--- a/app/src/main/res/layout/actions_fragment.xml
+++ b/app/src/main/res/layout/actions_fragment.xml
@@ -52,6 +52,19 @@
android:drawableTop="@drawable/icon_actions_starttempbasal"
android:text="@string/overview_tempbasal_button" />
+
+
+ android:layout_height="100dp"
+ android:visibility="gone" />
@@ -385,7 +386,8 @@
android:layout_marginTop="3dp"
android:layout_weight="0.5"
android:text="Accept new temp\n0.25U/h"
- android:textColor="@color/colorAcceptTempButton" />
+ android:textColor="@color/colorAcceptTempButton"
+ android:visibility="gone" />
+ android:textSize="10sp"
+ android:visibility="gone" />
-
-
diff --git a/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml b/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml
index 014f5f5993..10148057bb 100644
--- a/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml
+++ b/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml
@@ -756,20 +756,6 @@
android:textSize="10sp"
android:visibility="gone" />
-
-
diff --git a/app/src/main/res/layout/overview_fragment_smallheight.xml b/app/src/main/res/layout/overview_fragment_smallheight.xml
index eaa632f3b4..e1d2338959 100644
--- a/app/src/main/res/layout/overview_fragment_smallheight.xml
+++ b/app/src/main/res/layout/overview_fragment_smallheight.xml
@@ -433,20 +433,6 @@
android:textSize="10sp"
android:visibility="gone" />
-
-
diff --git a/app/src/main/res/layout/overview_newtempbasal_dialog.xml b/app/src/main/res/layout/overview_newtempbasal_dialog.xml
index 04caae43f4..48c20b6809 100644
--- a/app/src/main/res/layout/overview_newtempbasal_dialog.xml
+++ b/app/src/main/res/layout/overview_newtempbasal_dialog.xml
@@ -12,266 +12,134 @@
android:layout_height="match_parent">
-
+
+
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="vertical">
+ android:text="@string/overview_newtempbasal_percent_label" />
+
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_marginTop="15dp"
+ android:text="@string/overview_newtempbasal_basalpercent"
+ android:textAppearance="@android:style/TextAppearance.Material.Small"
+ android:textStyle="bold" />
-
+
+
+
+
+
-
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
+
diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml
index 460e57d226..8b026dd0b2 100644
--- a/app/src/main/res/values-bg/strings.xml
+++ b/app/src/main/res/values-bg/strings.xml
@@ -3,7 +3,6 @@
Настройки на сигурността
Максимален инсулин при болус [единици]
Максимални въглехидрати [гр]
-
Опции
Обнови леченията от NS
Резервно копие
@@ -77,7 +76,6 @@
Промяна
Delta:
Средна промяна
-
Конфигурация
Цели
OpenAPS MA
@@ -99,7 +97,6 @@
дни
Минимална продължителност
Ограничения
-
Цикъл
Цикъл
APS
@@ -114,7 +111,7 @@
Нарушено ограничение
Грешка при подаване на болус
Грешка при подаване на временен базал
- Стойност на базал
+ Стойност на базал [%]
% (100% = текущ)
Приложи нов временен базал:
Болус
@@ -139,7 +136,6 @@
изключен
Изключи
Включи
-
Има ново предложение
Несъвместима версия на NSClient
Несъвместима версия на Nightscout
@@ -171,7 +167,6 @@
Край на временен базал
Корекция с въглехидрати
OpenAPS спрян
-
Тип събитие
Друго
Глюкомер
@@ -183,7 +178,6 @@
Продължителност
Процент
Абсолютна
- мин
Бележки
Време на събитие
Профил
@@ -219,7 +213,6 @@
Bulgarian
Разбрах
Език
-
DanaR
Свързване
Свързана
@@ -268,7 +261,7 @@
Откажи временна цел
DanaR профил
DIA (Време на действие на инсулина) ч.:
- Продължителност на действие на инсулина
+ Време на действие на инсулина
Неуспешно обноввяване на базалния профил
История
Презареди
@@ -288,12 +281,12 @@
Базален по часове
Болуси
Въглехидрати
- Дневен инсулин
+ Инсулин за деня
Грешки
КЗ
Пълнене
Спиране
- Опитва да се свърже през последните %d с
+ Свързване с помпата за %d сек.
Парола за помпата
Грешна парола за помпата!
Помпата е заета
@@ -336,7 +329,6 @@
Temp basal canceled
Canceling temp basal failed
Uknonwn command or wrong reply
-
Бърз болус
Настройки за бърз болус
Текст на бутона:
@@ -348,7 +340,7 @@
Хранене
Корекция
Korean
- Actions
+ Действия
Стартиран AndroidAPS
NS upload only (изключва синхронизацията)
Само качване на данните в NS. Няма ефект върху данните за КЗ ако локален източник като xDrip е избран. Няма ефект върху профила освен ако не е избран NS-профил.
@@ -363,19 +355,17 @@
Бутон 3
% с който базовият профил ще бъде променен.
Точен брой часове, с които ще бъде изместен профила!
- Изпрати в помпата
+ ИЗПРАТИ КЪМ ПОМПАТА
Единици:
мг/дл
ммол/л
- DIA(продължителност на действие на инсулина):
+ DIA(време на действие на инсулина):
Целеви диапазон:
Редактирай базални стойности
Редактирай Инс. чувствителност
Редактирай Инс./ВХ
Базов профил:
Процентен профил
- край на временен базал
- Старт на временен базал
Диапазон за визуализация
Стойност на линиите за ниска и висока КЗ (mmol/l) за телефона и часовника
Ниска КЗ под
@@ -489,7 +479,7 @@
Спира временен базал
Настойва удължен болус
Спира удължен болус
- Обновява базалите
+ Обновява базални стойности
Спира връзката
Изпълнява
Настойки Виртуална Помпа
@@ -511,13 +501,13 @@
Въведете NS API secret (мин 12 символа)
Име на устройството
Въведете името на телефона
- Ще се използва за полето enteredBy
+ Ще се използва за полето \"Въведено от\"
Изпрати сега
Изчисти опашка
Покажи опашка
Опашка:
Статус:
- пауза
+ Пауза
Възраст на потребителя
Дете
Тийнейджър
@@ -604,8 +594,6 @@
Много стари данни при повече от [мин]
Интервал за autosens [ч]
Брой часове назад за определяне на чувствителността (приемът на въглехидрати е изключен)
- RAT
- do_not_track_profile_switch
Игнорирай събитията от тип Смяна на профил
Всички смени на профила се игнорират и винаги се използва текущия профил
Помпа
@@ -614,8 +602,8 @@
Uploader
Определяне на чувствителност
ЧУВСТВ
- Алгоритъм на Oref0
- Алгоритъм на AAPS
+ чрез Oref0
+ чрез AAPS
Настройки за абсорбция
Максимално време за усвояване на храненето [ч]
Брой часове, за които се очаква храненето да бъде напълно усвоено в организма
@@ -631,11 +619,20 @@
Заключен екран
Закл
Когато включите Autosense feature трябва да въвеждате ВСИЧКИ въглехидрати. В противен случай те ще се изчисляват грешно като повишена чувствителност!!
-
- Алгоритъм на Среднопретеглената стойност
+ чрез Среднопретеглената стойност
OK
Откажи
- трябва да е активно за да изпратя стойностите към помпата!
+ трябва да е активно за да изпрати стойностите към помпата!
Не всички профили са заредени!
Стойностите не са запазени!
+ Изчисти лога
+ неуспешно - моля проверете телефона
+ Недостъпно
+ NSClient няма права за запис. Грешна API secret?
+ Разреши предаване към други приложения (напр. xDrip)
+ Разреши локално предаване на данни
+ Потвърждаване, че КЗ е достъпна в Найтскаут и данните за помпата се качват там
+ Раздели IOB от болус и от базал на часовника
+ Покажи подробен IOB
+ AndroidAPS
diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml
index 9dfb85f9a4..1deda05866 100644
--- a/app/src/main/res/values-cs/strings.xml
+++ b/app/src/main/res/values-cs/strings.xml
@@ -26,7 +26,6 @@
Sacharidy
Čas jídla
Trvání
- min
Zadal
Čas
Inzulín
@@ -116,7 +115,7 @@
Dostupné nové doporučení
Přehled
Kalkulačka
- Hodnota bazálu
+ Hodnota bazálu [%]
% (100% = současný)
Bolus
NS profil
@@ -313,8 +312,6 @@
Korekce
Akce
AndroidAPS restartován
- Dočasný bazál konec
- Dočasný bazál začátek
Prosím restartujte Váš telefon nebo restartujte AndroidAPS z nastavení systému jinak nebudou zaznamenány ladící informace (důležité pro sledování a kontrolu, zda algoritmus pracuje správně)
Bazální profil:
Baterie v pumpě vybitá
@@ -540,4 +537,91 @@
O aplikaci
Chybějící povolení SMS
Italian
+ Čas v hodinách, ve kterém předpokládáme, že všechny sacharidy budou strávené
+ Max. doba absorbce sacharidu [h]
+ Nastavení absorbce sacharidů
+ BAS
+ Krok bolusu
+ Stáří kanyly
+ KAN
+ SACHARIDY & BOLUSY
+ CGM & OPENAPS
+ Stáří inzulínu
+ INZ
+ Trvání [min]
+ Stáří baterie v pumpě
+ BAT
+ PUMPA
+ Výměna baterie pumpy
+ Stáří senzoru
+ SEN
+ COB
+ Detekce citlivosti
+ Všechny profily nenačteny
+ musí být aktivovaný, aby šly poslat hodnoty do pumpy!
+ Hodnoty nejsou uloženy!
+ DanaRv2
+ ODCH
+ Zařízení
+ Ignorovat přepnutí profilu
+ Všechny záznamy přepnutí profilu jsou ignorovány a vždy je použit aktivní profil
+ ProdlouženýBolus
+ hodin
+ I:S chybí. Je použita výchozí hodnota.
+ Chybný profil !!!
+ IOB
+ Senzitivita chybí. Je použita výchozí hodnota.
+ Zámek obrazovky
+ Zámek
+ Zrušit
+ OK
+ Nastavení alarmů
+ Povolit odesílání do ostatních aplikací (jako xDrip)
+ Povolení odesílaní
+ Zakazát nahrávání do NS
+ Všechny data odeslaná do NS jsou zahozena. AAPS je připojen k NS, ale nedělá do něj žádné změny.
+ Vysoká
+ Nízká
+ Zastaralá data
+ Mezní hodnota pro zastaralá data [min]
+ Právě nastaveno na %f
+ Urgetní mezní hodnota pro zastaralá data [min]
+ Urgentně vysoká
+ Urgentně nízká
+ Urgentně zastaralá data
+ Zrušit prodloužený bolus
+ Hodnota bazálu [U/h]
+ Typ bazálu
+ PRE
+ PřepnutíProfilu
+ Pumpa
+ SEN
+ Statusový řádek xDripu (hodinky)
+ Status z xDripu (hodinky)
+ xds
+ EXT
+ Chybí cílový rozsah. Použity výchozí hodnoty.
+ DočasnýBazál
+ DočasnýCíl
+ Oznámení na hodinkách
+ Předávat oznámení jako zprávy do hodinek
+ Přidat BGI do stavové řádky
+ Zobrazovat BGI
+ SENS
+ Ruština
+ Při zapnuté detektci sensitivity nezapomeňte vkládat všechny sacharidy. Jinak budou odchylky mylně vyhodnocovány jako změna sensitivity !!
+ Sensitivita AAPS
+ Sensotivita Oref0
+ Sensitivita vážený průměr
+ OpenAPS
+ OAPS
+ Bluetooth status
+ AKTIVITA & ZPĚTNÁ VAZBA
+ Chybějící bazál v profilu. Použita výchozí hodnota
+ Krok bazálu
+ BAZ
+ Nepodporovaná verze Nightscoutu
+ Uploader
+ UPLD
+ AndroidAPS
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 6fa152a194..702a18ca2a 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -33,7 +33,6 @@
CGM Sensor Start
Absolut
Kohlehydrate
- min
Insulin
Glukose-Art
Ereignis-Typ
@@ -90,7 +89,7 @@
Aktives IOB total:
IOB total:
Basal IOB
- U
+ E
Up
Virtuelle Pumpe
Reservoir
@@ -119,7 +118,7 @@
Benutze extended Bolus für hohe temps (\>200%)>
Pumpen Status verfügbar in NS
% (100% = current)
- Basal Wert
+ Basal Wert [%]
Extended Bolus
Übersicht
Neue Empfehlung verfügbar
@@ -286,7 +285,6 @@
Basalrate:
Basisprofil:
Pumpenbatterie entladen
- Basal Temp Ende
neu laden
Hoch Markierung
Niedrig Markierung
@@ -328,11 +326,10 @@
Telefonnummer ist nicht gültig.
Bitte verwenden Sie nur Ziffern von %1$s - %2$s
Warte auf Pumpe
-
+ Wear
Bitte starte dein Telefon neu oder starte AndroidAPS in den System-Einstellungen neu. Anderenfalls hat AndroidAPS kein logging (wichtig zum Nachverfolgen und Verifizieren, dass der Algorithmus korrekt funktioniert)
Immer das kurze Durchschnitts-Delta statt dem einfachen Delta verwenden
Sinnvoll, wenn die Daten von einer ungefilterten Quelle Signalrauschen haben.
- Basal Temp Anfang
Tagesinsulin-Limit wird erreicht.
BR
Kalibrierung an xDrip gesendet
@@ -357,4 +354,47 @@
Trenne IOB in Bolus- und Basal-IOB auf dem Watchface
Falsches Passwort
Italian
+ Glimp
+ MM640g
+ Zeit in Stunden in der zu erwarten ist, dass alle Kohlenhydrate resorbiert sein werden
+ Maximale Essens-Resorptionszeit [h]
+ Resorptions-Einstellungen
+ Aktivität
+ Erwachsener
+ Erweiter
+ AndroidAPS
+ BAS
+ Basal-Schritt
+ Basal fehlt im Profil. Verwende Standardwert.
+ Basalwert unter dem Minimum. Profil nicht gesetzt!
+ Gerät untertützt anscheinend das deaktivieren der Akku-Leistungsoptimierung nicht.
+ Bolus-Schritt
+ Werde %.2fE abgeben
+ AKTIVITÄT & FEEDBACK
+ Katheter-Liegedauer
+ CAGE
+ CARBS & BOLUS
+ CGM & OPENAPS
+
+ Dauer [min]
+ pausiert
+ Patientenalter
+ Bitte wähle das Pateintenalter um die Sicherheits-Limits festzulegen
+ Ziel fehlt im Profil. Verwende Standardwert.h
+ Teenager
+ TempBasal
+ Tempbasal Abgabe-Fehler
+ TempZiel
+ Zeit in Stunden um die das profil zylindrisch verschoben wird.
+
+ COB
+ Nicht-unterstütze Nightscout-Version
+ Uploader
+ UPLD
+ EXT
+ Firmware
+ Virtuelle Pumpe Einstellungen
+ Status zu NS hochladen
+ Superbolus
+
diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml
index e146ba4571..729b67be9e 100644
--- a/app/src/main/res/values-el/strings.xml
+++ b/app/src/main/res/values-el/strings.xml
@@ -19,4 +19,5 @@
" "
" "
Italian
+ AndroidAPS
\ No newline at end of file
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index cb011f510e..c619bc3322 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -108,7 +108,7 @@
Plugin está desactivado
Violación restricciones
Error de administración del bolo
- Valor basal
+ Valor basal [%]
% (100% = actual)
Aceptar nueva basal temporal:
Bolo
@@ -170,7 +170,6 @@
Duración
Dosis
Absoluto
- min
Notas
Fecha Hora
Perfil
@@ -332,8 +331,6 @@
Comando desconocido o respuesta incorrecta
¡Por favor asegurar que la cantidad coincide con la especificación del set de infusión!
Para iniciar basal %.2fU/h responder con código %s
- Inicio Basal Temporal
- Fin Basal Temporal
" "
" "
" "
@@ -398,4 +395,5 @@
Número de teléfono inválido
Esperando bomba
Italian
+ AndroidAPS
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 48cd17b8a1..0461f4b0fc 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -47,7 +47,6 @@
Tipo di glucosio
Insulina
Glucometro
- Minimo
Note
Altro
Percentuale
@@ -310,7 +309,7 @@
Valido:
Aggiungere
Bolo Esteso
- Valore Basale
+ Valore Basale [%]
Uscire
Eliminare
HOME
@@ -497,5 +496,6 @@
Profilo NS
Profilo Basale aggiornato nel Micro
Impostazione Profilo Basale fallito
+ AndroidAPS
diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml
index be4ded3526..f39c68d957 100644
--- a/app/src/main/res/values-ko/strings.xml
+++ b/app/src/main/res/values-ko/strings.xml
@@ -108,7 +108,7 @@
제한 위반
식사주입 전송 에러
Tempbasal delivery error
- 기초주입 값
+ 기초주입 값 [%]
% (100% = 현재)
새 임시기초주입 적용:
식사주입
@@ -171,7 +171,6 @@
Duration
Percent
Absolute
- min
Notes
Event time
Profile
@@ -358,8 +357,6 @@
Edit Base-IC:
Base Profile:
CircadianPercentageProfile
- Basal Temp End
- Basal Temp Start
차트 표시 범위
Overview/스마트워치 차트 표시용 고/저혈당 선
저혈당 선
@@ -515,4 +512,5 @@
성인
안전제한을 설정하기 위해 당뇨인의 나이를 선택하세요
Italian
+ AndroidAPS
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 7f797ea3a5..ee6f7cf8e9 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -12,8 +12,6 @@
всегда используйте укороченное среднее приращение вместо простого
AndroidAPS запущен
полезно когда данные из нефильтруемых источников вроде Xdrip зашумляются
- конец действия временного базала
- начало действия временного базала
приближается суточный лимит инсулина
режим APS
массив %d элементов. актуальная величина:
@@ -62,7 +60,6 @@
тип глюкозы
инсулин
глюкометр
- минут
заметки
другое
процент
@@ -389,7 +386,7 @@
использовать до:
добавить
расширенный болюс
- величина базала
+ величина базала
% (100% = current)
редактировать
удалить
@@ -430,7 +427,6 @@
перезапуск
выход из приложения для применения настроек
возобновить
- русский
безопасность
сохранить
ОТПРАВИТЬ
@@ -570,4 +566,5 @@
"состояние xdrip (часы) "
xds
разрешенный предел достигнут
+ AndroidAPS
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 2e15c489da..459f671821 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -44,5 +44,4 @@
- @string/key_adult
- Russian
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 262eb38345..fc97ca722d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -114,7 +114,7 @@
Constraints violation
Bolus delivery error
Tempbasal delivery error
- Basal value
+ Basal value [%]
% (100% = current)
Accept new temp basal:
Bolus
@@ -183,7 +183,6 @@
Duration
Percent
Absolute
- min
Notes
Event time
Profile
@@ -375,8 +374,6 @@
Edit Base-IC:
Base Profile:
CircadianPercentageProfile
- Basal Temp End
- Basal Temp Start
Range for Visualization
High and low mark for the charts in Overview and Smartwatch
LOW mark
@@ -649,8 +646,9 @@
Interval for autosens [h]
Amount of hours in the past for sensitivity detection (carbs absorption time is excluded)
openapsama_autosens_period
- RAT
- do_not_track_profile_switch
+ nsclient_localbroadcasts
+ SEN
+ do_not_track_profile_switch
Ignore profile switch events
All profile switch events are ignored and active profile is always used
Pump
@@ -689,11 +687,13 @@
Accu-Chek Combo
Accu-Chek Combo settings
COMBO
- Enable loacal broadcasts to other apps (like xDrip).
+ Enable broadcasts to other apps (like xDrip).
Enable local Broadcasts.
ACTIVITY & FEEDBACK
CARBS & BOLUS
CGM & OPENAPS
PUMP
+ Basal value [U/h]
+ Duration [min]
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
index 7aa663b341..7701b17d25 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
@@ -2,8 +2,10 @@ package info.nightscout.androidaps.interaction.actions;
import android.app.Activity;
+import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.support.wearable.view.DotsPageIndicator;
import android.support.wearable.view.GridPagerAdapter;
import android.support.wearable.view.GridViewPager;
@@ -28,10 +30,13 @@ import info.nightscout.androidaps.interaction.utils.SafeParse;
public class WizardActivity extends ViewSelectorActivity {
PlusMinusEditText editCarbs;
+ PlusMinusEditText editPercentage;
boolean useBG;
boolean includeBolusIOB;
boolean includeBasalIOB;
+ boolean hasPercentage;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -43,6 +48,8 @@ public class WizardActivity extends ViewSelectorActivity {
pager.setAdapter(new MyGridViewPagerAdapter());
DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator);
dotsPageIndicator.setPager(pager);
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
+ hasPercentage = sp.getBoolean("wizardpercentage", false);
}
@@ -56,7 +63,7 @@ public class WizardActivity extends ViewSelectorActivity {
private class MyGridViewPagerAdapter extends GridPagerAdapter {
@Override
public int getColumnCount(int arg0) {
- return 5;
+ return hasPercentage?6:5;
}
@Override
@@ -151,6 +158,17 @@ public class WizardActivity extends ViewSelectorActivity {
});
container.addView(view);
return view;
+ } else if(col == 4 && hasPercentage){
+ final View view = getInflatedPlusMinusView(container);
+ if (editPercentage == null) {
+ editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 50d, 150d, 1d, new DecimalFormat("0"), false);
+ } else {
+ double def = SafeParse.stringToDouble(editPercentage.editText.getText().toString());
+ editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 50d, 150d, 1d, new DecimalFormat("0"), false);
+ }
+ setLabelToPlusMinusView(view, "percentage");
+ container.addView(view);
+ return view;
} else {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
@@ -162,10 +180,15 @@ public class WizardActivity extends ViewSelectorActivity {
//check if it can happen that the fagment is never created that hold data?
// (you have to swipe past them anyways - but still)
+ int percentage = 100;
+
+ if (editPercentage != null) percentage = SafeParse.stringToInt(editPercentage.editText.getText().toString());
+
String actionstring = "wizard " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
+ " " + useBG
+ " " + includeBolusIOB
- + " " + includeBasalIOB;
+ + " " + includeBasalIOB
+ + " " + percentage;
ListenerService.initiateAction(WizardActivity.this, actionstring);
finish();
}
diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml
index b9c6307cac..aa78611b0c 100644
--- a/wear/src/main/res/xml/preferences.xml
+++ b/wear/src/main/res/xml/preferences.xml
@@ -142,4 +142,11 @@
android:title="Single Target"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
+