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() {
|
||||
MainApp.bus().register(this);
|
||||
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
|
||||
|
|
|
@ -240,7 +240,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
if (insulin > 0 || carbs > 0) {
|
||||
Treatment t = new Treatment();
|
||||
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();
|
||||
result.success = connectionOK;
|
||||
result.bolusDelivered = t.insulin;
|
||||
|
|
|
@ -82,10 +82,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
|
||||
Context parentContext;
|
||||
|
||||
public WizardDialog(Context context) {
|
||||
public WizardDialog() {
|
||||
mHandlerThread = new HandlerThread(WizardDialog.class.getSimpleName());
|
||||
mHandlerThread.start();
|
||||
mHandler = new Handler(mHandlerThread.getLooper());
|
||||
}
|
||||
|
||||
|
||||
public WizardDialog(Context context) {
|
||||
this();
|
||||
parentContext = context;
|
||||
}
|
||||
|
||||
|
@ -120,7 +125,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -192,10 +197,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
||||
|
||||
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || carbsAfterConstraints != calculatedCarbs) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
@ -203,8 +208,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
||||
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(getContext().getString(R.string.confirmation));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||
builder.setMessage(confirmMessage);
|
||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
@ -223,10 +228,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
boluscalcJSON
|
||||
);
|
||||
if (!result.success) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
||||
builder.setMessage(result.comment);
|
||||
builder.setPositiveButton(getContext().getString(R.string.ok), null);
|
||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +258,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
|
||||
ArrayList<CharSequence> profileList;
|
||||
profileList = profile.getProfileList();
|
||||
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
|
||||
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(parentContext,
|
||||
android.R.layout.simple_spinner_item, profileList);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
profileSpinner.setAdapter(adapter);
|
||||
|
|
Loading…
Reference in a new issue