Adhere to 'Sync to profile' setting in ConfigBuilder.

This commit is contained in:
Johannes Mockenhaupt 2017-11-25 02:09:58 +01:00
parent ac935b19de
commit b148b334b2
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
6 changed files with 8 additions and 52 deletions

View file

@ -385,6 +385,10 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
@Override @Override
public int setNewBasalProfile(Profile profile) { public int setNewBasalProfile(Profile profile) {
if (!SP.getBoolean(R.string.key_sync_profile_to_pump, false)) {
return NOT_NEEDED;
}
// Compare with pump limits // Compare with pump limits
Profile.BasalValue[] basalValues = profile.getBasalValues(); Profile.BasalValue[] basalValues = profile.getBasalValues();

View file

@ -169,55 +169,6 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
createConvertedProfile(); createConvertedProfile();
} }
public String externallySetParameters(int timeshift, int percentage) {
String msg = "";
if (!fragmentEnabled){
msg+= "NO CPP!" + "\n";
}
//check for validity
if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) {
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage") + "\n";
}
if (timeshift < 0 || timeshift > 23) {
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
}
if(!SP.getBoolean("syncprofiletopump", false)){
msg+= MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n";
}
final PumpInterface pump = MainApp.getConfigBuilder();
final Profile profile = MainApp.getConfigBuilder().getProfile();
if (pump == null || profile == null || profile.getBasal() == null){
msg+= MainApp.sResources.getString(R.string.cpp_notloadedplugins) + "\n";
}
if(!"".equals(msg)) {
msg += MainApp.sResources.getString(R.string.cpp_valuesnotstored);
return msg;
}
//store profile
this.timeshift= timeshift;
this.percentage = percentage;
storeSettings();
//send profile to pumpe
new NewNSTreatmentDialog(); //init
NewNSTreatmentDialog.doProfileSwitch(this.getProfile(), this.getProfileName(), 0, percentage, timeshift);
//return formatted string
/*msg += "%: " + this.percentage + " h: +" + this.timeshift;
msg += "\n";
msg += "\nBasal:\n" + basalString() + "\n";
msg += "\nISF:\n" + isfString() + "\n";
msg += "\nIC:\n" + isfString() + "\n";*/
return msg;
}
public static void migrateToLP(){ public static void migrateToLP(){
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();

View file

@ -120,7 +120,7 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
storeNSProfile(); storeNSProfile();
MainApp.bus().post(new EventNSProfileUpdateGUI()); MainApp.bus().post(new EventNSProfileUpdateGUI());
PumpInterface pump = MainApp.getConfigBuilder(); PumpInterface pump = MainApp.getConfigBuilder();
if (SP.getBoolean("syncprofiletopump", false)) { if (SP.getBoolean(R.string.key_sync_profile_to_pump, false)) {
if (pump.setNewBasalProfile(MainApp.getConfigBuilder().getProfile()) == PumpInterface.SUCCESS) { if (pump.setNewBasalProfile(MainApp.getConfigBuilder().getProfile()) == PumpInterface.SUCCESS) {
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class); SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) { if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {

View file

@ -583,7 +583,7 @@ public class ActionStringHandler {
if (timeshift < 0 || timeshift > 23) { if (timeshift < 0 || timeshift > 23) {
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n"; msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
} }
if(!SP.getBoolean("syncprofiletopump", false)){ if(!SP.getBoolean(R.string.key_sync_profile_to_pump, false)){
msg+= MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n"; msg+= MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n";
} }
final PumpInterface pump = MainApp.getConfigBuilder(); final PumpInterface pump = MainApp.getConfigBuilder();

View file

@ -89,7 +89,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
MainApp.bus().post(new EventNewNotification(n)); MainApp.bus().post(new EventNewNotification(n));
} }
if (SP.getBoolean("syncprofiletopump", false) && !pump.isThisProfileSet(profile)) { if (SP.getBoolean(MainApp.sResources.getString(R.string.key_sync_profile_to_pump), false) && !pump.isThisProfileSet(profile)) {
Thread t = new Thread(new Runnable() { Thread t = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {

View file

@ -816,5 +816,6 @@
<string name="info">INFO</string> <string name="info">INFO</string>
<string name="combo_empty_alert_history_note">To retrieve the alert history from the pump, long press the Refresh button.</string> <string name="combo_empty_alert_history_note">To retrieve the alert history from the pump, long press the Refresh button.</string>
<string name="combo_empty_tdd_history_note">To retrieve the TDD history from the pump, long press the Refresh button.</string> <string name="combo_empty_tdd_history_note">To retrieve the TDD history from the pump, long press the Refresh button.</string>
<string name="key_sync_profile_to_pump">sync_profile_to_pump</string>
</resources> </resources>