LoopDialog protection
This commit is contained in:
parent
34435d4684
commit
eb84f5e6a7
2 changed files with 30 additions and 23 deletions
|
@ -237,18 +237,21 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
val profile = profileFunction.getProfile() ?: return true
|
val profile = profileFunction.getProfile() ?: return true
|
||||||
when (v.id) {
|
when (v.id) {
|
||||||
R.id.overview_closeloop -> {
|
R.id.overview_closeloop -> {
|
||||||
|
aapsLogger.debug("USER ENTRY: CLOSED LOOP MODE")
|
||||||
sp.putString(R.string.key_aps_mode, "closed")
|
sp.putString(R.string.key_aps_mode, "closed")
|
||||||
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop)))
|
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_lgsloop -> {
|
R.id.overview_lgsloop -> {
|
||||||
|
aapsLogger.debug("USER ENTRY: LGS LOOP MODE")
|
||||||
sp.putString(R.string.key_aps_mode, "lgs")
|
sp.putString(R.string.key_aps_mode, "lgs")
|
||||||
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
|
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_openloop -> {
|
R.id.overview_openloop -> {
|
||||||
|
aapsLogger.debug("USER ENTRY: OPEN LOOP MODE")
|
||||||
sp.putString(R.string.key_aps_mode, "open")
|
sp.putString(R.string.key_aps_mode, "open")
|
||||||
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
|
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -289,12 +289,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
R.id.overview_temptarget -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { TempTargetDialog().show(childFragmentManager, "Overview") })
|
R.id.overview_temptarget -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { TempTargetDialog().show(childFragmentManager, "Overview") })
|
||||||
|
|
||||||
R.id.overview_activeprofile -> {
|
R.id.overview_activeprofile -> {
|
||||||
val args = Bundle()
|
ProfileViewerDialog().also { pvd ->
|
||||||
args.putLong("time", DateUtil.now())
|
pvd.arguments = Bundle().also {
|
||||||
args.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal)
|
it.putLong("time", DateUtil.now())
|
||||||
val pvd = ProfileViewerDialog()
|
it.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal)
|
||||||
pvd.arguments = args
|
}
|
||||||
pvd.show(childFragmentManager, "ProfileViewDialog")
|
}.show(childFragmentManager, "ProfileViewDialog")
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_cgmbutton -> {
|
R.id.overview_cgmbutton -> {
|
||||||
|
@ -329,24 +329,26 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
val lastRun = loopPlugin.lastRun
|
val lastRun = loopPlugin.lastRun
|
||||||
loopPlugin.invoke("Accept temp button", false)
|
loopPlugin.invoke("Accept temp button", false)
|
||||||
if (lastRun?.lastAPSRun != null && lastRun.constraintsProcessed?.isChangeRequested == true) {
|
if (lastRun?.lastAPSRun != null && lastRun.constraintsProcessed?.isChangeRequested == true) {
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned()
|
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
|
||||||
?: "".toSpanned(), {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned()
|
||||||
aapsLogger.debug("USER ENTRY: ACCEPT TEMP BASAL")
|
?: "".toSpanned(), {
|
||||||
overview_accepttempbutton?.visibility = View.GONE
|
aapsLogger.debug("USER ENTRY: ACCEPT TEMP BASAL")
|
||||||
(context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID)
|
overview_accepttempbutton?.visibility = View.GONE
|
||||||
actionStringHandler.handleInitiate("cancelChangeRequest")
|
(context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID)
|
||||||
loopPlugin.acceptChangeRequest()
|
actionStringHandler.handleInitiate("cancelChangeRequest")
|
||||||
|
loopPlugin.acceptChangeRequest()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_apsmode -> {
|
R.id.overview_apsmode -> {
|
||||||
val args = Bundle()
|
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
|
||||||
args.putInt("showOkCancel", 1) // 1-> true
|
LoopDialog().also { dialog ->
|
||||||
val pvd = LoopDialog()
|
dialog.arguments = Bundle().also { it.putInt("showOkCancel", 1) }
|
||||||
pvd.arguments = args
|
}.show(childFragmentManager, "Overview")
|
||||||
pvd.show(childFragmentManager, "Overview")
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,11 +376,13 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_apsmode -> {
|
R.id.overview_apsmode -> {
|
||||||
val args = Bundle()
|
activity?.let { activity ->
|
||||||
args.putInt("showOkCancel", 0) // 0-> false
|
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
|
||||||
val pvd = LoopDialog()
|
LoopDialog().also { dialog ->
|
||||||
pvd.arguments = args
|
dialog.arguments = Bundle().also { it.putInt("showOkCancel", 0) }
|
||||||
pvd.show(childFragmentManager, "Overview")
|
}.show(childFragmentManager, "Overview")
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_temptarget -> v.performClick()
|
R.id.overview_temptarget -> v.performClick()
|
||||||
|
|
Loading…
Reference in a new issue