From c015862239f0297ddd23e0b1b3a7649cb82361cd Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 9 Feb 2017 16:04:57 +0100 Subject: [PATCH 1/9] fix crash: not attached to Activity --- .../nightscout/androidaps/plugins/DanaR/DanaRFragment.java | 4 ++-- .../androidaps/plugins/DanaRKorean/DanaRKoreanFragment.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRFragment.java index 787f241612..7c59790e35 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRFragment.java @@ -219,7 +219,7 @@ public class DanaRFragment extends Fragment implements FragmentBase { Long agoMsec = new Date().getTime() - pump.lastBolusTime.getTime(); double agoHours = agoMsec / 60d / 60d / 1000d; if (agoHours < 6) // max 6h back - lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(getPlugin().getDanaRPump().lastBolusAmount) + " U"); + lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(getPlugin().getDanaRPump().lastBolusAmount) + " U"); else lastBolusView.setText(""); } @@ -242,7 +242,7 @@ public class DanaRFragment extends Fragment implements FragmentBase { SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d); iobView.setText(pump.iob + " U"); if (pump.isNewPump) { - firmwareView.setText(String.format(getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode)); + firmwareView.setText(String.format(MainApp.sResources.getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode)); } else { firmwareView.setText("OLD"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanFragment.java index f6778ed5f6..4142b43ff6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanFragment.java @@ -240,7 +240,7 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase { SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d); iobView.setText(pump.iob + " U"); if (pump.isNewPump) { - firmwareView.setText(String.format(getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode)); + firmwareView.setText(String.format(MainApp.sResources.getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode)); } else { firmwareView.setText("OLD"); } From 7f123e4208154943548bce4daa95b76c914d685a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 9 Feb 2017 16:14:09 +0100 Subject: [PATCH 2/9] warn on wrong entered sms phone number --- .../androidaps/plugins/Overview/Notification.java | 1 + .../SmsCommunicator/SmsCommunicatorPlugin.java | 11 +++++++++-- app/src/main/res/values-cs/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java index daa882bd8f..8a7a9b00ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java @@ -21,6 +21,7 @@ public class Notification { public static final int FAILED_UDPATE_PROFILE = 6; public static final int BASAL_VALUE_BELOW_MINIMUM = 7; public static final int OLD_NSCLIENT = 8; + public static final int INVALID_PHONE_NUMBER = 9; public int id; public Date date; 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 21e66a37aa..c072c88b59 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 @@ -31,6 +31,8 @@ import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.data.IobTotal; +import info.nightscout.androidaps.plugins.Overview.Notification; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui; import info.nightscout.client.data.NSProfile; @@ -446,8 +448,13 @@ public class SmsCommunicatorPlugin implements PluginBase { SmsManager smsManager = SmsManager.getDefault(); sms.text = stripAccents(sms.text); if (sms.text.length() > 140) sms.text = sms.text.substring(0, 139); - smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null); - messages.add(sms); + try { + smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null); + messages.add(sms); + } catch (IllegalArgumentException e) { + Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.sResources.getString(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL); + MainApp.bus().post(new EventNewNotification(notification)); + } } private String generatePasscode() { diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 231091bed4..8571acf6cc 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -439,4 +439,6 @@ Profil Krátké názvy modulů Firmware: + Špatné telefonní číslo + Chyba nastavování dočasného bazálu diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5d1991276e..b9a049a119 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -453,4 +453,5 @@ Firmware: Model: %02X Protocol: %02X Code: %02X Profile + Invalid SMS phone number From 3d3e849d8a0ab95d68e1504d34eef33da9f6595a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 9 Feb 2017 16:23:28 +0100 Subject: [PATCH 3/9] fix null pointer exception in persistentnotification --- .../PersistentNotificationPlugin.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/persistentnotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/persistentnotification/PersistentNotificationPlugin.java index 54b4070bed..31e369889d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/persistentnotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/persistentnotification/PersistentNotificationPlugin.java @@ -113,14 +113,14 @@ public class PersistentNotificationPlugin implements PluginBase{ if(profile != null && lastBG != null) { line1 = lastBG.valueToUnitsToString(profile.getUnits()); - } - if (glucoseStatus != null) { - line1 += " Δ" + deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, profile.getUnits()) - + " avgΔ" + deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, profile.getUnits()); - } else { - line1 += " " + - ctx.getString(R.string.old_data) + - " "; + if (glucoseStatus != null) { + line1 += " Δ" + deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, profile.getUnits()) + + " avgΔ" + deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, profile.getUnits()); + } else { + line1 += " " + + ctx.getString(R.string.old_data) + + " "; + } } PumpInterface pump = MainApp.getConfigBuilder(); From b9b08c15288d3c4a3a0722402f4ffe8ed4d177a7 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 9 Feb 2017 16:29:02 +0100 Subject: [PATCH 4/9] fix crash when pump status not loaded yet --- .../info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java | 2 ++ .../androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java index 577e1d3bcf..791e7a0c8d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java @@ -258,6 +258,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf if (!isInitialized()) return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS DanaRPump pump = getDanaRPump(); + if (pump.pumpProfiles == null) + return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS int basalValues = pump.basal48Enable ? 48 : 24; int basalIncrement = pump.basal48Enable ? 30 * 60 : 60 * 60; for (int h = 0; h < basalValues; h++) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java index e5b40a60a5..78c42a0f2e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java @@ -258,6 +258,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints if (!isInitialized()) return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS DanaRKoreanPump pump = getDanaRPump(); + if (pump.pumpProfiles == null) + return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS int basalValues = pump.basal48Enable ? 48 : 24; int basalIncrement = pump.basal48Enable ? 30 * 60 : 60 * 60; for (int h = 0; h < basalValues; h++) { From caa109dbfd7c5863accf2cf41df5adba2facd09c Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 9 Feb 2017 16:32:44 +0100 Subject: [PATCH 5/9] use SafeParse in DanaRStartsActivity --- .../androidaps/plugins/DanaR/History/DanaRStatsActivity.java | 3 ++- .../plugins/DanaRKorean/History/DanaRStatsActivity.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/History/DanaRStatsActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/History/DanaRStatsActivity.java index 4e75c4c999..1ded51f982 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/History/DanaRStatsActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/History/DanaRStatsActivity.java @@ -56,6 +56,7 @@ import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus; import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.SafeParse; import info.nightscout.utils.ToastUtils; public class DanaRStatsActivity extends Activity { @@ -366,7 +367,7 @@ public class DanaRStatsActivity extends Activity { return; } else { - magicNumber = Double.parseDouble(TBB); + magicNumber = SafeParse.stringToDouble(TBB); } magicNumber *=2; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/History/DanaRStatsActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/History/DanaRStatsActivity.java index bf7a7c4321..995924b9c7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/History/DanaRStatsActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/History/DanaRStatsActivity.java @@ -56,6 +56,7 @@ import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatu import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus; import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.SafeParse; import info.nightscout.utils.ToastUtils; public class DanaRStatsActivity extends Activity { @@ -366,7 +367,7 @@ public class DanaRStatsActivity extends Activity { return; } else { - magicNumber = Double.parseDouble(TBB); + magicNumber = SafeParse.stringToDouble(TBB); } magicNumber *=2; From a39416d876b5cc17199f37cceb05b049e5cc4eeb Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 9 Feb 2017 16:39:07 +0100 Subject: [PATCH 6/9] fix nullpointerexception in reading temp basal status --- .../nightscout/androidaps/plugins/DanaR/DanaRPlugin.java | 9 +++++---- .../plugins/DanaRKorean/DanaRKoreanPlugin.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java index 791e7a0c8d..7e91f86cbe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java @@ -709,11 +709,12 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf extended.put("PumpIOB", getDanaRPump().iob); extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString()); extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount); - if (isTempBasalInProgress()) { + TempBasal tb = getTempBasal(); + if (tb != null) { extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate()); - extended.put("TempBasalStart", getTempBasal().timeStart.toLocaleString()); - extended.put("TempBasalRemaining", getTempBasal().getPlannedRemainingMinutes()); - extended.put("IsExtended", getTempBasal().isExtended); + extended.put("TempBasalStart", tb.timeStart.toLocaleString()); + extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); + extended.put("IsExtended", tb.isExtended); } extended.put("BaseBasalRate", getBaseBasalRate()); try { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java index 78c42a0f2e..c3784d80e4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java @@ -709,11 +709,12 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints extended.put("PumpIOB", getDanaRPump().iob); // extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString()); // extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount); - if (isTempBasalInProgress()) { + TempBasal tb = getTempBasal(); + if (tb != null) { extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate()); - extended.put("TempBasalStart", getTempBasal().timeStart.toLocaleString()); - extended.put("TempBasalRemaining", getTempBasal().getPlannedRemainingMinutes()); - extended.put("IsExtended", getTempBasal().isExtended); + extended.put("TempBasalStart", tb.timeStart.toLocaleString()); + extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); + extended.put("IsExtended", tb.isExtended); } extended.put("BaseBasalRate", getBaseBasalRate()); try { From 806cc4a3a780152970785f2eb72aa3dfd3a80acb Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 9 Feb 2017 16:43:27 +0100 Subject: [PATCH 7/9] fix nullpointerexception in reading temp basal status --- .../androidaps/plugins/DanaR/DanaRPlugin.java | 14 ++++++++------ .../plugins/DanaRKorean/DanaRKoreanPlugin.java | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java index 7e91f86cbe..f2fa7909c7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java @@ -292,17 +292,19 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf @Override public double getTempBasalAbsoluteRate() { - if (isRealTempBasalInProgress()) { - if (getRealTempBasal().isAbsolute) { - return getRealTempBasal().absolute; + TempBasal tb = getRealTempBasal(); + if (tb != null) { + if (tb.isAbsolute) { + return tb.absolute; } else { Double baseRate = getBaseBasalRate(); - Double tempRate = baseRate * (getRealTempBasal().percent / 100d); + Double tempRate = baseRate * (tb.percent / 100d); return tempRate; } } - if (isExtendedBoluslInProgress() && useExtendedBoluses) { - return getBaseBasalRate() + getExtendedBolus().absolute; + TempBasal eb = getExtendedBolus(); + if (eb != null && useExtendedBoluses) { + return getBaseBasalRate() + eb.absolute; } return 0; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java index c3784d80e4..1b3aced79e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java @@ -292,17 +292,19 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints @Override public double getTempBasalAbsoluteRate() { - if (isRealTempBasalInProgress()) { - if (getRealTempBasal().isAbsolute) { - return getRealTempBasal().absolute; + TempBasal tb = getRealTempBasal(); + if (tb != null) { + if (tb.isAbsolute) { + return tb.absolute; } else { Double baseRate = getBaseBasalRate(); - Double tempRate = baseRate * (getRealTempBasal().percent / 100d); + Double tempRate = baseRate * (tb.percent / 100d); return tempRate; } } - if (isExtendedBoluslInProgress() && useExtendedBoluses) { - return getBaseBasalRate() + getExtendedBolus().absolute; + TempBasal eb = getExtendedBolus(); + if (eb != null && useExtendedBoluses) { + return getBaseBasalRate() + eb.absolute; } return 0; } From 3aff89acdcabf9b7e6bde2c9380f668688e1997e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 9 Feb 2017 16:45:54 +0100 Subject: [PATCH 8/9] fix not attached to activity in bolus progress dialog --- .../plugins/Overview/Dialogs/BolusProgressDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java index 537613b9e2..2078e5e2e8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java @@ -124,7 +124,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL @Override public void run() { if (c.sStatus == c.CONNECTING) { - statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed)); + statusView.setText(String.format(MainApp.sResources.getString(R.string.danar_history_connectingfor), c.sSecondsElapsed)); } else if (c.sStatus == c.CONNECTED) { statusView.setText(MainApp.sResources.getString(R.string.connected)); } else { From 9e9637d70b1974fe3517f030930860c7f6bd627f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 9 Feb 2017 16:51:14 +0100 Subject: [PATCH 9/9] accept temp button visible only if loop selected --- .../androidaps/plugins/Overview/OverviewFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index e36bac93b7..2c80489033 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 @@ -237,7 +237,7 @@ public class OverviewFragment extends Fragment { acceptTempButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - MainApp.getConfigBuilder().getActiveLoop().invoke("Accept temp button", false); + ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false); final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun; if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.changeRequested) { AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); @@ -564,7 +564,7 @@ public class OverviewFragment extends Fragment { showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.changeRequested; // change is requested - if (showAcceptButton && pump.isInitialized()) { + if (showAcceptButton && pump.isInitialized() && ConfigBuilderPlugin.getActiveLoop() != null) { acceptTempLayout.setVisibility(View.VISIBLE); acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed); } else {