stop extended bolus in actions
This commit is contained in:
parent
2ae30fe9b4
commit
86af9eab3d
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.Actions;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -10,13 +12,21 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
||||
import info.nightscout.androidaps.plugins.Actions.dialogs.NewExtendedBolusDialog;
|
||||
import info.nightscout.androidaps.plugins.Actions.dialogs.NewTempBasalDialog;
|
||||
|
@ -38,10 +48,20 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
Button profileSwitch;
|
||||
Button tempTarget;
|
||||
Button extendedBolus;
|
||||
Button extendedBolusCancel;
|
||||
Button tempBasal;
|
||||
Button fill;
|
||||
|
||||
private static Handler sHandler;
|
||||
private static HandlerThread sHandlerThread;
|
||||
|
||||
public ActionsFragment() {
|
||||
super();
|
||||
if (sHandlerThread == null) {
|
||||
sHandlerThread = new HandlerThread(ActionsFragment.class.getSimpleName());
|
||||
sHandlerThread.start();
|
||||
sHandler = new Handler(sHandlerThread.getLooper());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,12 +73,14 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
profileSwitch = (Button) view.findViewById(R.id.actions_profileswitch);
|
||||
tempTarget = (Button) view.findViewById(R.id.actions_temptarget);
|
||||
extendedBolus = (Button) view.findViewById(R.id.actions_extendedbolus);
|
||||
extendedBolusCancel = (Button) view.findViewById(R.id.actions_extendedbolus_cancel);
|
||||
tempBasal = (Button) view.findViewById(R.id.actions_settempbasal);
|
||||
fill = (Button) view.findViewById(R.id.actions_fill);
|
||||
|
||||
profileSwitch.setOnClickListener(this);
|
||||
tempTarget.setOnClickListener(this);
|
||||
extendedBolus.setOnClickListener(this);
|
||||
extendedBolusCancel.setOnClickListener(this);
|
||||
tempBasal.setOnClickListener(this);
|
||||
fill.setOnClickListener(this);
|
||||
|
||||
|
@ -91,6 +113,16 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
updateGUIIfVisible();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
||||
updateGUIIfVisible();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
||||
updateGUIIfVisible();
|
||||
}
|
||||
|
||||
void updateGUIIfVisible() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
|
@ -101,11 +133,19 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
profileSwitch.setVisibility(View.GONE);
|
||||
else
|
||||
profileSwitch.setVisibility(View.VISIBLE);
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended())
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isExtendedBoluslInProgress())
|
||||
extendedBolus.setVisibility(View.GONE);
|
||||
else
|
||||
else {
|
||||
extendedBolus.setVisibility(View.VISIBLE);
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended())
|
||||
}
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isExtendedBoluslInProgress())
|
||||
extendedBolusCancel.setVisibility(View.GONE);
|
||||
else {
|
||||
extendedBolusCancel.setVisibility(View.VISIBLE);
|
||||
ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime());
|
||||
extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString());
|
||||
}
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isTempBasalInProgress())
|
||||
tempBasal.setVisibility(View.GONE);
|
||||
else
|
||||
tempBasal.setVisibility(View.VISIBLE);
|
||||
|
@ -125,6 +165,7 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
FragmentManager manager = getFragmentManager();
|
||||
final PumpInterface pump = MainApp.getConfigBuilder();
|
||||
switch (view.getId()) {
|
||||
case R.id.actions_profileswitch:
|
||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
|
@ -144,6 +185,17 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
NewExtendedBolusDialog newExtendedDialog = new NewExtendedBolusDialog();
|
||||
newExtendedDialog.show(manager, "NewExtendedDialog");
|
||||
break;
|
||||
case R.id.actions_extendedbolus_cancel:
|
||||
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pump.cancelExtendedBolus();
|
||||
Answers.getInstance().logCustom(new CustomEvent("CancelExtended"));
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case R.id.actions_settempbasal:
|
||||
NewTempBasalDialog newTempDialog = new NewTempBasalDialog();
|
||||
newTempDialog.show(manager, "NewTempDialog");
|
||||
|
@ -153,12 +205,26 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
fillDialog.show(manager, "FillDialog");
|
||||
break;
|
||||
case R.id.actions_50_30:
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DanaRv2Plugin danaRv2Plugin = (DanaRv2Plugin) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||
danaRv2Plugin.setHighTempBasalPercent(50);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case R.id.actions_400_15:
|
||||
danaRv2Plugin = (DanaRv2Plugin) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DanaRv2Plugin danaRv2Plugin = (DanaRv2Plugin) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||
danaRv2Plugin.setHighTempBasalPercent(400);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,8 +232,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
treatmentButton.setOnClickListener(this);
|
||||
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
|
||||
wizardButton.setOnClickListener(this);
|
||||
cancelTempButton = (Button) view.findViewById(R.id.overview_canceltempbutton);
|
||||
cancelTempButton.setOnClickListener(this);
|
||||
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
|
||||
acceptTempButton.setOnClickListener(this);
|
||||
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton);
|
||||
|
|
|
@ -65,6 +65,19 @@
|
|||
android:text="@string/overview_extendedbolus_button"
|
||||
android:textColor="@color/colorSetExtendedButton" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/actions_extendedbolus_cancel"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_weight="0.5"
|
||||
android:text="@string/overview_extendedbolus_cancel_button"
|
||||
android:textColor="@color/colorSetExtendedButton" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/actions_fill"
|
||||
style="?android:attr/buttonStyle"
|
||||
|
|
|
@ -614,4 +614,5 @@
|
|||
<string name="bolus_step">Bolus Step</string>
|
||||
<string name="extendedbolus">ExtendedBolus</string>
|
||||
<string name="temptarget">TempTarget</string>
|
||||
<string name="overview_extendedbolus_cancel_button">Cancel Extended Bolus</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue