diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java index b62674c5ae..5a8b7017fa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java @@ -20,6 +20,7 @@ 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.db.TemporaryBasal; import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventRefreshOverview; @@ -49,6 +50,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL Button extendedBolus; Button extendedBolusCancel; Button tempBasal; + Button tempBasalCancel; Button fill; private static Handler sHandler; @@ -74,6 +76,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL 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); + tempBasalCancel = (Button) view.findViewById(R.id.actions_canceltempbasal); fill = (Button) view.findViewById(R.id.actions_fill); profileSwitch.setOnClickListener(this); @@ -81,6 +84,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL extendedBolus.setOnClickListener(this); extendedBolusCancel.setOnClickListener(this); tempBasal.setOnClickListener(this); + tempBasalCancel.setOnClickListener(this); fill.setOnClickListener(this); updateGUI(); @@ -114,33 +118,59 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL activity.runOnUiThread(new Runnable() { @Override public void run() { - if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() == null) + if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() == null) { + tempTarget.setVisibility(View.GONE); + profileSwitch.setVisibility(View.GONE); + extendedBolus.setVisibility(View.GONE); + extendedBolusCancel.setVisibility(View.GONE); + tempBasal.setVisibility(View.GONE); + tempBasalCancel.setVisibility(View.GONE); + fill.setVisibility(View.GONE); return; + } boolean allowProfileSwitch = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile().getProfileList().size() > 1; if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !allowProfileSwitch) profileSwitch.setVisibility(View.GONE); else profileSwitch.setVisibility(View.VISIBLE); - if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() || MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) + + + if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) { extendedBolus.setVisibility(View.GONE); - else { - extendedBolus.setVisibility(View.VISIBLE); - } - if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() || MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) extendedBolusCancel.setVisibility(View.GONE); - else { - extendedBolusCancel.setVisibility(View.VISIBLE); - ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()); - extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString()); + } else { + if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { + extendedBolus.setVisibility(View.GONE); + extendedBolusCancel.setVisibility(View.VISIBLE); + ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()); + extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString()); + } else { + extendedBolus.setVisibility(View.VISIBLE); + extendedBolusCancel.setVisibility(View.GONE); + } } - if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isTempBasalInProgress()) + + + if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) { tempBasal.setVisibility(View.GONE); - else - tempBasal.setVisibility(View.VISIBLE); + tempBasalCancel.setVisibility(View.GONE); + } else { + if (MainApp.getConfigBuilder().isTempBasalInProgress()) { + tempBasal.setVisibility(View.GONE); + tempBasalCancel.setVisibility(View.VISIBLE); + final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()); + tempBasalCancel.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort()); + } else { + tempBasal.setVisibility(View.VISIBLE); + tempBasalCancel.setVisibility(View.GONE); + } + } + if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) fill.setVisibility(View.GONE); else fill.setVisibility(View.VISIBLE); + if (!Config.APS) tempTarget.setVisibility(View.GONE); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 94472ce9f4..a5b7e9edca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -175,7 +175,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, LinearLayoutManager llm; LinearLayout acceptTempLayout; - Button cancelTempButton; Button treatmentButton; Button wizardButton; Button calibrationButton; @@ -269,9 +268,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph); iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph); - cancelTempButton = (Button) view.findViewById(R.id.overview_canceltempbutton); - if (cancelTempButton != null) - cancelTempButton.setOnClickListener(this); treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton); treatmentButton.setOnClickListener(this); wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton); @@ -1020,15 +1016,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()); - if (cancelTempButton != null) { - if (activeTemp != null) { - cancelTempButton.setVisibility(View.VISIBLE); - cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort()); - } else { - cancelTempButton.setVisibility(View.GONE); - } - } - String basalText = ""; if (shorttextmode) { if (activeTemp != null) { diff --git a/app/src/main/res/layout/actions_fragment.xml b/app/src/main/res/layout/actions_fragment.xml index e24f69124d..bc8f416770 100644 --- a/app/src/main/res/layout/actions_fragment.xml +++ b/app/src/main/res/layout/actions_fragment.xml @@ -52,6 +52,19 @@ android:drawableTop="@drawable/icon_actions_starttempbasal" android:text="@string/overview_tempbasal_button" /> +