hide controls if pump is disconnected
This commit is contained in:
parent
85140a9c2e
commit
babbf8e7c9
4 changed files with 73 additions and 60 deletions
|
@ -14,11 +14,13 @@ import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
|
import info.nightscout.androidaps.activities.HistoryBrowseActivity
|
||||||
import info.nightscout.androidaps.activities.TDDStatsActivity
|
import info.nightscout.androidaps.activities.TDDStatsActivity
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.ValueWrapper
|
import info.nightscout.androidaps.database.ValueWrapper
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
||||||
|
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
|
||||||
import info.nightscout.androidaps.dialogs.*
|
import info.nightscout.androidaps.dialogs.*
|
||||||
import info.nightscout.androidaps.events.EventCustomActionsChanged
|
import info.nightscout.androidaps.events.EventCustomActionsChanged
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange
|
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.toStringMedium
|
||||||
import info.nightscout.androidaps.extensions.toStringShort
|
import info.nightscout.androidaps.extensions.toStringShort
|
||||||
import info.nightscout.androidaps.extensions.toVisibility
|
import info.nightscout.androidaps.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.activities.HistoryBrowseActivity
|
import info.nightscout.androidaps.interfaces.*
|
||||||
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.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
|
@ -79,6 +75,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
@Inject lateinit var config: Config
|
@Inject lateinit var config: Config
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
|
@Inject lateinit var loop: Loop
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -111,8 +108,10 @@ class ActionsFragment : DaggerFragment() {
|
||||||
private var insulinLevelLabel: TextView? = null
|
private var insulinLevelLabel: TextView? = null
|
||||||
private var pbLevelLabel: TextView? = null
|
private var pbLevelLabel: TextView? = null
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(
|
||||||
savedInstanceState: Bundle?): View? {
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
//check screen width
|
//check screen width
|
||||||
dm = DisplayMetrics()
|
dm = DisplayMetrics()
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
|
||||||
|
@ -164,10 +163,12 @@ class ActionsFragment : DaggerFragment() {
|
||||||
extendedBolus?.setOnClickListener {
|
extendedBolus?.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
|
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 {
|
Runnable {
|
||||||
ExtendedBolusDialog().show(childFragmentManager, "Actions")
|
ExtendedBolusDialog().show(childFragmentManager, "Actions")
|
||||||
}, null)
|
}, null
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,9 +273,10 @@ class ActionsFragment : DaggerFragment() {
|
||||||
activePlugin.activeProfileSource.profile != null &&
|
activePlugin.activeProfileSource.profile != null &&
|
||||||
pump.pumpDescription.isSetBasalProfileCapable &&
|
pump.pumpDescription.isSetBasalProfileCapable &&
|
||||||
pump.isInitialized() &&
|
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
|
extendedBolus?.visibility = View.GONE
|
||||||
extendedBolusCancel?.visibility = View.GONE
|
extendedBolusCancel?.visibility = View.GONE
|
||||||
} else {
|
} 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
|
setTempBasal?.visibility = View.GONE
|
||||||
cancelTempBasal?.visibility = View.GONE
|
cancelTempBasal?.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
|
@ -308,12 +310,13 @@ class ActionsFragment : DaggerFragment() {
|
||||||
val activeBgSource = activePlugin.activeBgSource
|
val activeBgSource = activePlugin.activeBgSource
|
||||||
historyBrowser?.visibility = (profile != null).toVisibility()
|
historyBrowser?.visibility = (profile != null).toVisibility()
|
||||||
fill?.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized() && !pump.isSuspended()).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()
|
pumpBatteryChange?.visibility = (pump.pumpDescription.isBatteryReplaceable && !pump.isBatteryChangeLoggingEnabled()).toVisibility()
|
||||||
} else {
|
} 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()
|
tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
||||||
|
|
||||||
if (!config.NSCLIENT) {
|
if (!config.NSCLIENT) {
|
||||||
|
@ -342,7 +345,8 @@ class ActionsFragment : DaggerFragment() {
|
||||||
btn.text = rh.gs(customAction.name)
|
btn.text = rh.gs(customAction.name)
|
||||||
|
|
||||||
val layoutParams = LinearLayout.LayoutParams(
|
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
|
layoutParams.setMargins(20, 8, 20, 8) // 10,3,10,3
|
||||||
|
|
||||||
btn.layoutParams = layoutParams
|
btn.layoutParams = layoutParams
|
||||||
|
|
|
@ -132,7 +132,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
private lateinit var refreshLoop: Runnable
|
private lateinit var refreshLoop: Runnable
|
||||||
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||||
|
|
||||||
|
|
||||||
private val secondaryGraphs = ArrayList<GraphView>()
|
private val secondaryGraphs = ArrayList<GraphView>()
|
||||||
private val secondaryGraphsLabel = ArrayList<TextView>()
|
private val secondaryGraphsLabel = ArrayList<TextView>()
|
||||||
|
|
||||||
|
@ -362,7 +361,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
activity,
|
activity,
|
||||||
ProtectionCheck.Protection.BOLUS,
|
ProtectionCheck.Protection.BOLUS,
|
||||||
UIRunnable { if (isAdded) CarbsDialog().show(childFragmentManager, "Overview") })
|
UIRunnable { if (isAdded) CarbsDialog().show(childFragmentManager, "Overview") })
|
||||||
R.id.temp_target -> protectionCheck.queryProtection(
|
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,
|
activity,
|
||||||
ProtectionCheck.Protection.BOLUS,
|
ProtectionCheck.Protection.BOLUS,
|
||||||
UIRunnable { if (isAdded) TempTargetDialog().show(childFragmentManager, "Overview") })
|
UIRunnable { if (isAdded) TempTargetDialog().show(childFragmentManager, "Overview") })
|
||||||
|
@ -472,6 +474,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
R.id.temp_target -> v.performClick()
|
R.id.temp_target -> v.performClick()
|
||||||
R.id.active_profile -> activity?.let { activity ->
|
R.id.active_profile -> activity?.let { activity ->
|
||||||
|
if (loop.isDisconnected) OKDialog.show(activity, rh.gs(R.string.not_available_full), rh.gs(R.string.smscommunicator_pumpdisconnected))
|
||||||
|
else
|
||||||
protectionCheck.queryProtection(
|
protectionCheck.queryProtection(
|
||||||
activity,
|
activity,
|
||||||
ProtectionCheck.Protection.BOLUS,
|
ProtectionCheck.Protection.BOLUS,
|
||||||
|
@ -514,7 +518,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
// QuickWizard button
|
// QuickWizard button
|
||||||
val quickWizardEntry = quickWizard.getActive()
|
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
|
binding.buttonsLayout.quickWizardButton.visibility = View.VISIBLE
|
||||||
val wizard = quickWizardEntry.doCalc(profile, profileName, lastBG, false)
|
val wizard = quickWizardEntry.doCalc(profile, profileName, lastBG, false)
|
||||||
binding.buttonsLayout.quickWizardButton.text = quickWizardEntry.buttonText() + "\n" + rh.gs(R.string.format_carbs, quickWizardEntry.carbs()) +
|
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 ****
|
// **** Various treatment buttons ****
|
||||||
binding.buttonsLayout.carbsButton.visibility =
|
binding.buttonsLayout.carbsButton.visibility =
|
||||||
((!activePlugin.activePump.pumpDescription.storesCarbInfo || pump.isInitialized() && !pump.isSuspended()) && profile != null && sp.getBoolean(
|
((!activePlugin.activePump.pumpDescription.storesCarbInfo || pump.isInitialized() && !pump.isSuspended()) && profile != null
|
||||||
R.string.key_show_carbs_button,
|
&& sp.getBoolean(R.string.key_show_carbs_button, true)).toVisibility()
|
||||||
true
|
binding.buttonsLayout.treatmentButton.visibility = (!loop.isDisconnected && pump.isInitialized() && !pump.isSuspended() && profile != null
|
||||||
)).toVisibility()
|
&& sp.getBoolean(R.string.key_show_treatment_button, false)).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 = (!loop.isDisconnected && pump.isInitialized() && !pump.isSuspended() && profile != null
|
||||||
binding.buttonsLayout.wizardButton.visibility = (pump.isInitialized() && !pump.isSuspended() && profile != null && sp.getBoolean(R.string.key_show_wizard_button, true)).toVisibility()
|
&& 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()
|
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 ****
|
// **** Calibration & CGM buttons ****
|
||||||
val xDripIsBgSource = xdripPlugin.isEnabled()
|
val xDripIsBgSource = xdripPlugin.isEnabled()
|
||||||
|
@ -557,6 +562,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
// Automation buttons
|
// Automation buttons
|
||||||
binding.buttonsLayout.userButtonsLayout.removeAllViews()
|
binding.buttonsLayout.userButtonsLayout.removeAllViews()
|
||||||
val events = automationPlugin.userEvents()
|
val events = automationPlugin.userEvents()
|
||||||
|
if (!loop.isDisconnected && pump.isInitialized() && !pump.isSuspended() && profile != null)
|
||||||
for (event in events)
|
for (event in events)
|
||||||
if (event.isEnabled && event.trigger.shouldRun())
|
if (event.isEnabled && event.trigger.shouldRun())
|
||||||
context?.let { context ->
|
context?.let { context ->
|
||||||
|
|
|
@ -146,7 +146,9 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
|
||||||
if (lastReadStatus != 0L && lastReadStatus > System.currentTimeMillis() - T.mins(5).msecs()) {
|
if (lastReadStatus != 0L && lastReadStatus > System.currentTimeMillis() - T.mins(5).msecs()) {
|
||||||
localAlertUtils.checkPumpUnreachableAlarm(lastConnection, isStatusOutdated, loop.isDisconnected)
|
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())
|
rxBus.send(EventProfileSwitchChanged())
|
||||||
} else if (isStatusOutdated && !pump.isBusy()) {
|
} else if (isStatusOutdated && !pump.isBusy()) {
|
||||||
lastReadStatus = System.currentTimeMillis()
|
lastReadStatus = System.currentTimeMillis()
|
||||||
|
|
|
@ -1136,5 +1136,6 @@
|
||||||
<string name="key_last_processed_glunovo_timestamp" translatable="false">last_processed_glunovo_timestamp</string>
|
<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">Identification (email, FB or Discord nick etc)</string>
|
||||||
<string name="identification_not_set">Identification not set in dev mode</string>
|
<string name="identification_not_set">Identification not set in dev mode</string>
|
||||||
|
<string name="not_available_full">Not available</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue