BolusWizard: show icons based on checkbox selection in simple mode
This commit is contained in:
parent
e6d3141ace
commit
fb799d8da6
|
@ -113,7 +113,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View {
|
||||
this.arguments?.let { bundle ->
|
||||
carbsPassedIntoWizard = bundle.getInt("carbs_input")?.toDouble()
|
||||
carbsPassedIntoWizard = bundle.getInt("carbs_input").toDouble()
|
||||
notesPassedIntoWizard = bundle.getString("notes_input").toString()
|
||||
}
|
||||
|
||||
|
@ -184,8 +184,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
binding.bgCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
binding.ttCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
binding.cobCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
binding.basalIobCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
binding.bolusIobCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
binding.iobCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
binding.bgTrendCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
binding.sbCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
|
||||
|
@ -198,9 +197,12 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
sp.putBoolean(rh.gs(R.string.key_wizard_calculation_visible), isChecked)
|
||||
binding.delimiter.visibility = isChecked.toVisibility()
|
||||
binding.result.visibility = isChecked.toVisibility()
|
||||
processEnabledIcons()
|
||||
}
|
||||
}
|
||||
|
||||
processEnabledIcons()
|
||||
|
||||
binding.correctionPercent.setOnCheckedChangeListener {_, isChecked ->
|
||||
run {
|
||||
sp.putBoolean(rh.gs(R.string.key_wizard_correction_percent), isChecked)
|
||||
|
@ -248,21 +250,30 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
binding.ttCheckbox.isEnabled = binding.bgCheckbox.isChecked && repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing
|
||||
if (buttonView.id == binding.cobCheckbox.id)
|
||||
processCobCheckBox()
|
||||
processEnabledIcons()
|
||||
calculateInsulin()
|
||||
}
|
||||
|
||||
private fun processCobCheckBox() {
|
||||
if (binding.cobCheckbox.isChecked) {
|
||||
binding.bolusIobCheckbox.isEnabled = false
|
||||
binding.basalIobCheckbox.isEnabled = false
|
||||
binding.bolusIobCheckbox.isChecked = true
|
||||
binding.basalIobCheckbox.isChecked = true
|
||||
binding.iobCheckbox.isEnabled = false
|
||||
binding.iobCheckbox.isChecked = true
|
||||
} else {
|
||||
binding.bolusIobCheckbox.isEnabled = true
|
||||
binding.basalIobCheckbox.isEnabled = true
|
||||
binding.iobCheckbox.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun processEnabledIcons() {
|
||||
binding.bgEnabledIcon.alpha = if (binding.bgCheckbox.isChecked) 1.0f else 0.2f
|
||||
binding.trendEnabledIcon.alpha = if (binding.bgTrendCheckbox.isChecked) 1.0f else 0.2f
|
||||
binding.iobEnabledIcon.alpha = if (binding.iobCheckbox.isChecked) 1.0f else 0.2f
|
||||
binding.cobEnabledIcon.alpha = if (binding.cobCheckbox.isChecked) 1.0f else 0.2f
|
||||
binding.bgEnabledIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
binding.trendEnabledIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
binding.iobEnabledIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
binding.cobEnabledIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
}
|
||||
|
||||
private fun saveCheckedStates() {
|
||||
sp.putBoolean(R.string.key_wizard_include_cob, binding.cobCheckbox.isChecked)
|
||||
sp.putBoolean(R.string.key_wizard_include_trend_bg, binding.bgTrendCheckbox.isChecked)
|
||||
|
@ -284,8 +295,8 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
if(carbsPassedIntoWizard != 0.0) {
|
||||
binding.carbsInput.value = carbsPassedIntoWizard
|
||||
}
|
||||
if(!notesPassedIntoWizard.isBlank()) {
|
||||
binding.notes.setText(notesPassedIntoWizard.toString())
|
||||
if(notesPassedIntoWizard.isNotBlank()) {
|
||||
binding.notes.setText(notesPassedIntoWizard)
|
||||
}
|
||||
val profile = profileFunction.getProfile()
|
||||
val profileStore = activePlugin.activeProfileSource.profile
|
||||
|
@ -315,8 +326,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
val bolusIob = iobCobCalculator.calculateIobFromBolus().round()
|
||||
val basalIob = iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended().round()
|
||||
|
||||
binding.bolusIobInsulin.text = rh.gs(R.string.formatinsulinunits, -bolusIob.iob)
|
||||
binding.basalIobInsulin.text = rh.gs(R.string.formatinsulinunits, -basalIob.basaliob)
|
||||
binding.iobInsulin.text = rh.gs(R.string.formatinsulinunits, -bolusIob.iob - basalIob.basaliob)
|
||||
|
||||
calculateInsulin()
|
||||
|
||||
|
@ -378,8 +388,8 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
wizard = BolusWizard(injector).doCalc(specificProfile, profileName, tempTarget, carbsAfterConstraint, cob, bg, correction, sp.getInt(R.string.key_boluswizard_percentage, 100),
|
||||
binding.bgCheckbox.isChecked,
|
||||
binding.cobCheckbox.isChecked,
|
||||
binding.bolusIobCheckbox.isChecked,
|
||||
binding.basalIobCheckbox.isChecked,
|
||||
binding.iobCheckbox.isChecked,
|
||||
binding.iobCheckbox.isChecked,
|
||||
binding.sbCheckbox.isChecked,
|
||||
binding.ttCheckbox.isChecked,
|
||||
binding.bgTrendCheckbox.isChecked,
|
||||
|
@ -397,8 +407,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
binding.carbs.text = String.format(rh.gs(R.string.format_carbs_ic), carbs.toDouble(), wizard.ic)
|
||||
binding.carbsInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromCarbs)
|
||||
|
||||
binding.bolusIobInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromBolusIOB)
|
||||
binding.basalIobInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromBasalIOB)
|
||||
binding.iobInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromBolusIOB + wizard.insulinFromBasalIOB)
|
||||
|
||||
binding.correctionInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromCorrection)
|
||||
|
||||
|
|
|
@ -266,12 +266,55 @@
|
|||
android:contentDescription="@string/show_calculation"
|
||||
app:srcCompat="@drawable/ic_visibility" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bg_enabled_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingStart="-11dp"
|
||||
android:paddingEnd="-11dp"
|
||||
android:scaleX="0.5"
|
||||
android:scaleY="0.5"
|
||||
app:srcCompat="@drawable/ic_xdrip"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/trend_enabled_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingStart="-11dp"
|
||||
android:paddingEnd="-11dp"
|
||||
android:scaleX="0.5"
|
||||
android:scaleY="0.5"
|
||||
app:srcCompat="@drawable/ic_fortyfiveup" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iob_enabled_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingStart="-11dp"
|
||||
android:paddingEnd="-11dp"
|
||||
android:scaleX="0.5"
|
||||
android:scaleY="0.5"
|
||||
app:srcCompat="@drawable/ic_bolus" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cob_enabled_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingStart="-11dp"
|
||||
android:paddingEnd="-11dp"
|
||||
android:scaleX="0.5"
|
||||
android:scaleY="0.5"
|
||||
app:srcCompat="@drawable/ic_cp_bolus_carbs" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel"
|
||||
style="@style/mdtp_ActionButton.Text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/mdtp_cancel"
|
||||
android:textAlignment="textEnd" />
|
||||
|
@ -281,7 +324,7 @@
|
|||
style="@style/mdtp_ActionButton.Text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="@string/mdtp_ok" />
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -532,7 +575,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/bolus_iob_checkbox"
|
||||
android:id="@+id/iob_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="32dp"
|
||||
|
@ -542,7 +585,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="130dp"
|
||||
android:text="@string/bolus_iob_label"
|
||||
android:text="@string/iob"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
|
@ -553,42 +596,7 @@
|
|||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bolus_iob_insulin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="50dp"
|
||||
android:gravity="end"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/basal_iob_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="32dp"
|
||||
android:checked="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="130dp"
|
||||
android:text="@string/treatments_wizard_basaliob_label"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:width="50dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/basal_iob_insulin"
|
||||
android:id="@+id/iob_insulin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="50dp"
|
||||
|
|
|
@ -2,10 +2,8 @@ package info.nightscout.androidaps.database.daos
|
|||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import info.nightscout.androidaps.database.TABLE_GLUCOSE_VALUES
|
||||
import info.nightscout.androidaps.database.TABLE_TEMPORARY_BASALS
|
||||
import info.nightscout.androidaps.database.embedments.InterfaceIDs
|
||||
import info.nightscout.androidaps.database.entities.GlucoseValue
|
||||
import info.nightscout.androidaps.database.entities.TemporaryBasal
|
||||
import io.reactivex.Maybe
|
||||
import io.reactivex.Single
|
||||
|
|
Loading…
Reference in a new issue