migrate BolusProgressDialog

This commit is contained in:
Milos Kozak 2022-11-22 11:54:27 +01:00
parent 9f5af9b80c
commit 94b1d0ce74
23 changed files with 144 additions and 53 deletions

View file

@ -15,6 +15,7 @@ import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.ui.activities.BolusProgressHelperActivity
import info.nightscout.ui.activities.ErrorHelperActivity
import info.nightscout.ui.activities.TDDStatsActivity
import info.nightscout.ui.dialogs.BolusProgressDialog
import info.nightscout.ui.dialogs.CareDialog
import info.nightscout.ui.dialogs.ExtendedBolusDialog
import info.nightscout.ui.dialogs.FillDialog
@ -104,4 +105,11 @@ class ActivityNamesImpl @Inject constructor() : ActivityNames {
}
.show(fragmentManager, "CareDialog")
}
override fun runBolusProgressDialog(fragmentManager: FragmentManager, insulin: Double, id: Long) {
BolusProgressDialog().also {
it.setInsulin(insulin)
it.setId(id)
it.show(fragmentManager, "BolusProgress")
}
}
}

View file

@ -29,7 +29,6 @@ dependencies {
api "androidx.activity:activity-ktx:$activity_version"
api "androidx.appcompat:appcompat:$appcompat_version"
api 'androidx.biometric:biometric:1.1.0'
api "com.google.dagger:dagger-android:$dagger_version"
api "com.google.dagger:dagger-android-support:$dagger_version"

View file

@ -32,7 +32,7 @@ class VersionCheckerUtils @Inject constructor(
private val dateUtil: DateUtil
) {
fun isConnected(): Boolean = receiverStatusStore.isConnected
private fun isConnected(): Boolean = receiverStatusStore.isConnected
fun triggerCheckVersion() {
@ -73,7 +73,7 @@ class VersionCheckerUtils @Inject constructor(
aapsLogger.debug(LTag.CORE, "Github master version not checked. No connectivity")
@Suppress("SameParameterValue")
fun compareWithCurrentVersion(newVersion: String?, currentVersion: String) {
internal fun compareWithCurrentVersion(newVersion: String?, currentVersion: String) {
val newVersionElements = newVersion.toNumberList()
val currentVersionElements = currentVersion.toNumberList()
@ -146,7 +146,7 @@ class VersionCheckerUtils @Inject constructor(
return digits.toIntArray()
}
fun findVersion(file: String?): String? {
internal fun findVersion(file: String?): String? {
val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex()
return file?.lines()?.filter { regex.matches(it) }?.firstNotNullOfOrNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) }
}
@ -161,8 +161,9 @@ class VersionCheckerUtils @Inject constructor(
fun String.numericVersionPart(): String =
"(((\\d+)\\.)+(\\d+))(\\D(.*))?".toRegex().matchEntire(this)?.groupValues?.getOrNull(1)
?: ""
/*
@Suppress("unused") fun findVersion(file: String?): String? {
val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex()
return file?.lines()?.filter { regex.matches(it) }?.firstNotNullOfOrNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) }
}
*/

View file

@ -2,7 +2,6 @@ package info.nightscout.core.di
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.dialogs.ErrorDialog
import info.nightscout.androidaps.plugins.general.maintenance.activities.PrefImportListActivity
import info.nightscout.core.ui.elements.SingleClickButton
@ -12,7 +11,6 @@ import info.nightscout.core.ui.elements.SingleClickButton
abstract class CoreFragmentsModule {
@ContributesAndroidInjector abstract fun contributesPrefImportListActivity(): PrefImportListActivity
@ContributesAndroidInjector abstract fun contributesBolusProgressDialog(): BolusProgressDialog
@ContributesAndroidInjector abstract fun contributesErrorDialog(): ErrorDialog
@ContributesAndroidInjector abstract fun contributesSingleClickButton(): SingleClickButton

View file

@ -30,7 +30,6 @@
<string name="please_wait">Please wait…</string>
<string name="mute">Mute</string>
<string name="reload">Reload</string>
<string name="stoppressed">STOP PRESSED</string>
<string name="stop">Stop</string>
<string name="carbs">Carbs</string>
<string name="invalid_profile">Invalid profile!</string>

View file

@ -26,4 +26,8 @@ dependencies {
implementation project(':core:utils')
implementation project(':core:ui')
implementation project(':ui')
// Protection
api 'androidx.biometric:biometric:1.1.0'
}

View file

@ -10,7 +10,6 @@ import androidx.appcompat.app.AppCompatActivity
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.extensions.getCustomizedName
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
@ -625,10 +624,11 @@ class CommandQueueImplementation @Inject constructor(
private fun showBolusProgressDialog(detailedBolusInfo: DetailedBolusInfo) {
if (detailedBolusInfo.context != null) {
val bolusProgressDialog = BolusProgressDialog()
bolusProgressDialog.setInsulin(detailedBolusInfo.insulin)
bolusProgressDialog.setId(detailedBolusInfo.id)
bolusProgressDialog.show((detailedBolusInfo.context as AppCompatActivity).supportFragmentManager, "BolusProgress")
activityNames.runBolusProgressDialog(
(detailedBolusInfo.context as AppCompatActivity).supportFragmentManager,
detailedBolusInfo.insulin,
detailedBolusInfo.id
)
} else {
val i = Intent()
i.putExtra("insulin", detailedBolusInfo.insulin)

View file

@ -1,10 +1,10 @@
package info.nightscout.implementation.queue.commands
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
import info.nightscout.implementation.R
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.BolusProgressData
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback
@ -27,7 +27,7 @@ class CommandBolus(
override fun execute() {
val r = activePlugin.activePump.deliverTreatment(detailedBolusInfo)
if (r.success) carbsRunnable.run()
BolusProgressDialog.bolusEnded = true
BolusProgressData.bolusEnded = true
rxBus.send(EventDismissBolusProgressIfRunning(r, detailedBolusInfo.id))
aapsLogger.debug(LTag.PUMPQUEUE, "Result success: ${r.success} enacted: ${r.enacted}")
callback?.result(r)?.run()

View file

@ -0,0 +1,6 @@
package info.nightscout.interfaces.pump
object BolusProgressData {
var bolusEnded = false
var stopPressed = false
}

View file

@ -33,7 +33,7 @@ interface ActivityNames {
fun runTempTargetDialog(fragmentManager: FragmentManager)
fun runExtendedBolusDialog(fragmentManager: FragmentManager)
fun runFillDialog(fragmentManager: FragmentManager)
fun runBolusProgressDialog(fragmentManager: FragmentManager, insulin: Double, id: Long)
enum class Mode(val i: Int) {
RUNNING_PROFILE(1),
CUSTOM_PROFILE(2),

View file

@ -7,8 +7,8 @@ import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerDialogFragment
import info.nightscout.core.main.R
import info.nightscout.core.main.databinding.DialogBolusprogressBinding
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.plugins.databinding.DialogNtpProgressBinding
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNtpStatus
@ -32,7 +32,7 @@ class NtpProgressDialog : DaggerDialogFragment() {
private var state: String? = null
private var percent = 0
private var _binding: DialogBolusprogressBinding? = null
private var _binding: DialogNtpProgressBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
@ -45,7 +45,7 @@ class NtpProgressDialog : DaggerDialogFragment() {
state = savedInstanceState?.getString("state", null)
percent = savedInstanceState?.getInt("percent", 0) ?: 0
_binding = DialogBolusprogressBinding.inflate(inflater, container, false)
_binding = DialogNtpProgressBinding.inflate(inflater, container, false)
return binding.root
}

View file

@ -4,7 +4,6 @@ import android.os.SystemClock
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
@ -17,6 +16,7 @@ import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.BolusProgressData
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.PumpEnactResult
@ -191,11 +191,11 @@ open class VirtualPumpPlugin @Inject constructor(
bolusingEvent.percent = min((delivering / detailedBolusInfo.insulin * 100).toInt(), 100)
rxBus.send(bolusingEvent)
delivering += 0.1
if (BolusProgressDialog.stopPressed)
if (BolusProgressData.stopPressed)
return PumpEnactResult(injector)
.success(false)
.enacted(false)
.comment(rh.gs(R.string.stoppressed))
.comment(rh.gs(R.string.stop))
}
SystemClock.sleep(200)
bolusingEvent.status = rh.gs(R.string.bolusdelivered, detailedBolusInfo.insulin)

View file

@ -0,0 +1,76 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
style="@style/StyleDialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.nightscout.plugins.constraints.objectives.dialogs.NtpProgressDialog">
<RelativeLayout
style="@style/StyleDialogHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageView
android:id="@+id/header_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
app:srcCompat="@drawable/ic_trending_flat_white_48dp" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_toEndOf="@id/header_icon"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:text="Going to deliver: 4.00 U" />
</RelativeLayout>
<LinearLayout
android:id="@+id/spacer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp" />
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingStart="10dp"
android:paddingEnd="10dp"
tools:text="Delivering 1.9U"/>
<ProgressBar
android:id="@+id/progressbar"
style="@android:style/Widget.Material.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_marginStart="5dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="5dp"
android:maxHeight="5dp"
android:minHeight="3dp"
android:scaleY="5"
tools:progress="50" />
<com.google.android.material.button.MaterialButton
style="@style/GrayButton"
android:id="@+id/stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="20dp"
android:text="@string/stop" />
</LinearLayout>

View file

@ -36,7 +36,6 @@ import info.nightscout.androidaps.danar.comm.MsgSettingShippingInfo;
import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
import info.nightscout.androidaps.dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.interfaces.Constants;
import info.nightscout.interfaces.constraints.Constraints;
@ -44,6 +43,7 @@ import info.nightscout.interfaces.notifications.Notification;
import info.nightscout.interfaces.plugin.ActivePlugin;
import info.nightscout.interfaces.profile.Profile;
import info.nightscout.interfaces.profile.ProfileFunction;
import info.nightscout.interfaces.pump.BolusProgressData;
import info.nightscout.interfaces.pump.PumpEnactResult;
import info.nightscout.interfaces.pump.PumpSync;
import info.nightscout.interfaces.pump.defs.PumpType;
@ -259,7 +259,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
public boolean bolus(double amount, int carbs, long carbTimeStamp, final EventOverviewBolusProgress.Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.Companion.getStopPressed()) return false;
if (BolusProgressData.INSTANCE.getStopPressed()) return false;
danaPump.setBolusingTreatment(t);
danaPump.setBolusDone(false);

View file

@ -48,13 +48,13 @@ import info.nightscout.androidaps.danar.comm.MsgStatusBasic;
import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
import info.nightscout.androidaps.dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.interfaces.Constants;
import info.nightscout.interfaces.notifications.Notification;
import info.nightscout.interfaces.plugin.ActivePlugin;
import info.nightscout.interfaces.profile.Profile;
import info.nightscout.interfaces.profile.ProfileFunction;
import info.nightscout.interfaces.pump.BolusProgressData;
import info.nightscout.interfaces.pump.Pump;
import info.nightscout.interfaces.pump.PumpEnactResult;
import info.nightscout.interfaces.pump.PumpSync;
@ -330,7 +330,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
public boolean bolus(final double amount, int carbs, long carbtime, final EventOverviewBolusProgress.Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.Companion.getStopPressed()) return false;
if (BolusProgressData.INSTANCE.getStopPressed()) return false;
rxBus.send(new EventPumpStatusChanged(rh.gs(R.string.startingbolus)));
danaPump.setBolusingTreatment(t);

View file

@ -43,12 +43,12 @@ import info.nightscout.androidaps.danar.comm.MsgStatus;
import info.nightscout.androidaps.danar.comm.MsgStatusBasic;
import info.nightscout.androidaps.danar.comm.MsgStatusBolusExtended;
import info.nightscout.androidaps.danar.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.interfaces.Constants;
import info.nightscout.interfaces.notifications.Notification;
import info.nightscout.interfaces.profile.Profile;
import info.nightscout.interfaces.profile.ProfileFunction;
import info.nightscout.interfaces.pump.BolusProgressData;
import info.nightscout.interfaces.pump.PumpEnactResult;
import info.nightscout.interfaces.pump.PumpSync;
import info.nightscout.interfaces.pump.defs.PumpType;
@ -265,7 +265,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
public boolean bolus(double amount, int carbs, long carbTimeStamp, final EventOverviewBolusProgress.Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.Companion.getStopPressed()) return false;
if (BolusProgressData.INSTANCE.getStopPressed()) return false;
danaPump.setBolusingTreatment(t);
danaPump.setBolusDone(false);

View file

@ -54,7 +54,6 @@ import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionGetUserOption
import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionSetPumpTime
import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionSetPumpUTCAndTimeZone
import info.nightscout.androidaps.danars.comm.DanaRSPacketOptionSetUserOption
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Constants
@ -63,6 +62,7 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.BolusProgressData
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.Callback
@ -293,7 +293,7 @@ class DanaRSService : DaggerService() {
fun bolus(insulin: Double, carbs: Int, carbTime: Long, t: EventOverviewBolusProgress.Treatment): Boolean {
if (!isConnected) return false
if (BolusProgressDialog.stopPressed) return false
if (BolusProgressData.stopPressed) return false
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.startingbolus)))
val preferencesSpeed = sp.getInt(R.string.key_danars_bolusspeed, 0)
danaPump.bolusDone = false

View file

@ -44,7 +44,6 @@ import info.nightscout.androidaps.diaconn.packet.TempBasalSettingPacket
import info.nightscout.androidaps.diaconn.packet.TimeInquirePacket
import info.nightscout.androidaps.diaconn.packet.TimeSettingPacket
import info.nightscout.androidaps.diaconn.pumplog.PumplogUtil
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.core.utils.fabric.FabricPrivacy
@ -54,6 +53,7 @@ import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.BolusProgressData
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpType
@ -446,7 +446,7 @@ class DiaconnG8Service : DaggerService() {
fun bolus(insulin: Double, carbs: Int, carbTime: Long, t: EventOverviewBolusProgress.Treatment): Boolean {
if (!isConnected) return false
if (BolusProgressDialog.stopPressed) return false
if (BolusProgressData.stopPressed) return false
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.startingbolus)))
// bolus speed setting

View file

@ -2,7 +2,7 @@ package info.nightscout.ui.activities
import android.os.Bundle
import info.nightscout.androidaps.activities.DialogAppCompatActivity
import info.nightscout.androidaps.dialogs.BolusProgressDialog
import info.nightscout.ui.dialogs.BolusProgressDialog
class BolusProgressHelperActivity : DialogAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {

View file

@ -16,6 +16,7 @@ import info.nightscout.ui.activities.fragments.TreatmentsProfileSwitchFragment
import info.nightscout.ui.activities.fragments.TreatmentsTempTargetFragment
import info.nightscout.ui.activities.fragments.TreatmentsTemporaryBasalsFragment
import info.nightscout.ui.activities.fragments.TreatmentsUserEntryFragment
import info.nightscout.ui.dialogs.BolusProgressDialog
import info.nightscout.ui.dialogs.CalibrationDialog
import info.nightscout.ui.dialogs.CarbsDialog
import info.nightscout.ui.dialogs.CareDialog
@ -54,6 +55,7 @@ abstract class UiModule {
@ContributesAndroidInjector abstract fun contributesTempBasalDialog(): TempBasalDialog
@ContributesAndroidInjector abstract fun contributesTempTargetDialog(): TempTargetDialog
@ContributesAndroidInjector abstract fun contributesLoopDialog(): LoopDialog
@ContributesAndroidInjector abstract fun contributesBolusProgressDialog(): BolusProgressDialog
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
@ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.dialogs
package info.nightscout.ui.dialogs
import android.os.Bundle
import android.os.SystemClock
@ -12,9 +12,9 @@ import info.nightscout.androidaps.activities.DialogAppCompatActivity
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning
import info.nightscout.core.main.R
import info.nightscout.core.main.databinding.DialogBolusprogressBinding
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.interfaces.pump.BolusProgressData
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
@ -23,6 +23,7 @@ import info.nightscout.rx.events.EventPumpStatusChanged
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.ui.databinding.DialogBolusprogressBinding
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import javax.inject.Inject
@ -38,15 +39,9 @@ class BolusProgressDialog : DaggerDialogFragment() {
private val disposable = CompositeDisposable()
companion object {
var bolusEnded = false
var stopPressed = false
}
private var running = true
private var amount = 0.0
var id: Long = 0L
private var id: Long = 0L
private var state: String? = null
private var helpActivity: DialogAppCompatActivity? = null
@ -57,7 +52,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
fun setInsulin(amount: Double): BolusProgressDialog {
this.amount = amount
bolusEnded = false
BolusProgressData.bolusEnded = false
return this
}
@ -92,15 +87,15 @@ class BolusProgressDialog : DaggerDialogFragment() {
binding.title.text = rh.gs(R.string.goingtodeliver, amount)
binding.stop.setOnClickListener {
aapsLogger.debug(LTag.UI, "Stop bolus delivery button pressed")
stopPressed = true
binding.stoppressed.visibility = View.VISIBLE
BolusProgressData.stopPressed = true
binding.stopPressed.visibility = View.VISIBLE
binding.stop.visibility = View.INVISIBLE
uel.log(Action.CANCEL_BOLUS, Sources.Overview, state)
commandQueue.cancelAllBoluses(id)
}
binding.progressbar.max = 100
binding.status.text = state
stopPressed = false
BolusProgressData.stopPressed = false
}
override fun onStart() {
@ -112,9 +107,9 @@ class BolusProgressDialog : DaggerDialogFragment() {
super.onResume()
aapsLogger.debug(LTag.UI, "onResume")
if (!commandQueue.bolusInQueue())
bolusEnded = true
BolusProgressData.bolusEnded = true
if (bolusEnded) dismiss()
if (BolusProgressData.bolusEnded) dismiss()
else running = true
disposable += rxBus
@ -153,7 +148,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
} catch (e: IllegalStateException) {
// dialog not running yet. onResume will try again. Set bolusEnded to make extra
// sure onResume will catch this
bolusEnded = true
BolusProgressData.bolusEnded = true
aapsLogger.error("Unhandled exception", e)
}
helpActivity?.finish()
@ -183,7 +178,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
aapsLogger.debug(LTag.UI, "scheduleDismiss")
Thread {
SystemClock.sleep(5000)
bolusEnded = true
BolusProgressData.bolusEnded = true
activity?.runOnUiThread {
if (running) {
aapsLogger.debug(LTag.UI, "executing")

View file

@ -4,7 +4,7 @@
style="@style/StyleDialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.nightscout.androidaps.dialogs.BolusProgressDialog">
tools:context=".dialogs.BolusProgressDialog">
<RelativeLayout
style="@style/StyleDialogHeader"
@ -51,12 +51,12 @@
tools:text="Delivering 1.9U"/>
<TextView
android:id="@+id/stoppressed"
android:id="@+id/stop_pressed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text="@string/stoppressed"
android:text="@string/stop_pressed"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fd0101"
android:textStyle="bold"

View file

@ -152,6 +152,9 @@
<!-- Other dialogs -->
<string name="basal_rate">Basal rate</string>
<!-- BolusProgressDialog-->
<string name="stop_pressed">STOP PRESSED</string>
<!-- PrefImport-->
<string name="check_preferences_details_btn">Explain import issues…</string>
<string name="check_preferences_details_title">Import issues details</string>