From 80962e33d774a57652b49d27e69f288823564bed Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 20 Jun 2017 19:52:46 +0200 Subject: [PATCH] allow to ignore profileswitch events --- .../androidaps/PreferencesActivity.java | 2 +- .../ConfigBuilder/ConfigBuilderPlugin.java | 26 +++++++++++-------- app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/pref_advanced.xml | 8 ++++++ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java index fa19e9b596..43bfb53c79 100644 --- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java @@ -134,8 +134,8 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre addPreferencesFromResource(R.xml.pref_smscommunicator); if (Config.ALLPREFERENCES) { addPreferencesFromResource(R.xml.pref_others); - addPreferencesFromResource(R.xml.pref_advanced); } + addPreferencesFromResource(R.xml.pref_advanced); if (Config.WEAR) { WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class); 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 6a18084b5e..ef33baf910 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 @@ -50,6 +50,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotificati import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.utils.NSUpload; +import info.nightscout.utils.SP; /** * Created by mike on 05.08.2016. @@ -1014,19 +1015,22 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain public Profile getProfile(long time) { //log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time)); - ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time); - if (profileSwitch != null) { - if (profileSwitch.profileJson != null) { - return profileSwitch.getProfileObject(); - } else if (activeProfile.getProfile() != null){ - Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName); - if (profile != null) - return profile; + boolean ignoreProfileSwitchEvents = SP.getBoolean(R.string.key_do_not_track_profile_switch, false); + if (!ignoreProfileSwitchEvents) { + ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time); + if (profileSwitch != null) { + if (profileSwitch.profileJson != null) { + return profileSwitch.getProfileObject(); + } else if (activeProfile.getProfile() != null) { + Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName); + if (profile != null) + return profile; + } } + // Unable to determine profile, failover to default + if (activeProfile.getProfile() == null) + return null; //app not initialized } - // Unable to determine profile, failover to default - if (activeProfile.getProfile() == null) - return null; //app not initialized Profile defaultProfile = activeProfile.getProfile().getDefaultProfile(); if (defaultProfile != null) return defaultProfile; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8787b618b4..abacb4c18b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -650,4 +650,7 @@ Amount of hours in the past for sensitivity detection (carbs absorption time is excluded) openapsama_autosens_period RAT + do_not_track_profile_switch + Ignore profile switch events + All profile switch events are ignoreg and active profile is always used diff --git a/app/src/main/res/xml/pref_advanced.xml b/app/src/main/res/xml/pref_advanced.xml index 05898654fe..a511327577 100644 --- a/app/src/main/res/xml/pref_advanced.xml +++ b/app/src/main/res/xml/pref_advanced.xml @@ -128,6 +128,14 @@ android:dialogMessage="@string/openapsama_min_5m_carbimpact_summary" android:key="openapsama_min_5m_carbimpact" /> + + +