fix percentage/shift from watch

This commit is contained in:
AdrianLxM 2017-10-10 21:51:58 +02:00
parent b60ff8ceef
commit 549b72b032
2 changed files with 4 additions and 3 deletions

View file

@ -322,7 +322,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false); editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
editPercentage = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentage); editPercentage = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentage);
editPercentage.setParams(100d, (double) Constants.CPP_MIN_PERCENTAGE, (double) Constants.CPP_MAX_PERCENTAGE, 5d, new DecimalFormat("0"), false); editPercentage.setParams(100d, (double) Constants.CPP_MIN_PERCENTAGE, (double) Constants.CPP_MAX_PERCENTAGE, 1d, new DecimalFormat("0"), false);
editTimeshift = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_timeshift); editTimeshift = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_timeshift);
editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false); editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false);
@ -722,7 +722,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
@Override @Override
public void run() { public void run() {
ProfileSwitch profileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis()); ProfileSwitch profileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
if (profileSwitch == null) { if (profileSwitch != null) {
profileSwitch = new ProfileSwitch(); profileSwitch = new ProfileSwitch();
profileSwitch.date = System.currentTimeMillis(); profileSwitch.date = System.currentTimeMillis();
profileSwitch.source = Source.USER; profileSwitch.source = Source.USER;

View file

@ -565,7 +565,7 @@ public class ActionStringHandler {
} else if ("cppset".equals(act[0])) { } else if ("cppset".equals(act[0])) {
int timeshift = SafeParse.stringToInt(act[1]); int timeshift = SafeParse.stringToInt(act[1]);
int percentage = SafeParse.stringToInt(act[2]); int percentage = SafeParse.stringToInt(act[2]);
setCPP(percentage, timeshift); setCPP(timeshift, percentage);
} else if ("dismissoverviewnotification".equals(act[0])){ } else if ("dismissoverviewnotification".equals(act[0])){
MainApp.bus().post(new EventDismissNotification(SafeParse.stringToInt(act[1]))); MainApp.bus().post(new EventDismissNotification(SafeParse.stringToInt(act[1])));
} }
@ -576,6 +576,7 @@ public class ActionStringHandler {
String msg = ""; String msg = "";
//check for validity //check for validity
if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) { if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) {
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage") + "\n"; msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage") + "\n";