use absolute in upload based on preference
This commit is contained in:
parent
efa2944c4c
commit
ae1a4b38dd
1 changed files with 25 additions and 19 deletions
|
@ -374,7 +374,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
request.rate = applyBasalConstraints(request.rate);
|
||||
PumpEnactResult result;
|
||||
|
||||
if (request.rate == getBaseBasalRate()) {
|
||||
if (Math.abs(request.rate - getBaseBasalRate()) < 0.1) {
|
||||
if (isTempBasalInProgress()) {
|
||||
result = cancelTempBasal();
|
||||
} else {
|
||||
|
@ -385,7 +385,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
result.comment = "Basal set correctly";
|
||||
result.success = true;
|
||||
}
|
||||
} else if (isTempBasalInProgress() && Math.abs(request.rate - getTempBasalAbsoluteRate()) < 0.05) {
|
||||
} else if (isTempBasalInProgress() && Math.abs(request.rate - getTempBasalAbsoluteRate()) < 0.1) {
|
||||
result = new PumpEnactResult();
|
||||
result.absolute = getTempBasalAbsoluteRate();
|
||||
result.duration = activePump.getTempBasal().getPlannedRemainingMinutes();
|
||||
|
@ -863,7 +863,12 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
|
||||
public static void uploadTempBasalStartPercent(Integer percent, double durationInMinutes) {
|
||||
try {
|
||||
// TODO: upload as absolute if in settings
|
||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
boolean useAbsolute = SP.getBoolean("ns_sync_use_absolute", false);
|
||||
if (useAbsolute) {
|
||||
double absolute = MainApp.getConfigBuilder().getActivePump().getBaseBasalRate() * percent / 100d;
|
||||
uploadTempBasalStartAbsolute(absolute, durationInMinutes);
|
||||
} else {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("eventType", "Temp Basal");
|
||||
|
@ -880,6 +885,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
DbLogger.dbAdd(intent, data.toString(), ConfigBuilderFragment.class);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue