allow to ignore profileswitch events

This commit is contained in:
Milos Kozak 2017-06-20 19:52:46 +02:00
parent c728174858
commit 80962e33d7
4 changed files with 27 additions and 12 deletions

View file

@ -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);

View file

@ -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,11 +1015,13 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
public Profile getProfile(long time) {
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
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){
} else if (activeProfile.getProfile() != null) {
Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName);
if (profile != null)
return profile;
@ -1027,6 +1030,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
// 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;

View file

@ -650,4 +650,7 @@
<string name="openapsama_autosens_period_summary">Amount of hours in the past for sensitivity detection (carbs absorption time is excluded)</string>
<string name="key_openapsama_autosens_period" translatable="false">openapsama_autosens_period</string>
<string name="ratio_short">RAT</string>
<string name="key_do_not_track_profile_switch">do_not_track_profile_switch</string>
<string name="do_not_track_profile_switch">Ignore profile switch events</string>
<string name="do_not_track_profile_switch_summary">All profile switch events are ignoreg and active profile is always used</string>
</resources>

View file

@ -128,6 +128,14 @@
android:dialogMessage="@string/openapsama_min_5m_carbimpact_summary"
android:key="openapsama_min_5m_carbimpact" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/profile">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_do_not_track_profile_switch"
android:title="@string/do_not_track_profile_switch"
android:summary="@string/do_not_track_profile_switch_summary"/>
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>