FillDialog -> ui
This commit is contained in:
parent
6cb6d23c60
commit
228167820c
14 changed files with 266 additions and 258 deletions
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.di
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.androidaps.activities.MyPreferenceFragment
|
import info.nightscout.androidaps.activities.MyPreferenceFragment
|
||||||
import info.nightscout.androidaps.dialogs.FillDialog
|
|
||||||
import info.nightscout.androidaps.dialogs.InsulinDialog
|
import info.nightscout.androidaps.dialogs.InsulinDialog
|
||||||
import info.nightscout.androidaps.dialogs.LoopDialog
|
import info.nightscout.androidaps.dialogs.LoopDialog
|
||||||
import info.nightscout.androidaps.dialogs.NtpProgressDialog
|
import info.nightscout.androidaps.dialogs.NtpProgressDialog
|
||||||
|
@ -41,7 +40,6 @@ abstract class FragmentsModule {
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
|
@ContributesAndroidInjector abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesFillDialog(): FillDialog
|
|
||||||
@ContributesAndroidInjector abstract fun contributesInsulinDialog(): InsulinDialog
|
@ContributesAndroidInjector abstract fun contributesInsulinDialog(): InsulinDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesLoopDialog(): LoopDialog
|
@ContributesAndroidInjector abstract fun contributesLoopDialog(): LoopDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesObjectivesExamDialog(): ObjectivesExamDialog
|
@ContributesAndroidInjector abstract fun contributesObjectivesExamDialog(): ObjectivesExamDialog
|
||||||
|
|
|
@ -1,231 +1,2 @@
|
||||||
package info.nightscout.androidaps.dialogs
|
package info.nightscout.androidaps.dialogs
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import com.google.common.base.Joiner
|
|
||||||
import info.nightscout.androidaps.R
|
|
||||||
import info.nightscout.androidaps.databinding.DialogFillBinding
|
|
||||||
import info.nightscout.androidaps.extensions.formatColor
|
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueue
|
|
||||||
import info.nightscout.androidaps.interfaces.Constraints
|
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
|
||||||
import info.nightscout.database.entities.TherapyEvent
|
|
||||||
import info.nightscout.database.entities.UserEntry.Action
|
|
||||||
import info.nightscout.database.entities.UserEntry.Sources
|
|
||||||
import info.nightscout.database.entities.ValueWithUnit
|
|
||||||
import info.nightscout.database.impl.AppRepository
|
|
||||||
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
|
||||||
import info.nightscout.interfaces.queue.Callback
|
|
||||||
import info.nightscout.interfaces.ui.ActivityNames
|
|
||||||
import info.nightscout.interfaces.utils.HtmlHelper
|
|
||||||
import info.nightscout.rx.logging.LTag
|
|
||||||
import info.nightscout.shared.SafeParse
|
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
|
||||||
import java.util.LinkedList
|
|
||||||
import javax.inject.Inject
|
|
||||||
import kotlin.math.abs
|
|
||||||
|
|
||||||
class FillDialog : DialogFragmentWithDate() {
|
|
||||||
|
|
||||||
@Inject lateinit var constraintChecker: Constraints
|
|
||||||
@Inject lateinit var rh: ResourceHelper
|
|
||||||
@Inject lateinit var ctx: Context
|
|
||||||
@Inject lateinit var commandQueue: CommandQueue
|
|
||||||
@Inject lateinit var activePlugin: ActivePlugin
|
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
|
||||||
@Inject lateinit var repository: AppRepository
|
|
||||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
|
||||||
@Inject lateinit var activityNames: ActivityNames
|
|
||||||
|
|
||||||
private var queryingProtection = false
|
|
||||||
private val disposable = CompositeDisposable()
|
|
||||||
private var _binding: DialogFillBinding? = null
|
|
||||||
|
|
||||||
// This property is only valid between onCreateView and onDestroyView.
|
|
||||||
private val binding get() = _binding!!
|
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
|
||||||
super.onSaveInstanceState(savedInstanceState)
|
|
||||||
savedInstanceState.putDouble("fill_insulin_amount", binding.fillInsulinamount.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View {
|
|
||||||
onCreateViewGeneral()
|
|
||||||
_binding = DialogFillBinding.inflate(inflater, container, false)
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
|
||||||
val bolusStep = activePlugin.activePump.pumpDescription.bolusStep
|
|
||||||
binding.fillInsulinamount.setParams(
|
|
||||||
savedInstanceState?.getDouble("fill_insulin_amount")
|
|
||||||
?: 0.0, 0.0, maxInsulin, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), true, binding.okcancel.ok
|
|
||||||
)
|
|
||||||
val amount1 = sp.getDouble("fill_button1", 0.3)
|
|
||||||
if (amount1 > 0) {
|
|
||||||
binding.fillPresetButton1.visibility = View.VISIBLE
|
|
||||||
binding.fillPresetButton1.text = DecimalFormatter.toPumpSupportedBolus(amount1, activePlugin.activePump) // + "U");
|
|
||||||
binding.fillPresetButton1.setOnClickListener { binding.fillInsulinamount.value = amount1 }
|
|
||||||
} else {
|
|
||||||
binding.fillPresetButton1.visibility = View.GONE
|
|
||||||
}
|
|
||||||
val amount2 = sp.getDouble("fill_button2", 0.0)
|
|
||||||
if (amount2 > 0) {
|
|
||||||
binding.fillPresetButton2.visibility = View.VISIBLE
|
|
||||||
binding.fillPresetButton2.text = DecimalFormatter.toPumpSupportedBolus(amount2, activePlugin.activePump) // + "U");
|
|
||||||
binding.fillPresetButton2.setOnClickListener { binding.fillInsulinamount.value = amount2 }
|
|
||||||
} else {
|
|
||||||
binding.fillPresetButton2.visibility = View.GONE
|
|
||||||
}
|
|
||||||
val amount3 = sp.getDouble("fill_button3", 0.0)
|
|
||||||
if (amount3 > 0) {
|
|
||||||
binding.fillPresetButton3.visibility = View.VISIBLE
|
|
||||||
binding.fillPresetButton3.text = DecimalFormatter.toPumpSupportedBolus(amount3, activePlugin.activePump) // + "U");
|
|
||||||
binding.fillPresetButton3.setOnClickListener { binding.fillInsulinamount.value = amount3 }
|
|
||||||
} else {
|
|
||||||
binding.fillPresetButton3.visibility = View.GONE
|
|
||||||
}
|
|
||||||
binding.fillLabel.labelFor = binding.fillInsulinamount.editTextId
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroyView() {
|
|
||||||
super.onDestroyView()
|
|
||||||
_binding = null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
|
||||||
if (_binding == null) return false
|
|
||||||
val insulin = SafeParse.stringToDouble(binding.fillInsulinamount.text)
|
|
||||||
val actions: LinkedList<String?> = LinkedList()
|
|
||||||
|
|
||||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value()
|
|
||||||
if (insulinAfterConstraints > 0) {
|
|
||||||
actions.add(rh.gs(R.string.fillwarning))
|
|
||||||
actions.add("")
|
|
||||||
actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(context, rh, R.attr.insulinButtonColor))
|
|
||||||
if (abs(insulinAfterConstraints - insulin) > 0.01)
|
|
||||||
actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor))
|
|
||||||
}
|
|
||||||
val siteChange = binding.fillCatheterChange.isChecked
|
|
||||||
if (siteChange)
|
|
||||||
actions.add(rh.gs(R.string.record_pump_site_change).formatColor(context, rh, R.attr.actionsConfirmColor))
|
|
||||||
val insulinChange = binding.fillCartridgeChange.isChecked
|
|
||||||
if (insulinChange)
|
|
||||||
actions.add(rh.gs(R.string.record_insulin_cartridge_change).formatColor(context, rh, R.attr.actionsConfirmColor))
|
|
||||||
val notes: String = binding.notesLayout.notes.text.toString()
|
|
||||||
if (notes.isNotEmpty())
|
|
||||||
actions.add(rh.gs(R.string.notes_label) + ": " + notes)
|
|
||||||
eventTime -= eventTime % 1000
|
|
||||||
|
|
||||||
if (eventTimeChanged)
|
|
||||||
actions.add(rh.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
|
|
||||||
|
|
||||||
if (insulinAfterConstraints > 0 || binding.fillCatheterChange.isChecked || binding.fillCartridgeChange.isChecked) {
|
|
||||||
activity?.let { activity ->
|
|
||||||
OKDialog.showConfirmation(activity, rh.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
|
||||||
if (insulinAfterConstraints > 0) {
|
|
||||||
uel.log(Action.PRIME_BOLUS, Sources.FillDialog,
|
|
||||||
notes,
|
|
||||||
ValueWithUnit.Insulin(insulinAfterConstraints))
|
|
||||||
requestPrimeBolus(insulinAfterConstraints, notes)
|
|
||||||
}
|
|
||||||
if (siteChange) {
|
|
||||||
uel.log(
|
|
||||||
Action.SITE_CHANGE, Sources.FillDialog,
|
|
||||||
notes,
|
|
||||||
ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged },
|
|
||||||
ValueWithUnit.TherapyEventType(TherapyEvent.Type.CANNULA_CHANGE)
|
|
||||||
)
|
|
||||||
disposable += repository.runTransactionForResult(
|
|
||||||
InsertIfNewByTimestampTherapyEventTransaction(
|
|
||||||
timestamp = eventTime,
|
|
||||||
type = TherapyEvent.Type.CANNULA_CHANGE,
|
|
||||||
note = notes,
|
|
||||||
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
|
||||||
)
|
|
||||||
).subscribe(
|
|
||||||
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted therapy event $it") } },
|
|
||||||
{ aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (insulinChange) {
|
|
||||||
// add a second for case of both checked
|
|
||||||
uel.log(
|
|
||||||
Action.RESERVOIR_CHANGE, Sources.FillDialog,
|
|
||||||
notes,
|
|
||||||
ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged },
|
|
||||||
ValueWithUnit.TherapyEventType(TherapyEvent.Type.INSULIN_CHANGE)
|
|
||||||
)
|
|
||||||
disposable += repository.runTransactionForResult(
|
|
||||||
InsertIfNewByTimestampTherapyEventTransaction(
|
|
||||||
timestamp = eventTime + 1000,
|
|
||||||
type = TherapyEvent.Type.INSULIN_CHANGE,
|
|
||||||
note = notes,
|
|
||||||
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
|
||||||
)
|
|
||||||
).subscribe(
|
|
||||||
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted therapy event $it") } },
|
|
||||||
{ aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}, null)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
activity?.let { activity ->
|
|
||||||
OKDialog.show(activity, rh.gs(R.string.primefill), rh.gs(R.string.no_action_selected))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dismiss()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun requestPrimeBolus(insulin: Double, notes: String) {
|
|
||||||
val detailedBolusInfo = DetailedBolusInfo()
|
|
||||||
detailedBolusInfo.insulin = insulin
|
|
||||||
detailedBolusInfo.context = context
|
|
||||||
detailedBolusInfo.bolusType = DetailedBolusInfo.BolusType.PRIMING
|
|
||||||
detailedBolusInfo.notes = notes
|
|
||||||
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
|
||||||
override fun run() {
|
|
||||||
if (!result.success) {
|
|
||||||
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
if (!queryingProtection) {
|
|
||||||
queryingProtection = true
|
|
||||||
activity?.let { activity ->
|
|
||||||
val cancelFail = {
|
|
||||||
queryingProtection = false
|
|
||||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.simpleName}")
|
|
||||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -13,8 +13,6 @@ import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.HistoryBrowseActivity
|
import info.nightscout.androidaps.activities.HistoryBrowseActivity
|
||||||
import info.nightscout.androidaps.databinding.ActionsFragmentBinding
|
import info.nightscout.androidaps.databinding.ActionsFragmentBinding
|
||||||
import info.nightscout.ui.dialogs.ExtendedBolusDialog
|
|
||||||
import info.nightscout.androidaps.dialogs.FillDialog
|
|
||||||
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
|
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
|
||||||
import info.nightscout.androidaps.dialogs.TempBasalDialog
|
import info.nightscout.androidaps.dialogs.TempBasalDialog
|
||||||
import info.nightscout.androidaps.dialogs.TempTargetDialog
|
import info.nightscout.androidaps.dialogs.TempTargetDialog
|
||||||
|
@ -56,6 +54,8 @@ import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import info.nightscout.ui.activities.TDDStatsActivity
|
import info.nightscout.ui.activities.TDDStatsActivity
|
||||||
import info.nightscout.ui.dialogs.CareDialog
|
import info.nightscout.ui.dialogs.CareDialog
|
||||||
|
import info.nightscout.ui.dialogs.ExtendedBolusDialog
|
||||||
|
import info.nightscout.ui.dialogs.FillDialog
|
||||||
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
|
||||||
|
|
|
@ -540,7 +540,7 @@ class DataHandlerMobile @Inject constructor(
|
||||||
else -> return
|
else -> return
|
||||||
}
|
}
|
||||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(amount)).value()
|
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(amount)).value()
|
||||||
var message = rh.gs(R.string.primefill) + ": " + insulinAfterConstraints + "U"
|
var message = rh.gs(R.string.prime_fill) + ": " + insulinAfterConstraints + "U"
|
||||||
if (insulinAfterConstraints - amount != 0.0) message += "\n" + rh.gs(R.string.constraint_applied)
|
if (insulinAfterConstraints - amount != 0.0) message += "\n" + rh.gs(R.string.constraint_applied)
|
||||||
rxBus.send(
|
rxBus.send(
|
||||||
EventMobileToWear(
|
EventMobileToWear(
|
||||||
|
@ -554,7 +554,7 @@ class DataHandlerMobile @Inject constructor(
|
||||||
|
|
||||||
private fun handleFillPreCheck(command: EventData.ActionFillPreCheck) {
|
private fun handleFillPreCheck(command: EventData.ActionFillPreCheck) {
|
||||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(command.insulin)).value()
|
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(command.insulin)).value()
|
||||||
var message = rh.gs(R.string.primefill) + ": " + insulinAfterConstraints + "U"
|
var message = rh.gs(R.string.prime_fill) + ": " + insulinAfterConstraints + "U"
|
||||||
if (insulinAfterConstraints - command.insulin != 0.0) message += "\n" + rh.gs(R.string.constraint_applied)
|
if (insulinAfterConstraints - command.insulin != 0.0) message += "\n" + rh.gs(R.string.constraint_applied)
|
||||||
rxBus.send(
|
rxBus.send(
|
||||||
EventMobileToWear(
|
EventMobileToWear(
|
||||||
|
|
|
@ -208,10 +208,10 @@
|
||||||
style="@style/GrayButton"
|
style="@style/GrayButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawableTop="@drawable/ic_cp_pump_canula"
|
android:drawableTop="@drawable/ic_cp_pump_cannula"
|
||||||
android:paddingStart="0dp"
|
android:paddingStart="0dp"
|
||||||
android:paddingEnd="0dp"
|
android:paddingEnd="0dp"
|
||||||
android:text="@string/primefill"
|
android:text="@string/prime_fill"
|
||||||
android:textSize="11sp"
|
android:textSize="11sp"
|
||||||
app:layout_column="1"
|
app:layout_column="1"
|
||||||
app:layout_columnWeight="1"
|
app:layout_columnWeight="1"
|
||||||
|
|
|
@ -158,12 +158,6 @@
|
||||||
<string name="ns_upload_only">(DANGEROUS TO DISABLE) NS upload only</string>
|
<string name="ns_upload_only">(DANGEROUS TO DISABLE) NS upload only</string>
|
||||||
<string name="ns_upload_only_summary">NS upload only (disabled sync). Not effective on SGV unless a local source like xDrip+ is selected. Not effective on Profiles while NS-Profiles is used.\n!!! WARNING !!! Disabling this option may cause malfunctions and insulin overdose if any of your component (AAPS, NS, xDrip+) is wrong configured. Carefully watch if data displayed by AAPS match the pump state!</string>
|
<string name="ns_upload_only_summary">NS upload only (disabled sync). Not effective on SGV unless a local source like xDrip+ is selected. Not effective on Profiles while NS-Profiles is used.\n!!! WARNING !!! Disabling this option may cause malfunctions and insulin overdose if any of your component (AAPS, NS, xDrip+) is wrong configured. Carefully watch if data displayed by AAPS match the pump state!</string>
|
||||||
<string name="pumpNotInitialized">Pump not initialized!</string>
|
<string name="pumpNotInitialized">Pump not initialized!</string>
|
||||||
<string name="primefill">Prime/Fill</string>
|
|
||||||
<string name="fillwarning">Please make sure the amount matches the specification of your infusion set!</string>
|
|
||||||
<string name="fillbolus_title">Fill/Prime standard insulin amounts</string>
|
|
||||||
<string name="button1">Button 1</string>
|
|
||||||
<string name="button2">Button 2</string>
|
|
||||||
<string name="button3">Button 3</string>
|
|
||||||
<string name="units">Units</string>
|
<string name="units">Units</string>
|
||||||
<string name="prefs_range_title">Range for Visualization</string>
|
<string name="prefs_range_title">Range for Visualization</string>
|
||||||
<string name="prefs_range_summary">High and low mark for the charts in Overview and Smartwatch</string>
|
<string name="prefs_range_summary">High and low mark for the charts in Overview and Smartwatch</string>
|
||||||
|
@ -358,7 +352,6 @@
|
||||||
<string name="enablesmbwithtemptarget_summary">Enable SMB when there is temp target active (eating soon, exercise)</string>
|
<string name="enablesmbwithtemptarget_summary">Enable SMB when there is temp target active (eating soon, exercise)</string>
|
||||||
<string name="enablesmbwithhightemptarget">Enable SMB with high temp targets</string>
|
<string name="enablesmbwithhightemptarget">Enable SMB with high temp targets</string>
|
||||||
<string name="enablesmbwithhightemptarget_summary">Enable SMB when there is high temp target active (exercise, above 100 mg/dl or 5.5 mmol/l)</string>
|
<string name="enablesmbwithhightemptarget_summary">Enable SMB when there is high temp target active (exercise, above 100 mg/dl or 5.5 mmol/l)</string>
|
||||||
<string name="overview_insulin_label">Insulin</string>
|
|
||||||
<string name="overview_buttons_selection">Buttons</string>
|
<string name="overview_buttons_selection">Buttons</string>
|
||||||
<string name="key_show_calibration_button" translatable="false">show_calibration_button</string>
|
<string name="key_show_calibration_button" translatable="false">show_calibration_button</string>
|
||||||
<string name="key_show_cgm_button" translatable="false">show_cgm_button</string>
|
<string name="key_show_cgm_button" translatable="false">show_cgm_button</string>
|
||||||
|
@ -422,8 +415,6 @@
|
||||||
<string name="maxvalueinpreferences">max value in preferences</string>
|
<string name="maxvalueinpreferences">max value in preferences</string>
|
||||||
<string name="hardlimit">hard limit</string>
|
<string name="hardlimit">hard limit</string>
|
||||||
<string name="key_openapsama_useautosens" translatable="false">openapsama_useautosens</string>
|
<string name="key_openapsama_useautosens" translatable="false">openapsama_useautosens</string>
|
||||||
<string name="record_pump_site_change">Record pump site change</string>
|
|
||||||
<string name="record_insulin_cartridge_change">Record insulin cartridge change</string>
|
|
||||||
<string name="smbalwaysdisabled">SMB always and after carbs disabled because active BG source doesn\'t support advanced filtering</string>
|
<string name="smbalwaysdisabled">SMB always and after carbs disabled because active BG source doesn\'t support advanced filtering</string>
|
||||||
<string name="smbnotallowedinopenloopmode">SMB not allowed in open loop mode</string>
|
<string name="smbnotallowedinopenloopmode">SMB not allowed in open loop mode</string>
|
||||||
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
|
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
|
||||||
|
@ -524,7 +515,6 @@
|
||||||
<string name="key_uamsmbmaxminutes" translatable="false">uamsmbmaxminutes</string>
|
<string name="key_uamsmbmaxminutes" translatable="false">uamsmbmaxminutes</string>
|
||||||
<string name="twohours">2h</string>
|
<string name="twohours">2h</string>
|
||||||
<string name="cobvsiob">COB vs IOB</string>
|
<string name="cobvsiob">COB vs IOB</string>
|
||||||
<string name="bolusconstraintappliedwarn">Bolus constraint applied: %1$.2f U to %2$.2f U</string>
|
|
||||||
<string name="slowabsorptiondetected"><![CDATA[<font color=\'%1$s\'>!!!!! Slow carbs absorption detected: %2$d%% of time. Double check your calculation. COB can be overestimated thus more insulin could be given !!!!!</font>]]></string>
|
<string name="slowabsorptiondetected"><![CDATA[<font color=\'%1$s\'>!!!!! Slow carbs absorption detected: %2$d%% of time. Double check your calculation. COB can be overestimated thus more insulin could be given !!!!!</font>]]></string>
|
||||||
<string name="key_boluswizard_percentage" translatable="false">boluswizard_percentage</string>
|
<string name="key_boluswizard_percentage" translatable="false">boluswizard_percentage</string>
|
||||||
<string name="partialboluswizard">Deliver this part of bolus wizard result [%]</string>
|
<string name="partialboluswizard">Deliver this part of bolus wizard result [%]</string>
|
||||||
|
|
|
@ -137,12 +137,12 @@ class Translator @Inject internal constructor(
|
||||||
TherapyEvent.Type.NOTE -> rh.gs(R.string.careportal_note)
|
TherapyEvent.Type.NOTE -> rh.gs(R.string.careportal_note)
|
||||||
TherapyEvent.Type.QUESTION -> rh.gs(R.string.careportal_question)
|
TherapyEvent.Type.QUESTION -> rh.gs(R.string.careportal_question)
|
||||||
TherapyEvent.Type.EXERCISE -> rh.gs(R.string.careportal_exercise)
|
TherapyEvent.Type.EXERCISE -> rh.gs(R.string.careportal_exercise)
|
||||||
TherapyEvent.Type.CANNULA_CHANGE -> rh.gs(R.string.careportal_pumpsitechange)
|
TherapyEvent.Type.CANNULA_CHANGE -> rh.gs(R.string.careportal_pump_site_change)
|
||||||
TherapyEvent.Type.PUMP_BATTERY_CHANGE -> rh.gs(R.string.careportal_pumpbatterychange)
|
TherapyEvent.Type.PUMP_BATTERY_CHANGE -> rh.gs(R.string.careportal_pumpbatterychange)
|
||||||
TherapyEvent.Type.SENSOR_STARTED -> rh.gs(R.string.careportal_cgmsensorstart)
|
TherapyEvent.Type.SENSOR_STARTED -> rh.gs(R.string.careportal_cgmsensorstart)
|
||||||
TherapyEvent.Type.SENSOR_STOPPED -> rh.gs(R.string.careportal_cgm_sensor_stop)
|
TherapyEvent.Type.SENSOR_STOPPED -> rh.gs(R.string.careportal_cgm_sensor_stop)
|
||||||
TherapyEvent.Type.SENSOR_CHANGE -> rh.gs(R.string.careportal_cgmsensorinsert)
|
TherapyEvent.Type.SENSOR_CHANGE -> rh.gs(R.string.careportal_cgmsensorinsert)
|
||||||
TherapyEvent.Type.INSULIN_CHANGE -> rh.gs(R.string.careportal_insulincartridgechange)
|
TherapyEvent.Type.INSULIN_CHANGE -> rh.gs(R.string.careportal_insulin_cartridge_change)
|
||||||
TherapyEvent.Type.DAD_ALERT -> rh.gs(R.string.careportal_dad_alert)
|
TherapyEvent.Type.DAD_ALERT -> rh.gs(R.string.careportal_dad_alert)
|
||||||
TherapyEvent.Type.TEMPORARY_BASAL_START -> rh.gs(R.string.careportal_tempbasalstart)
|
TherapyEvent.Type.TEMPORARY_BASAL_START -> rh.gs(R.string.careportal_tempbasalstart)
|
||||||
TherapyEvent.Type.TEMPORARY_BASAL_END -> rh.gs(R.string.careportal_tempbasalend)
|
TherapyEvent.Type.TEMPORARY_BASAL_END -> rh.gs(R.string.careportal_tempbasalend)
|
||||||
|
|
|
@ -53,7 +53,7 @@ class UserEntryPresentationHelper @Inject constructor(
|
||||||
Sources.LoopDialog -> R.drawable.ic_loop_closed
|
Sources.LoopDialog -> R.drawable.ic_loop_closed
|
||||||
Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal
|
Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal
|
||||||
Sources.CalibrationDialog -> R.drawable.ic_calibration
|
Sources.CalibrationDialog -> R.drawable.ic_calibration
|
||||||
Sources.FillDialog -> R.drawable.ic_cp_pump_canula
|
Sources.FillDialog -> R.drawable.ic_cp_pump_cannula
|
||||||
Sources.BgCheck -> R.drawable.ic_cp_bgcheck
|
Sources.BgCheck -> R.drawable.ic_cp_bgcheck
|
||||||
Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert
|
Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert
|
||||||
Sources.BatteryChange -> R.drawable.ic_cp_pump_battery
|
Sources.BatteryChange -> R.drawable.ic_cp_pump_battery
|
||||||
|
|
|
@ -254,6 +254,8 @@
|
||||||
<string name="invalid">INVALID</string>
|
<string name="invalid">INVALID</string>
|
||||||
<string name="login">Login</string>
|
<string name="login">Login</string>
|
||||||
<string name="upload_now">Upload now</string>
|
<string name="upload_now">Upload now</string>
|
||||||
|
<string name="prime_fill">Prime/Fill</string>
|
||||||
|
<string name="overview_insulin_label">Insulin</string>
|
||||||
|
|
||||||
<!-- Constraints-->
|
<!-- Constraints-->
|
||||||
<string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string>
|
<string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string>
|
||||||
|
@ -320,12 +322,12 @@
|
||||||
<string name="careportal_note_message">Note : %1$s</string>
|
<string name="careportal_note_message">Note : %1$s</string>
|
||||||
<string name="careportal_question_message">Question : %1$s</string>
|
<string name="careportal_question_message">Question : %1$s</string>
|
||||||
<string name="careportal_exercise_message">Exercise : %1$s</string>
|
<string name="careportal_exercise_message">Exercise : %1$s</string>
|
||||||
<string name="careportal_pumpsitechange">Pump Site Change</string>
|
<string name="careportal_pump_site_change">Pump Site Change</string>
|
||||||
<string name="careportal_cgmsensorinsert">CGM Sensor Insert</string>
|
<string name="careportal_cgmsensorinsert">CGM Sensor Insert</string>
|
||||||
<string name="careportal_cgmsensorstart">CGM Sensor Start</string>
|
<string name="careportal_cgmsensorstart">CGM Sensor Start</string>
|
||||||
<string name="careportal_cgm_sensor_stop">CGM Sensor Stop</string>
|
<string name="careportal_cgm_sensor_stop">CGM Sensor Stop</string>
|
||||||
<string name="careportal_dad_alert">D.A.D. Alert</string>
|
<string name="careportal_dad_alert">D.A.D. Alert</string>
|
||||||
<string name="careportal_insulincartridgechange">Insulin Cartridge Change</string>
|
<string name="careportal_insulin_cartridge_change">Insulin Cartridge Change</string>
|
||||||
<string name="careportal_profileswitch">Profile switch</string>
|
<string name="careportal_profileswitch">Profile switch</string>
|
||||||
<string name="careportal_snackbolus">Snack Bolus</string>
|
<string name="careportal_snackbolus">Snack Bolus</string>
|
||||||
<string name="careportal_mealbolus">Meal Bolus</string>
|
<string name="careportal_mealbolus">Meal Bolus</string>
|
||||||
|
|
|
@ -20,6 +20,7 @@ import info.nightscout.ui.dialogs.CalibrationDialog
|
||||||
import info.nightscout.ui.dialogs.CarbsDialog
|
import info.nightscout.ui.dialogs.CarbsDialog
|
||||||
import info.nightscout.ui.dialogs.CareDialog
|
import info.nightscout.ui.dialogs.CareDialog
|
||||||
import info.nightscout.ui.dialogs.ExtendedBolusDialog
|
import info.nightscout.ui.dialogs.ExtendedBolusDialog
|
||||||
|
import info.nightscout.ui.dialogs.FillDialog
|
||||||
import info.nightscout.ui.dialogs.ProfileViewerDialog
|
import info.nightscout.ui.dialogs.ProfileViewerDialog
|
||||||
import info.nightscout.ui.dialogs.WizardInfoDialog
|
import info.nightscout.ui.dialogs.WizardInfoDialog
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ abstract class UiModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesWizardInfoDialog(): WizardInfoDialog
|
@ContributesAndroidInjector abstract fun contributesWizardInfoDialog(): WizardInfoDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesProfileViewerDialog(): ProfileViewerDialog
|
@ContributesAndroidInjector abstract fun contributesProfileViewerDialog(): ProfileViewerDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesExtendedBolusDialog(): ExtendedBolusDialog
|
@ContributesAndroidInjector abstract fun contributesExtendedBolusDialog(): ExtendedBolusDialog
|
||||||
|
@ContributesAndroidInjector abstract fun contributesFillDialog(): FillDialog
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
|
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
|
||||||
@ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity
|
@ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity
|
||||||
|
|
232
ui/src/main/java/info/nightscout/ui/dialogs/FillDialog.kt
Normal file
232
ui/src/main/java/info/nightscout/ui/dialogs/FillDialog.kt
Normal file
|
@ -0,0 +1,232 @@
|
||||||
|
package info.nightscout.ui.dialogs
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.google.common.base.Joiner
|
||||||
|
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||||
|
import info.nightscout.androidaps.extensions.formatColor
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueue
|
||||||
|
import info.nightscout.androidaps.interfaces.Constraints
|
||||||
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
|
import info.nightscout.androidaps.utils.ToastUtils
|
||||||
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
|
import info.nightscout.database.entities.TherapyEvent
|
||||||
|
import info.nightscout.database.entities.UserEntry
|
||||||
|
import info.nightscout.database.entities.ValueWithUnit
|
||||||
|
import info.nightscout.database.impl.AppRepository
|
||||||
|
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
||||||
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
|
import info.nightscout.interfaces.queue.Callback
|
||||||
|
import info.nightscout.interfaces.ui.ActivityNames
|
||||||
|
import info.nightscout.interfaces.utils.HtmlHelper
|
||||||
|
import info.nightscout.rx.logging.LTag
|
||||||
|
import info.nightscout.shared.SafeParse
|
||||||
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
|
import info.nightscout.ui.R
|
||||||
|
import info.nightscout.ui.databinding.DialogFillBinding
|
||||||
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
|
import java.util.LinkedList
|
||||||
|
import javax.inject.Inject
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
|
class FillDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
|
@Inject lateinit var constraintChecker: Constraints
|
||||||
|
@Inject lateinit var rh: ResourceHelper
|
||||||
|
@Inject lateinit var ctx: Context
|
||||||
|
@Inject lateinit var commandQueue: CommandQueue
|
||||||
|
@Inject lateinit var activePlugin: ActivePlugin
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
@Inject lateinit var repository: AppRepository
|
||||||
|
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||||
|
@Inject lateinit var activityNames: ActivityNames
|
||||||
|
|
||||||
|
private var queryingProtection = false
|
||||||
|
private val disposable = CompositeDisposable()
|
||||||
|
private var _binding: DialogFillBinding? = null
|
||||||
|
|
||||||
|
// This property is only valid between onCreateView and onDestroyView.
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
|
super.onSaveInstanceState(savedInstanceState)
|
||||||
|
savedInstanceState.putDouble("fill_insulin_amount", binding.fillInsulinAmount.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
onCreateViewGeneral()
|
||||||
|
_binding = DialogFillBinding.inflate(inflater, container, false)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
||||||
|
val bolusStep = activePlugin.activePump.pumpDescription.bolusStep
|
||||||
|
binding.fillInsulinAmount.setParams(
|
||||||
|
savedInstanceState?.getDouble("fill_insulin_amount")
|
||||||
|
?: 0.0, 0.0, maxInsulin, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), true, binding.okcancel.ok
|
||||||
|
)
|
||||||
|
val amount1 = sp.getDouble("fill_button1", 0.3)
|
||||||
|
if (amount1 > 0) {
|
||||||
|
binding.fillPresetButton1.visibility = View.VISIBLE
|
||||||
|
binding.fillPresetButton1.text = DecimalFormatter.toPumpSupportedBolus(amount1, activePlugin.activePump) // + "U");
|
||||||
|
binding.fillPresetButton1.setOnClickListener { binding.fillInsulinAmount.value = amount1 }
|
||||||
|
} else {
|
||||||
|
binding.fillPresetButton1.visibility = View.GONE
|
||||||
|
}
|
||||||
|
val amount2 = sp.getDouble("fill_button2", 0.0)
|
||||||
|
if (amount2 > 0) {
|
||||||
|
binding.fillPresetButton2.visibility = View.VISIBLE
|
||||||
|
binding.fillPresetButton2.text = DecimalFormatter.toPumpSupportedBolus(amount2, activePlugin.activePump) // + "U");
|
||||||
|
binding.fillPresetButton2.setOnClickListener { binding.fillInsulinAmount.value = amount2 }
|
||||||
|
} else {
|
||||||
|
binding.fillPresetButton2.visibility = View.GONE
|
||||||
|
}
|
||||||
|
val amount3 = sp.getDouble("fill_button3", 0.0)
|
||||||
|
if (amount3 > 0) {
|
||||||
|
binding.fillPresetButton3.visibility = View.VISIBLE
|
||||||
|
binding.fillPresetButton3.text = DecimalFormatter.toPumpSupportedBolus(amount3, activePlugin.activePump) // + "U");
|
||||||
|
binding.fillPresetButton3.setOnClickListener { binding.fillInsulinAmount.value = amount3 }
|
||||||
|
} else {
|
||||||
|
binding.fillPresetButton3.visibility = View.GONE
|
||||||
|
}
|
||||||
|
binding.fillLabel.labelFor = binding.fillInsulinAmount.editTextId
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
_binding = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun submit(): Boolean {
|
||||||
|
if (_binding == null) return false
|
||||||
|
val insulin = SafeParse.stringToDouble(binding.fillInsulinAmount.text)
|
||||||
|
val actions: LinkedList<String?> = LinkedList()
|
||||||
|
|
||||||
|
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(insulin)).value()
|
||||||
|
if (insulinAfterConstraints > 0) {
|
||||||
|
actions.add(rh.gs(R.string.fillwarning))
|
||||||
|
actions.add("")
|
||||||
|
actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(context, rh, R.attr.insulinButtonColor))
|
||||||
|
if (abs(insulinAfterConstraints - insulin) > 0.01)
|
||||||
|
actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor))
|
||||||
|
}
|
||||||
|
val siteChange = binding.fillCatheterChange.isChecked
|
||||||
|
if (siteChange)
|
||||||
|
actions.add(rh.gs(R.string.record_pump_site_change).formatColor(context, rh, R.attr.actionsConfirmColor))
|
||||||
|
val insulinChange = binding.fillCartridgeChange.isChecked
|
||||||
|
if (insulinChange)
|
||||||
|
actions.add(rh.gs(R.string.record_insulin_cartridge_change).formatColor(context, rh, R.attr.actionsConfirmColor))
|
||||||
|
val notes: String = binding.notesLayout.notes.text.toString()
|
||||||
|
if (notes.isNotEmpty())
|
||||||
|
actions.add(rh.gs(R.string.notes_label) + ": " + notes)
|
||||||
|
eventTime -= eventTime % 1000
|
||||||
|
|
||||||
|
if (eventTimeChanged)
|
||||||
|
actions.add(rh.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
|
||||||
|
|
||||||
|
if (insulinAfterConstraints > 0 || binding.fillCatheterChange.isChecked || binding.fillCartridgeChange.isChecked) {
|
||||||
|
activity?.let { activity ->
|
||||||
|
OKDialog.showConfirmation(activity, rh.gs(R.string.prime_fill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
||||||
|
if (insulinAfterConstraints > 0) {
|
||||||
|
uel.log(
|
||||||
|
UserEntry.Action.PRIME_BOLUS, UserEntry.Sources.FillDialog,
|
||||||
|
notes,
|
||||||
|
ValueWithUnit.Insulin(insulinAfterConstraints)
|
||||||
|
)
|
||||||
|
requestPrimeBolus(insulinAfterConstraints, notes)
|
||||||
|
}
|
||||||
|
if (siteChange) {
|
||||||
|
uel.log(
|
||||||
|
UserEntry.Action.SITE_CHANGE, UserEntry.Sources.FillDialog,
|
||||||
|
notes,
|
||||||
|
ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged },
|
||||||
|
ValueWithUnit.TherapyEventType(TherapyEvent.Type.CANNULA_CHANGE)
|
||||||
|
)
|
||||||
|
disposable += repository.runTransactionForResult(
|
||||||
|
InsertIfNewByTimestampTherapyEventTransaction(
|
||||||
|
timestamp = eventTime,
|
||||||
|
type = TherapyEvent.Type.CANNULA_CHANGE,
|
||||||
|
note = notes,
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||||
|
)
|
||||||
|
).subscribe(
|
||||||
|
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted therapy event $it") } },
|
||||||
|
{ aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (insulinChange) {
|
||||||
|
// add a second for case of both checked
|
||||||
|
uel.log(
|
||||||
|
UserEntry.Action.RESERVOIR_CHANGE, UserEntry.Sources.FillDialog,
|
||||||
|
notes,
|
||||||
|
ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged },
|
||||||
|
ValueWithUnit.TherapyEventType(TherapyEvent.Type.INSULIN_CHANGE)
|
||||||
|
)
|
||||||
|
disposable += repository.runTransactionForResult(
|
||||||
|
InsertIfNewByTimestampTherapyEventTransaction(
|
||||||
|
timestamp = eventTime + 1000,
|
||||||
|
type = TherapyEvent.Type.INSULIN_CHANGE,
|
||||||
|
note = notes,
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||||
|
)
|
||||||
|
).subscribe(
|
||||||
|
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted therapy event $it") } },
|
||||||
|
{ aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}, null)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
activity?.let { activity ->
|
||||||
|
OKDialog.show(activity, rh.gs(R.string.prime_fill), rh.gs(R.string.no_action_selected))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dismiss()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun requestPrimeBolus(insulin: Double, notes: String) {
|
||||||
|
val detailedBolusInfo = DetailedBolusInfo()
|
||||||
|
detailedBolusInfo.insulin = insulin
|
||||||
|
detailedBolusInfo.context = context
|
||||||
|
detailedBolusInfo.bolusType = DetailedBolusInfo.BolusType.PRIMING
|
||||||
|
detailedBolusInfo.notes = notes
|
||||||
|
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
if (!result.success) {
|
||||||
|
activityNames.runAlarm(ctx, result.comment, rh.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
if (!queryingProtection) {
|
||||||
|
queryingProtection = true
|
||||||
|
activity?.let { activity ->
|
||||||
|
val cancelFail = {
|
||||||
|
queryingProtection = false
|
||||||
|
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.simpleName}")
|
||||||
|
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,7 +23,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:importantForAccessibility="no"
|
android:importantForAccessibility="no"
|
||||||
app:srcCompat="@drawable/ic_cp_pump_canula" />
|
app:srcCompat="@drawable/ic_cp_pump_cannula" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:text="@string/primefill"
|
android:text="@string/prime_fill"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
|
@ -56,13 +56,13 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:text="@string/careportal_pumpsitechange" />
|
android:text="@string/careportal_pump_site_change" />
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/fill_cartridge_change"
|
android:id="@+id/fill_cartridge_change"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/careportal_insulincartridgechange" />
|
android:text="@string/careportal_insulin_cartridge_change" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||||
android:id="@+id/fill_insulinamount"
|
android:id="@+id/fill_insulin_amount"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
|
@ -33,7 +33,10 @@
|
||||||
<string name="most_common_profile">Most common profile:</string>
|
<string name="most_common_profile">Most common profile:</string>
|
||||||
<string name="survey_comment">Note: Only data visible on this screen will be anonymously uploaded. ID is assigned to this installation of AAPS. You can submit data again if your main profile get changed but let it running at least for a week to make result visible in time in range. Your help is appreciated.</string>
|
<string name="survey_comment">Note: Only data visible on this screen will be anonymously uploaded. ID is assigned to this installation of AAPS. You can submit data again if your main profile get changed but let it running at least for a week to make result visible in time in range. Your help is appreciated.</string>
|
||||||
|
|
||||||
<!-- CareDialog -->
|
|
||||||
|
<!-- Dialogs -->
|
||||||
|
<string name="bolusconstraintappliedwarn">Bolus constraint applied: %1$.2f U to %2$.2f U</string>
|
||||||
|
|
||||||
<string name="glucose_type">Glucose type</string>
|
<string name="glucose_type">Glucose type</string>
|
||||||
<string name="bg_other">Other</string>
|
<string name="bg_other">Other</string>
|
||||||
<string name="bg_meter">Meter</string>
|
<string name="bg_meter">Meter</string>
|
||||||
|
@ -46,6 +49,16 @@
|
||||||
<string name="superbolus">Superbolus</string>
|
<string name="superbolus">Superbolus</string>
|
||||||
<string name="treatments_wizard_total_label">Total</string>
|
<string name="treatments_wizard_total_label">Total</string>
|
||||||
|
|
||||||
|
<!-- FillDialog -->
|
||||||
|
<string name="fillwarning">Please make sure the amount matches the specification of your infusion set!</string>
|
||||||
|
<string name="fillbolus_title">Fill/Prime standard insulin amounts</string>
|
||||||
|
<string name="button1">Button 1</string>
|
||||||
|
<string name="button2">Button 2</string>
|
||||||
|
<string name="button3">Button 3</string>
|
||||||
|
<string name="record_pump_site_change">Record pump site change</string>
|
||||||
|
<string name="record_insulin_cartridge_change">Record insulin cartridge change</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Treatments -->
|
<!-- Treatments -->
|
||||||
<string name="no_records_available">No records available</string>
|
<string name="no_records_available">No records available</string>
|
||||||
<string name="calculation_short">Calc</string>
|
<string name="calculation_short">Calc</string>
|
||||||
|
|
Loading…
Reference in a new issue