allow to ignore profileswitch events
This commit is contained in:
parent
c728174858
commit
80962e33d7
4 changed files with 27 additions and 12 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue