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?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?): View {
|
savedInstanceState: Bundle?): View {
|
||||||
this.arguments?.let { bundle ->
|
this.arguments?.let { bundle ->
|
||||||
carbsPassedIntoWizard = bundle.getInt("carbs_input")?.toDouble()
|
carbsPassedIntoWizard = bundle.getInt("carbs_input").toDouble()
|
||||||
notesPassedIntoWizard = bundle.getString("notes_input").toString()
|
notesPassedIntoWizard = bundle.getString("notes_input").toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,8 +184,7 @@ class WizardDialog : DaggerDialogFragment() {
|
||||||
binding.bgCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
binding.bgCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||||
binding.ttCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
binding.ttCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||||
binding.cobCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
binding.cobCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||||
binding.basalIobCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
binding.iobCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||||
binding.bolusIobCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
|
||||||
binding.bgTrendCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
binding.bgTrendCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||||
binding.sbCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
binding.sbCheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||||
|
|
||||||
|
@ -198,9 +197,12 @@ class WizardDialog : DaggerDialogFragment() {
|
||||||
sp.putBoolean(rh.gs(R.string.key_wizard_calculation_visible), isChecked)
|
sp.putBoolean(rh.gs(R.string.key_wizard_calculation_visible), isChecked)
|
||||||
binding.delimiter.visibility = isChecked.toVisibility()
|
binding.delimiter.visibility = isChecked.toVisibility()
|
||||||
binding.result.visibility = isChecked.toVisibility()
|
binding.result.visibility = isChecked.toVisibility()
|
||||||
|
processEnabledIcons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processEnabledIcons()
|
||||||
|
|
||||||
binding.correctionPercent.setOnCheckedChangeListener {_, isChecked ->
|
binding.correctionPercent.setOnCheckedChangeListener {_, isChecked ->
|
||||||
run {
|
run {
|
||||||
sp.putBoolean(rh.gs(R.string.key_wizard_correction_percent), isChecked)
|
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
|
binding.ttCheckbox.isEnabled = binding.bgCheckbox.isChecked && repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing
|
||||||
if (buttonView.id == binding.cobCheckbox.id)
|
if (buttonView.id == binding.cobCheckbox.id)
|
||||||
processCobCheckBox()
|
processCobCheckBox()
|
||||||
|
processEnabledIcons()
|
||||||
calculateInsulin()
|
calculateInsulin()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processCobCheckBox() {
|
private fun processCobCheckBox() {
|
||||||
if (binding.cobCheckbox.isChecked) {
|
if (binding.cobCheckbox.isChecked) {
|
||||||
binding.bolusIobCheckbox.isEnabled = false
|
binding.iobCheckbox.isEnabled = false
|
||||||
binding.basalIobCheckbox.isEnabled = false
|
binding.iobCheckbox.isChecked = true
|
||||||
binding.bolusIobCheckbox.isChecked = true
|
|
||||||
binding.basalIobCheckbox.isChecked = true
|
|
||||||
} else {
|
} else {
|
||||||
binding.bolusIobCheckbox.isEnabled = true
|
binding.iobCheckbox.isEnabled = true
|
||||||
binding.basalIobCheckbox.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() {
|
private fun saveCheckedStates() {
|
||||||
sp.putBoolean(R.string.key_wizard_include_cob, binding.cobCheckbox.isChecked)
|
sp.putBoolean(R.string.key_wizard_include_cob, binding.cobCheckbox.isChecked)
|
||||||
sp.putBoolean(R.string.key_wizard_include_trend_bg, binding.bgTrendCheckbox.isChecked)
|
sp.putBoolean(R.string.key_wizard_include_trend_bg, binding.bgTrendCheckbox.isChecked)
|
||||||
|
@ -284,8 +295,8 @@ class WizardDialog : DaggerDialogFragment() {
|
||||||
if(carbsPassedIntoWizard != 0.0) {
|
if(carbsPassedIntoWizard != 0.0) {
|
||||||
binding.carbsInput.value = carbsPassedIntoWizard
|
binding.carbsInput.value = carbsPassedIntoWizard
|
||||||
}
|
}
|
||||||
if(!notesPassedIntoWizard.isBlank()) {
|
if(notesPassedIntoWizard.isNotBlank()) {
|
||||||
binding.notes.setText(notesPassedIntoWizard.toString())
|
binding.notes.setText(notesPassedIntoWizard)
|
||||||
}
|
}
|
||||||
val profile = profileFunction.getProfile()
|
val profile = profileFunction.getProfile()
|
||||||
val profileStore = activePlugin.activeProfileSource.profile
|
val profileStore = activePlugin.activeProfileSource.profile
|
||||||
|
@ -315,8 +326,7 @@ class WizardDialog : DaggerDialogFragment() {
|
||||||
val bolusIob = iobCobCalculator.calculateIobFromBolus().round()
|
val bolusIob = iobCobCalculator.calculateIobFromBolus().round()
|
||||||
val basalIob = iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended().round()
|
val basalIob = iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended().round()
|
||||||
|
|
||||||
binding.bolusIobInsulin.text = rh.gs(R.string.formatinsulinunits, -bolusIob.iob)
|
binding.iobInsulin.text = rh.gs(R.string.formatinsulinunits, -bolusIob.iob - basalIob.basaliob)
|
||||||
binding.basalIobInsulin.text = rh.gs(R.string.formatinsulinunits, -basalIob.basaliob)
|
|
||||||
|
|
||||||
calculateInsulin()
|
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),
|
wizard = BolusWizard(injector).doCalc(specificProfile, profileName, tempTarget, carbsAfterConstraint, cob, bg, correction, sp.getInt(R.string.key_boluswizard_percentage, 100),
|
||||||
binding.bgCheckbox.isChecked,
|
binding.bgCheckbox.isChecked,
|
||||||
binding.cobCheckbox.isChecked,
|
binding.cobCheckbox.isChecked,
|
||||||
binding.bolusIobCheckbox.isChecked,
|
binding.iobCheckbox.isChecked,
|
||||||
binding.basalIobCheckbox.isChecked,
|
binding.iobCheckbox.isChecked,
|
||||||
binding.sbCheckbox.isChecked,
|
binding.sbCheckbox.isChecked,
|
||||||
binding.ttCheckbox.isChecked,
|
binding.ttCheckbox.isChecked,
|
||||||
binding.bgTrendCheckbox.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.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.carbsInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromCarbs)
|
||||||
|
|
||||||
binding.bolusIobInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromBolusIOB)
|
binding.iobInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromBolusIOB + wizard.insulinFromBasalIOB)
|
||||||
binding.basalIobInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromBasalIOB)
|
|
||||||
|
|
||||||
binding.correctionInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromCorrection)
|
binding.correctionInsulin.text = rh.gs(R.string.formatinsulinunits, wizard.insulinFromCorrection)
|
||||||
|
|
||||||
|
|
|
@ -266,12 +266,55 @@
|
||||||
android:contentDescription="@string/show_calculation"
|
android:contentDescription="@string/show_calculation"
|
||||||
app:srcCompat="@drawable/ic_visibility" />
|
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
|
<Button
|
||||||
android:id="@+id/cancel"
|
android:id="@+id/cancel"
|
||||||
style="@style/mdtp_ActionButton.Text"
|
style="@style/mdtp_ActionButton.Text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/mdtp_cancel"
|
android:text="@string/mdtp_cancel"
|
||||||
android:textAlignment="textEnd" />
|
android:textAlignment="textEnd" />
|
||||||
|
@ -281,7 +324,7 @@
|
||||||
style="@style/mdtp_ActionButton.Text"
|
style="@style/mdtp_ActionButton.Text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:text="@string/mdtp_ok" />
|
android:text="@string/mdtp_ok" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -532,7 +575,7 @@
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/bolus_iob_checkbox"
|
android:id="@+id/iob_checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:width="32dp"
|
android:width="32dp"
|
||||||
|
@ -542,7 +585,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:width="130dp"
|
android:width="130dp"
|
||||||
android:text="@string/bolus_iob_label"
|
android:text="@string/iob"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -553,42 +596,7 @@
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bolus_iob_insulin"
|
android:id="@+id/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:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:width="50dp"
|
android:width="50dp"
|
||||||
|
|
|
@ -2,10 +2,8 @@ package info.nightscout.androidaps.database.daos
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
import androidx.room.Query
|
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.TABLE_TEMPORARY_BASALS
|
||||||
import info.nightscout.androidaps.database.embedments.InterfaceIDs
|
import info.nightscout.androidaps.database.embedments.InterfaceIDs
|
||||||
import info.nightscout.androidaps.database.entities.GlucoseValue
|
|
||||||
import info.nightscout.androidaps.database.entities.TemporaryBasal
|
import info.nightscout.androidaps.database.entities.TemporaryBasal
|
||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
|
|
Loading…
Reference in a new issue