Improve bolus canceling
This commit is contained in:
parent
bd979d24e5
commit
be201f0177
|
@ -321,9 +321,9 @@ class CommandQueueImplementation @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun cancelAllBoluses() {
|
override fun cancelAllBoluses(timestamp: Long) {
|
||||||
if (!isRunning(CommandType.BOLUS)) {
|
if (!isRunning(CommandType.BOLUS)) {
|
||||||
rxBus.send(EventDismissBolusProgressIfRunning(PumpEnactResult(injector).success(true).enacted(false), null))
|
rxBus.send(EventDismissBolusProgressIfRunning(PumpEnactResult(injector).success(true).enacted(false), timestamp))
|
||||||
}
|
}
|
||||||
removeAll(CommandType.BOLUS)
|
removeAll(CommandType.BOLUS)
|
||||||
removeAll(CommandType.SMB_BOLUS)
|
removeAll(CommandType.SMB_BOLUS)
|
||||||
|
|
|
@ -241,7 +241,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
|
||||||
Assert.assertEquals(2, commandQueue.size())
|
Assert.assertEquals(2, commandQueue.size())
|
||||||
|
|
||||||
// when
|
// when
|
||||||
commandQueue.cancelAllBoluses()
|
commandQueue.cancelAllBoluses(anyLong())
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assert.assertEquals(0, commandQueue.size())
|
Assert.assertEquals(0, commandQueue.size())
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.dialogs
|
package info.nightscout.androidaps.dialogs
|
||||||
|
|
||||||
import android.content.res.Resources
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -16,15 +15,15 @@ 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.events.EventPumpStatusChanged
|
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueue
|
import info.nightscout.androidaps.interfaces.CommandQueue
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.logging.LTag
|
|
||||||
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
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
|
import info.nightscout.shared.logging.LTag
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -75,17 +74,12 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
||||||
// onDestroyView.
|
// onDestroyView.
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View {
|
|
||||||
dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE)
|
dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE)
|
||||||
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
|
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
|
||||||
isCancelable = false
|
isCancelable = false
|
||||||
dialog?.setCanceledOnTouchOutside(false)
|
dialog?.setCanceledOnTouchOutside(false)
|
||||||
|
context?.theme?.applyStyle(R.style.AppTheme_NoActionBar, true)
|
||||||
val theme: Resources.Theme? = context?.theme
|
|
||||||
theme?.applyStyle(R.style.AppTheme_NoActionBar, true)
|
|
||||||
|
|
||||||
_binding = DialogBolusprogressBinding.inflate(inflater, container, false)
|
_binding = DialogBolusprogressBinding.inflate(inflater, container, false)
|
||||||
return binding.root
|
return binding.root
|
||||||
|
@ -95,6 +89,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
||||||
savedInstanceState?.let {
|
savedInstanceState?.let {
|
||||||
amount = it.getDouble("amount")
|
amount = it.getDouble("amount")
|
||||||
timestamp = it.getLong("timestamp")
|
timestamp = it.getLong("timestamp")
|
||||||
|
state = it.getString("state") ?: rh.gs(R.string.waitingforpump)
|
||||||
}
|
}
|
||||||
binding.title.text = rh.gs(R.string.goingtodeliver, amount)
|
binding.title.text = rh.gs(R.string.goingtodeliver, amount)
|
||||||
binding.stop.setOnClickListener {
|
binding.stop.setOnClickListener {
|
||||||
|
@ -103,11 +98,9 @@ class BolusProgressDialog : DaggerDialogFragment() {
|
||||||
binding.stoppressed.visibility = View.VISIBLE
|
binding.stoppressed.visibility = View.VISIBLE
|
||||||
binding.stop.visibility = View.INVISIBLE
|
binding.stop.visibility = View.INVISIBLE
|
||||||
uel.log(Action.CANCEL_BOLUS, Sources.Overview, state)
|
uel.log(Action.CANCEL_BOLUS, Sources.Overview, state)
|
||||||
commandQueue.cancelAllBoluses()
|
commandQueue.cancelAllBoluses(timestamp)
|
||||||
}
|
}
|
||||||
val defaultState = rh.gs(R.string.waitingforpump)
|
|
||||||
binding.progressbar.max = 100
|
binding.progressbar.max = 100
|
||||||
state = savedInstanceState?.getString("state", defaultState) ?: defaultState
|
|
||||||
binding.status.text = state
|
binding.status.text = state
|
||||||
stopPressed = false
|
stopPressed = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ interface CommandQueue {
|
||||||
fun independentConnect(reason: String, callback: Callback?)
|
fun independentConnect(reason: String, callback: Callback?)
|
||||||
fun bolusInQueue(): Boolean
|
fun bolusInQueue(): Boolean
|
||||||
fun bolus(detailedBolusInfo: DetailedBolusInfo, callback: Callback?): Boolean
|
fun bolus(detailedBolusInfo: DetailedBolusInfo, callback: Callback?): Boolean
|
||||||
fun cancelAllBoluses()
|
fun cancelAllBoluses(running: Long)
|
||||||
fun stopPump(callback: Callback?)
|
fun stopPump(callback: Callback?)
|
||||||
fun startPump(callback: Callback?)
|
fun startPump(callback: Callback?)
|
||||||
fun setTBROverNotification(callback: Callback?, enable: Boolean)
|
fun setTBROverNotification(callback: Callback?, enable: Boolean)
|
||||||
|
|
Loading…
Reference in a new issue