Simplify a bit more LoopPlugin
This commit is contained in:
parent
8770cfa4ad
commit
c00000e079
1 changed files with 24 additions and 23 deletions
|
@ -35,6 +35,7 @@ import info.nightscout.androidaps.utils.ToastUtils
|
|||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.extensions.toVisibility
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
|
@ -60,6 +61,7 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
@Inject lateinit var repository: AppRepository
|
||||
@Inject lateinit var objectivePlugin: ObjectivesPlugin
|
||||
|
||||
private var showOkCancel: Boolean = true
|
||||
private var _binding: DialogLoopBinding? = null
|
||||
|
@ -159,6 +161,7 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
aapsLogger.debug("UpdateGUI from $from")
|
||||
val pumpDescription: PumpDescription = activePlugin.activePump.pumpDescription
|
||||
val closedLoopAllowed = constraintChecker.isClosedLoopAllowed(Constraint(true))
|
||||
val closedLoopAllowed2 = objectivePlugin.objectives[ObjectivesPlugin.MAXIOB_OBJECTIVE].isCompleted
|
||||
val lgsEnabled = constraintChecker.isLgsAllowed(Constraint(true))
|
||||
val apsMode = sp.getString(R.string.key_aps_mode, "open")
|
||||
val pump = activePlugin.activePump
|
||||
|
@ -178,15 +181,6 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
binding.overviewPump.visibility = View.GONE
|
||||
}
|
||||
|
||||
!loopPlugin.isEnabled(PluginType.LOOP) -> {
|
||||
binding.overviewLoop.visibility = View.VISIBLE
|
||||
binding.overviewEnable.visibility = View.VISIBLE
|
||||
binding.overviewDisable.visibility = View.GONE
|
||||
binding.overviewSuspend.visibility = View.GONE
|
||||
binding.overviewPump.visibility = View.VISIBLE
|
||||
binding.overviewReconnect.visibility = View.GONE
|
||||
}
|
||||
|
||||
loopPlugin.isDisconnected -> {
|
||||
binding.overviewLoop.visibility = View.GONE
|
||||
binding.overviewSuspend.visibility = View.GONE
|
||||
|
@ -196,6 +190,15 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
binding.overviewReconnect.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
!loopPlugin.isEnabled(PluginType.LOOP) -> {
|
||||
binding.overviewLoop.visibility = View.VISIBLE
|
||||
binding.overviewEnable.visibility = View.VISIBLE
|
||||
binding.overviewDisable.visibility = View.GONE
|
||||
binding.overviewSuspend.visibility = View.GONE
|
||||
binding.overviewPump.visibility = View.VISIBLE
|
||||
binding.overviewReconnect.visibility = View.GONE
|
||||
}
|
||||
|
||||
loopPlugin.isSuspended -> {
|
||||
binding.overviewLoop.visibility = View.GONE
|
||||
binding.overviewSuspend.visibility = View.VISIBLE
|
||||
|
@ -210,24 +213,24 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
binding.overviewLoop.visibility = View.VISIBLE
|
||||
binding.overviewEnable.visibility = View.GONE
|
||||
when {
|
||||
closedLoopAllowed.value() -> {
|
||||
binding.overviewCloseloop.visibility = (apsMode != "closed").toVisibility()
|
||||
binding.overviewLgsloop.visibility = (apsMode != "lgs").toVisibility()
|
||||
binding.overviewOpenloop.visibility = (apsMode != "open").toVisibility()
|
||||
apsMode == "closed" -> {
|
||||
binding.overviewCloseloop.visibility = View.GONE
|
||||
binding.overviewLgsloop.visibility = View.VISIBLE
|
||||
binding.overviewOpenloop.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
apsMode == "lgs" -> {
|
||||
binding.overviewCloseloop.visibility = closedLoopAllowed.value().toVisibility() //show Close loop button only if Close loop allowed
|
||||
binding.overviewLgsloop.visibility = View.GONE
|
||||
binding.overviewOpenloop.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
apsMode == "open" -> {
|
||||
binding.overviewCloseloop.visibility = View.VISIBLE
|
||||
binding.overviewLgsloop.visibility = View.GONE
|
||||
binding.overviewCloseloop.visibility = closedLoopAllowed2.toVisibility() //show CloseLoop button only if Objective 6 is completed (closedLoopAllowed always false in open loop mode)
|
||||
binding.overviewLgsloop.visibility = lgsEnabled.value().toVisibility()
|
||||
binding.overviewOpenloop.visibility = View.GONE
|
||||
}
|
||||
|
||||
lgsEnabled.value() -> {
|
||||
binding.overviewCloseloop.visibility = View.GONE
|
||||
binding.overviewLgsloop.visibility = (apsMode != "lgs").toVisibility()
|
||||
binding.overviewOpenloop.visibility = (apsMode != "open").toVisibility()
|
||||
}
|
||||
|
||||
else -> {
|
||||
binding.overviewCloseloop.visibility = View.GONE
|
||||
binding.overviewLgsloop.visibility = View.GONE
|
||||
|
@ -247,7 +250,6 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
val profile = profileFunction.getProfile()
|
||||
val profileStore = activePlugin.activeProfileSource.profile
|
||||
|
@ -258,7 +260,6 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
return
|
||||
}
|
||||
**************************************************************************************************/
|
||||
|
||||
}
|
||||
|
||||
private fun onClickOkCancelEnabled(v: View): Boolean {
|
||||
|
|
Loading…
Reference in a new issue