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.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 {
|
||||
|
@ -311,9 +313,10 @@ class ActionsFragment : DaggerFragment() {
|
|||
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,7 +361,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
activity,
|
||||
ProtectionCheck.Protection.BOLUS,
|
||||
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,
|
||||
ProtectionCheck.Protection.BOLUS,
|
||||
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.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(
|
||||
activity,
|
||||
ProtectionCheck.Protection.BOLUS,
|
||||
|
@ -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,6 +562,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
// Automation buttons
|
||||
binding.buttonsLayout.userButtonsLayout.removeAllViews()
|
||||
val events = automationPlugin.userEvents()
|
||||
if (!loop.isDisconnected && pump.isInitialized() && !pump.isSuspended() && profile != null)
|
||||
for (event in events)
|
||||
if (event.isEnabled && event.trigger.shouldRun())
|
||||
context?.let { context ->
|
||||
|
|
|
@ -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