change to screen lock, better context handling
This commit is contained in:
parent
9c3b8dc2b9
commit
be8c1c2a83
3 changed files with 18 additions and 13 deletions
|
@ -76,7 +76,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
public ConfigBuilderPlugin() {
|
public ConfigBuilderPlugin() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
||||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ConfigBuilderPlugin");;
|
mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "ConfigBuilderPlugin");;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -240,7 +240,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
if (insulin > 0 || carbs > 0) {
|
if (insulin > 0 || carbs > 0) {
|
||||||
Treatment t = new Treatment();
|
Treatment t = new Treatment();
|
||||||
boolean connectionOK = false;
|
boolean connectionOK = false;
|
||||||
if (insulin > 0) connectionOK = sExecutionService.bolus(insulin, carbs, t);
|
if (insulin > 0 || carbs > 0) connectionOK = sExecutionService.bolus(insulin, carbs, t);
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = connectionOK;
|
result.success = connectionOK;
|
||||||
result.bolusDelivered = t.insulin;
|
result.bolusDelivered = t.insulin;
|
||||||
|
|
|
@ -82,10 +82,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
Context parentContext;
|
Context parentContext;
|
||||||
|
|
||||||
public WizardDialog(Context context) {
|
public WizardDialog() {
|
||||||
mHandlerThread = new HandlerThread(WizardDialog.class.getSimpleName());
|
mHandlerThread = new HandlerThread(WizardDialog.class.getSimpleName());
|
||||||
mHandlerThread.start();
|
mHandlerThread.start();
|
||||||
mHandler = new Handler(mHandlerThread.getLooper());
|
mHandler = new Handler(mHandlerThread.getLooper());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public WizardDialog(Context context) {
|
||||||
|
this();
|
||||||
parentContext = context;
|
parentContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +125,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
ToastUtils.showToastInUiThread(getContext(), MainApp.sResources.getString(R.string.noprofileselected));
|
ToastUtils.showToastInUiThread(parentContext, MainApp.sResources.getString(R.string.noprofileselected));
|
||||||
wizardDialogDeliverButton.setVisibility(View.GONE);
|
wizardDialogDeliverButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -192,10 +197,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
||||||
|
|
||||||
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || carbsAfterConstraints != calculatedCarbs) {
|
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || carbsAfterConstraints != calculatedCarbs) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||||
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
|
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
||||||
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
|
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
|
||||||
builder.setPositiveButton(getContext().getString(R.string.ok), null);
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
||||||
builder.show();
|
builder.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -203,8 +208,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
||||||
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||||
builder.setTitle(getContext().getString(R.string.confirmation));
|
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||||
builder.setMessage(confirmMessage);
|
builder.setMessage(confirmMessage);
|
||||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
@ -223,10 +228,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
boluscalcJSON
|
boluscalcJSON
|
||||||
);
|
);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||||
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
|
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
||||||
builder.setMessage(result.comment);
|
builder.setMessage(result.comment);
|
||||||
builder.setPositiveButton(getContext().getString(R.string.ok), null);
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,7 +258,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
ArrayList<CharSequence> profileList;
|
ArrayList<CharSequence> profileList;
|
||||||
profileList = profile.getProfileList();
|
profileList = profile.getProfileList();
|
||||||
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
|
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(parentContext,
|
||||||
android.R.layout.simple_spinner_item, profileList);
|
android.R.layout.simple_spinner_item, profileList);
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
profileSpinner.setAdapter(adapter);
|
profileSpinner.setAdapter(adapter);
|
||||||
|
|
Loading…
Reference in a new issue