diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueueImplementation.kt b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueueImplementation.kt index bbfbd91d31..3f2e2de469 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueueImplementation.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueueImplementation.kt @@ -321,9 +321,9 @@ class CommandQueueImplementation @Inject constructor( } @Synchronized - override fun cancelAllBoluses() { + override fun cancelAllBoluses(timestamp: Long) { 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.SMB_BOLUS) diff --git a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueImplementationTest.kt b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueImplementationTest.kt index 907f739127..7c694189da 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueImplementationTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueImplementationTest.kt @@ -241,7 +241,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() { Assert.assertEquals(2, commandQueue.size()) // when - commandQueue.cancelAllBoluses() + commandQueue.cancelAllBoluses(anyLong()) // then Assert.assertEquals(0, commandQueue.size()) diff --git a/core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt index 8b6368bc0c..c19f869a71 100644 --- a/core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt @@ -1,6 +1,5 @@ package info.nightscout.androidaps.dialogs -import android.content.res.Resources import android.os.Bundle import android.os.SystemClock 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.events.EventPumpStatusChanged import info.nightscout.androidaps.interfaces.CommandQueue -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag +import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.interfaces.ResourceHelper 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.kotlin.plusAssign import javax.inject.Inject @@ -75,17 +74,12 @@ class BolusProgressDialog : DaggerDialogFragment() { // onDestroyView. private val binding get() = _binding!! - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE) dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) isCancelable = false dialog?.setCanceledOnTouchOutside(false) - - val theme: Resources.Theme? = context?.theme - theme?.applyStyle(R.style.AppTheme_NoActionBar, true) + context?.theme?.applyStyle(R.style.AppTheme_NoActionBar, true) _binding = DialogBolusprogressBinding.inflate(inflater, container, false) return binding.root @@ -95,6 +89,7 @@ class BolusProgressDialog : DaggerDialogFragment() { savedInstanceState?.let { amount = it.getDouble("amount") timestamp = it.getLong("timestamp") + state = it.getString("state") ?: rh.gs(R.string.waitingforpump) } binding.title.text = rh.gs(R.string.goingtodeliver, amount) binding.stop.setOnClickListener { @@ -103,11 +98,9 @@ class BolusProgressDialog : DaggerDialogFragment() { binding.stoppressed.visibility = View.VISIBLE binding.stop.visibility = View.INVISIBLE uel.log(Action.CANCEL_BOLUS, Sources.Overview, state) - commandQueue.cancelAllBoluses() + commandQueue.cancelAllBoluses(timestamp) } - val defaultState = rh.gs(R.string.waitingforpump) binding.progressbar.max = 100 - state = savedInstanceState?.getString("state", defaultState) ?: defaultState binding.status.text = state stopPressed = false } @@ -134,7 +127,7 @@ class BolusProgressDialog : DaggerDialogFragment() { .toObservable(EventDismissBolusProgressIfRunning::class.java) .observeOn(aapsSchedulers.main) .subscribe({ - aapsLogger.debug(LTag.PUMP, "Running timestamp $timestamp. Close request timestamp ${it.bolusTimestamp}") + aapsLogger.debug(LTag.PUMP, "Running timestamp $timestamp. Close request timestamp ${it.bolusTimestamp}") if (it.bolusTimestamp == null || it.bolusTimestamp == timestamp) if (running) dismiss() }, fabricPrivacy::logException) diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/CommandQueue.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/CommandQueue.kt index 5ba0055402..8619f43a3a 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/CommandQueue.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/CommandQueue.kt @@ -17,7 +17,7 @@ interface CommandQueue { fun independentConnect(reason: String, callback: Callback?) fun bolusInQueue(): Boolean fun bolus(detailedBolusInfo: DetailedBolusInfo, callback: Callback?): Boolean - fun cancelAllBoluses() + fun cancelAllBoluses(running: Long) fun stopPump(callback: Callback?) fun startPump(callback: Callback?) fun setTBROverNotification(callback: Callback?, enable: Boolean)