hide controls if pump is disconnected
This commit is contained in:
parent
85140a9c2e
commit
babbf8e7c9
|
@ -14,11 +14,13 @@ import dagger.android.support.DaggerFragment
|
|||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.activities.HistoryBrowseActivity
|
||||
import info.nightscout.androidaps.activities.TDDStatsActivity
|
||||
import info.nightscout.androidaps.database.AppRepository
|
||||
import info.nightscout.androidaps.database.ValueWrapper
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
||||
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
|
||||
import info.nightscout.androidaps.dialogs.*
|
||||
import info.nightscout.androidaps.events.EventCustomActionsChanged
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange
|
||||
|
@ -28,13 +30,7 @@ import info.nightscout.androidaps.events.EventTherapyEventChange
|
|||
import info.nightscout.androidaps.extensions.toStringMedium
|
||||
import info.nightscout.androidaps.extensions.toStringShort
|
||||
import info.nightscout.androidaps.extensions.toVisibility
|
||||
import info.nightscout.androidaps.activities.HistoryBrowseActivity
|
||||
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
import info.nightscout.androidaps.interfaces.CommandQueue
|
||||
import info.nightscout.androidaps.interfaces.Config
|
||||
import info.nightscout.androidaps.interfaces.IobCobCalculator
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.interfaces.*
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
|
@ -79,6 +75,7 @@ class ActionsFragment : DaggerFragment() {
|
|||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var repository: AppRepository
|
||||
@Inject lateinit var loop: Loop
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -111,8 +108,10 @@ class ActionsFragment : DaggerFragment() {
|
|||
private var insulinLevelLabel: TextView? = null
|
||||
private var pbLevelLabel: TextView? = null
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
//check screen width
|
||||
dm = DisplayMetrics()
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
|
||||
|
@ -164,10 +163,12 @@ class ActionsFragment : DaggerFragment() {
|
|||
extendedBolus?.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
|
||||
OKDialog.showConfirmation(activity, rh.gs(R.string.extended_bolus), rh.gs(R.string.ebstopsloop),
|
||||
OKDialog.showConfirmation(
|
||||
activity, rh.gs(R.string.extended_bolus), rh.gs(R.string.ebstopsloop),
|
||||
Runnable {
|
||||
ExtendedBolusDialog().show(childFragmentManager, "Actions")
|
||||
}, null)
|
||||
}, null
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -272,9 +273,10 @@ class ActionsFragment : DaggerFragment() {
|
|||
activePlugin.activeProfileSource.profile != null &&
|
||||
pump.pumpDescription.isSetBasalProfileCapable &&
|
||||
pump.isInitialized() &&
|
||||
!pump.isSuspended()).toVisibility()
|
||||
!pump.isSuspended() &&
|
||||
!loop.isDisconnected).toVisibility()
|
||||
|
||||
if (!pump.pumpDescription.isExtendedBolusCapable || !pump.isInitialized() || pump.isSuspended() || pump.isFakingTempsByExtendedBoluses || config.NSCLIENT) {
|
||||
if (!pump.pumpDescription.isExtendedBolusCapable || !pump.isInitialized() || pump.isSuspended() || loop.isDisconnected || pump.isFakingTempsByExtendedBoluses || config.NSCLIENT) {
|
||||
extendedBolus?.visibility = View.GONE
|
||||
extendedBolusCancel?.visibility = View.GONE
|
||||
} else {
|
||||
|
@ -290,7 +292,7 @@ class ActionsFragment : DaggerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!pump.pumpDescription.isTempBasalCapable || !pump.isInitialized() || pump.isSuspended() || config.NSCLIENT) {
|
||||
if (!pump.pumpDescription.isTempBasalCapable || !pump.isInitialized() || pump.isSuspended() || loop.isDisconnected || config.NSCLIENT) {
|
||||
setTempBasal?.visibility = View.GONE
|
||||
cancelTempBasal?.visibility = View.GONE
|
||||
} else {
|
||||
|
@ -308,12 +310,13 @@ class ActionsFragment : DaggerFragment() {
|
|||
val activeBgSource = activePlugin.activeBgSource
|
||||
historyBrowser?.visibility = (profile != null).toVisibility()
|
||||
fill?.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized() && !pump.isSuspended()).toVisibility()
|
||||
if(pump is DiaconnG8Plugin) {
|
||||
if (pump is DiaconnG8Plugin) {
|
||||
pumpBatteryChange?.visibility = (pump.pumpDescription.isBatteryReplaceable && !pump.isBatteryChangeLoggingEnabled()).toVisibility()
|
||||
} else {
|
||||
pumpBatteryChange?.visibility = (pump.pumpDescription.isBatteryReplaceable || (pump is OmnipodErosPumpPlugin && pump.isUseRileyLinkBatteryLevel && pump.isBatteryChangeLoggingEnabled)).toVisibility()
|
||||
pumpBatteryChange?.visibility =
|
||||
(pump.pumpDescription.isBatteryReplaceable || (pump is OmnipodErosPumpPlugin && pump.isUseRileyLinkBatteryLevel && pump.isBatteryChangeLoggingEnabled)).toVisibility()
|
||||
}
|
||||
tempTarget?.visibility = (profile != null && config.APS).toVisibility()
|
||||
tempTarget?.visibility = (profile != null && !loop.isDisconnected).toVisibility()
|
||||
tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
||||
|
||||
if (!config.NSCLIENT) {
|
||||
|
@ -342,7 +345,8 @@ class ActionsFragment : DaggerFragment() {
|
|||
btn.text = rh.gs(customAction.name)
|
||||
|
||||
val layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0.5f)
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0.5f
|
||||
)
|
||||
layoutParams.setMargins(20, 8, 20, 8) // 10,3,10,3
|
||||
|
||||
btn.layoutParams = layoutParams
|
||||
|
|
|
@ -132,7 +132,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
private lateinit var refreshLoop: Runnable
|
||||
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||
|
||||
|
||||
private val secondaryGraphs = ArrayList<GraphView>()
|
||||
private val secondaryGraphsLabel = ArrayList<TextView>()
|
||||
|
||||
|
@ -362,10 +361,13 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
activity,
|
||||
ProtectionCheck.Protection.BOLUS,
|
||||
UIRunnable { if (isAdded) CarbsDialog().show(childFragmentManager, "Overview") })
|
||||
R.id.temp_target -> protectionCheck.queryProtection(
|
||||
activity,
|
||||
ProtectionCheck.Protection.BOLUS,
|
||||
UIRunnable { if (isAdded) TempTargetDialog().show(childFragmentManager, "Overview") })
|
||||
R.id.temp_target ->
|
||||
if (loop.isDisconnected) OKDialog.show(activity, rh.gs(R.string.not_available_full), rh.gs(R.string.smscommunicator_pumpdisconnected))
|
||||
else
|
||||
protectionCheck.queryProtection(
|
||||
activity,
|
||||
ProtectionCheck.Protection.BOLUS,
|
||||
UIRunnable { if (isAdded) TempTargetDialog().show(childFragmentManager, "Overview") })
|
||||
|
||||
R.id.active_profile -> {
|
||||
ProfileViewerDialog().also { pvd ->
|
||||
|
@ -472,10 +474,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
R.id.temp_target -> v.performClick()
|
||||
R.id.active_profile -> activity?.let { activity ->
|
||||
protectionCheck.queryProtection(
|
||||
activity,
|
||||
ProtectionCheck.Protection.BOLUS,
|
||||
UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog") })
|
||||
if (loop.isDisconnected) OKDialog.show(activity, rh.gs(R.string.not_available_full), rh.gs(R.string.smscommunicator_pumpdisconnected))
|
||||
else
|
||||
protectionCheck.queryProtection(
|
||||
activity,
|
||||
ProtectionCheck.Protection.BOLUS,
|
||||
UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog") })
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -514,7 +518,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
// QuickWizard button
|
||||
val quickWizardEntry = quickWizard.getActive()
|
||||
if (quickWizardEntry != null && lastBG != null && profile != null && pump.isInitialized() && !pump.isSuspended()) {
|
||||
if (quickWizardEntry != null && lastBG != null && profile != null && pump.isInitialized() && !pump.isSuspended() && !loop.isDisconnected) {
|
||||
binding.buttonsLayout.quickWizardButton.visibility = View.VISIBLE
|
||||
val wizard = quickWizardEntry.doCalc(profile, profileName, lastBG, false)
|
||||
binding.buttonsLayout.quickWizardButton.text = quickWizardEntry.buttonText() + "\n" + rh.gs(R.string.format_carbs, quickWizardEntry.carbs()) +
|
||||
|
@ -540,13 +544,14 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
|
||||
// **** Various treatment buttons ****
|
||||
binding.buttonsLayout.carbsButton.visibility =
|
||||
((!activePlugin.activePump.pumpDescription.storesCarbInfo || pump.isInitialized() && !pump.isSuspended()) && profile != null && sp.getBoolean(
|
||||
R.string.key_show_carbs_button,
|
||||
true
|
||||
)).toVisibility()
|
||||
binding.buttonsLayout.treatmentButton.visibility = (pump.isInitialized() && !pump.isSuspended() && profile != null && sp.getBoolean(R.string.key_show_treatment_button, false)).toVisibility()
|
||||
binding.buttonsLayout.wizardButton.visibility = (pump.isInitialized() && !pump.isSuspended() && profile != null && sp.getBoolean(R.string.key_show_wizard_button, true)).toVisibility()
|
||||
binding.buttonsLayout.insulinButton.visibility = (pump.isInitialized() && !pump.isSuspended() && profile != null && sp.getBoolean(R.string.key_show_insulin_button, true)).toVisibility()
|
||||
((!activePlugin.activePump.pumpDescription.storesCarbInfo || pump.isInitialized() && !pump.isSuspended()) && profile != null
|
||||
&& sp.getBoolean(R.string.key_show_carbs_button, true)).toVisibility()
|
||||
binding.buttonsLayout.treatmentButton.visibility = (!loop.isDisconnected && pump.isInitialized() && !pump.isSuspended() && profile != null
|
||||
&& sp.getBoolean(R.string.key_show_treatment_button, false)).toVisibility()
|
||||
binding.buttonsLayout.wizardButton.visibility = (!loop.isDisconnected && pump.isInitialized() && !pump.isSuspended() && profile != null
|
||||
&& sp.getBoolean(R.string.key_show_wizard_button, true)).toVisibility()
|
||||
binding.buttonsLayout.insulinButton.visibility = (!loop.isDisconnected && pump.isInitialized() && !pump.isSuspended() && profile != null
|
||||
&& sp.getBoolean(R.string.key_show_insulin_button, true)).toVisibility()
|
||||
|
||||
// **** Calibration & CGM buttons ****
|
||||
val xDripIsBgSource = xdripPlugin.isEnabled()
|
||||
|
@ -557,28 +562,29 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
// Automation buttons
|
||||
binding.buttonsLayout.userButtonsLayout.removeAllViews()
|
||||
val events = automationPlugin.userEvents()
|
||||
for (event in events)
|
||||
if (event.isEnabled && event.trigger.shouldRun())
|
||||
context?.let { context ->
|
||||
SingleClickButton(context).also {
|
||||
it.setTextColor(rh.gc(R.color.colorTreatmentButton))
|
||||
it.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10f)
|
||||
it.layoutParams = LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 0.5f).also { l ->
|
||||
l.setMargins(0, 0, rh.dpToPx(-4), 0)
|
||||
}
|
||||
it.setCompoundDrawablesWithIntrinsicBounds(null, rh.gd(R.drawable.ic_danar_useropt), null, null)
|
||||
it.text = event.title
|
||||
if (!loop.isDisconnected && pump.isInitialized() && !pump.isSuspended() && profile != null)
|
||||
for (event in events)
|
||||
if (event.isEnabled && event.trigger.shouldRun())
|
||||
context?.let { context ->
|
||||
SingleClickButton(context).also {
|
||||
it.setTextColor(rh.gc(R.color.colorTreatmentButton))
|
||||
it.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10f)
|
||||
it.layoutParams = LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 0.5f).also { l ->
|
||||
l.setMargins(0, 0, rh.dpToPx(-4), 0)
|
||||
}
|
||||
it.setCompoundDrawablesWithIntrinsicBounds(null, rh.gd(R.drawable.ic_danar_useropt), null, null)
|
||||
it.text = event.title
|
||||
|
||||
it.setOnClickListener {
|
||||
OKDialog.showConfirmation(
|
||||
context,
|
||||
rh.gs(R.string.run_question, event.title),
|
||||
{ handler.post { automationPlugin.processEvent(event) } }
|
||||
)
|
||||
it.setOnClickListener {
|
||||
OKDialog.showConfirmation(
|
||||
context,
|
||||
rh.gs(R.string.run_question, event.title),
|
||||
{ handler.post { automationPlugin.processEvent(event) } }
|
||||
)
|
||||
}
|
||||
binding.buttonsLayout.userButtonsLayout.addView(it)
|
||||
}
|
||||
binding.buttonsLayout.userButtonsLayout.addView(it)
|
||||
}
|
||||
}
|
||||
binding.buttonsLayout.userButtonsLayout.visibility = events.isNotEmpty().toVisibility()
|
||||
}
|
||||
|
||||
|
@ -597,7 +603,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
binding.infoLayout.apsModeText.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
loop.isDisconnected -> {
|
||||
loop.isDisconnected -> {
|
||||
binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_disconnected)
|
||||
binding.infoLayout.apsModeText.text = dateUtil.age(loop.minutesToEndOfSuspend() * 60000L, true, rh)
|
||||
binding.infoLayout.apsModeText.visibility = View.VISIBLE
|
||||
|
@ -609,7 +615,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
binding.infoLayout.apsModeText.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
pump.isSuspended() -> {
|
||||
pump.isSuspended() -> {
|
||||
binding.infoLayout.apsMode.setImageResource(
|
||||
if (pump.model() == PumpType.OMNIPOD_EROS || pump.model() == PumpType.OMNIPOD_DASH) {
|
||||
// For Omnipod, indicate the pump as disconnected when it's suspended.
|
||||
|
@ -627,17 +633,17 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
binding.infoLayout.apsModeText.visibility = View.GONE
|
||||
}
|
||||
|
||||
(loop as PluginBase).isEnabled() && closedLoopEnabled.value() -> {
|
||||
(loop as PluginBase).isEnabled() && closedLoopEnabled.value() -> {
|
||||
binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_closed)
|
||||
binding.infoLayout.apsModeText.visibility = View.GONE
|
||||
}
|
||||
|
||||
(loop as PluginBase).isEnabled() && !closedLoopEnabled.value() -> {
|
||||
(loop as PluginBase).isEnabled() && !closedLoopEnabled.value() -> {
|
||||
binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_open)
|
||||
binding.infoLayout.apsModeText.visibility = View.GONE
|
||||
}
|
||||
|
||||
else -> {
|
||||
else -> {
|
||||
binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_disabled)
|
||||
binding.infoLayout.apsModeText.visibility = View.GONE
|
||||
}
|
||||
|
|
|
@ -146,7 +146,9 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
|
|||
if (lastReadStatus != 0L && lastReadStatus > System.currentTimeMillis() - T.mins(5).msecs()) {
|
||||
localAlertUtils.checkPumpUnreachableAlarm(lastConnection, isStatusOutdated, loop.isDisconnected)
|
||||
}
|
||||
if (runningProfile == null || ((!pump.isThisProfileSet(requestedProfile) || !requestedProfile.isEqual(runningProfile)) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE))) {
|
||||
if (loop.isDisconnected) {
|
||||
// do nothing if pump is disconnected
|
||||
} else if (runningProfile == null || ((!pump.isThisProfileSet(requestedProfile) || !requestedProfile.isEqual(runningProfile)) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE))) {
|
||||
rxBus.send(EventProfileSwitchChanged())
|
||||
} else if (isStatusOutdated && !pump.isBusy()) {
|
||||
lastReadStatus = System.currentTimeMillis()
|
||||
|
|
|
@ -1136,5 +1136,6 @@
|
|||
<string name="key_last_processed_glunovo_timestamp" translatable="false">last_processed_glunovo_timestamp</string>
|
||||
<string name="identification">Identification (email, FB or Discord nick etc)</string>
|
||||
<string name="identification_not_set">Identification not set in dev mode</string>
|
||||
<string name="not_available_full">Not available</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue