From 66fd83ccb1e9a98f9cc1a6aec73e9d21098e3291 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 8 Dec 2019 18:01:52 +0100 Subject: [PATCH] biometrics bolus protection --- .../plugins/general/actions/ActionsFragment.kt | 7 ++++++- .../plugins/general/overview/OverviewFragment.java | 13 ++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index dfc06e6156..a0aa2fc066 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -26,6 +26,7 @@ import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatm import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.* +import info.nightscout.androidaps.utils.protection.ProtectionCheck import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import kotlinx.android.synthetic.main.actions_fragment.* @@ -84,7 +85,11 @@ class ActionsFragment : Fragment() { }) } } - actions_fill.setOnClickListener { fragmentManager?.let { FillDialog().show(it, "FillDialog") } } + actions_fill.setOnClickListener { + activity?.let { activity -> + ProtectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, Runnable { fragmentManager?.let { FillDialog().show(it, "FillDialog") } }) + } + } actions_historybrowser.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) } actions_tddstats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java index f3b718743e..80cbcea992 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java @@ -118,6 +118,7 @@ import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.SingleClickButton; import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.ToastUtils; +import info.nightscout.androidaps.utils.protection.ProtectionCheck; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; @@ -825,11 +826,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, onClickAcceptTemp(); break; case R.id.overview_quickwizardbutton: - onClickQuickwizard(); + ProtectionCheck.INSTANCE.queryProtection(getActivity(), ProtectionCheck.Protection.BOLUS, this::onClickQuickwizard); break; case R.id.overview_wizardbutton: - WizardDialog wizardDialog = new WizardDialog(); - wizardDialog.show(manager, "WizardDialog"); + ProtectionCheck.INSTANCE.queryProtection(getActivity(), ProtectionCheck.Protection.BOLUS, () -> new WizardDialog().show(manager, "WizardDialog")); break; case R.id.overview_calibrationbutton: if (xdrip) { @@ -863,14 +863,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } break; case R.id.overview_treatmentbutton: - NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog(); - treatmentDialogFragment.show(manager, "TreatmentDialog"); + ProtectionCheck.INSTANCE.queryProtection(getActivity(), ProtectionCheck.Protection.BOLUS, () -> new NewTreatmentDialog().show(manager, "TreatmentDialog")); break; case R.id.overview_insulinbutton: - new NewInsulinDialog().show(manager, "InsulinDialog"); + ProtectionCheck.INSTANCE.queryProtection(getActivity(), ProtectionCheck.Protection.BOLUS, () -> new NewInsulinDialog().show(manager, "InsulinDialog")); break; case R.id.overview_carbsbutton: - new NewCarbsDialog().show(manager, "CarbsDialog"); + ProtectionCheck.INSTANCE.queryProtection(getActivity(), ProtectionCheck.Protection.BOLUS, () -> new NewCarbsDialog().show(manager, "CarbsDialog")); break; case R.id.overview_pumpstatus: if (ConfigBuilderPlugin.getPlugin().getActivePump().isSuspended() || !ConfigBuilderPlugin.getPlugin().getActivePump().isInitialized())