From 4fe06e4ee139058d9910b9f8bb82b1c43fc3df02 Mon Sep 17 00:00:00 2001 From: viktoria Date: Mon, 9 Jan 2017 02:28:27 +0100 Subject: [PATCH] refactor cpp add safety values to constans class --- .../main/java/info/nightscout/androidaps/Constants.java | 4 ++++ .../CircadianPercentageProfilePlugin.java | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Constants.java b/app/src/main/java/info/nightscout/androidaps/Constants.java index 6cd7c764dd..4662178d71 100644 --- a/app/src/main/java/info/nightscout/androidaps/Constants.java +++ b/app/src/main/java/info/nightscout/androidaps/Constants.java @@ -25,4 +25,8 @@ public class Constants { public static final long keepAliveMsecs = 5 * 60 * 1000L; public static final long remoteBolusMinDistance = 15 * 60 * 1000L; + + // Circadian Percentage Profile + public static final int CPP_MIN_PERCENTAGE = 50; + public static final int CPP_MAX_PERCENTAGE = 200; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java index 274e1a941d..019c1b9677 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfilePlugin.java @@ -15,7 +15,6 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.ProfileInterface; -import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin; import info.nightscout.client.data.NSProfile; import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.SafeParse; @@ -27,8 +26,6 @@ import info.nightscout.utils.ToastUtils; */ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInterface { public static final String SETTINGS_PREFIX = "CircadianPercentageProfile"; - public static final int MIN_PERCENTAGE = 50; - public static final int MAX_PERCENTAGE = 200; private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfilePlugin.class); private static boolean fragmentEnabled = true; @@ -262,13 +259,13 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte } private void performLimitCheck() { - if (percentage < MIN_PERCENTAGE || percentage > MAX_PERCENTAGE){ + if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE){ String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage"); log.error(msg); MainApp.getConfigBuilder().uploadError(msg); ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error); - percentage = Math.max(percentage, MIN_PERCENTAGE); - percentage = Math.min(percentage, MAX_PERCENTAGE); + percentage = Math.max(percentage, Constants.CPP_MIN_PERCENTAGE); + percentage = Math.min(percentage, Constants.CPP_MAX_PERCENTAGE); } }