Merge pull request #1337 from Philoul/New/WizardIcons
Wizard Dialog Add TT Icon + Iob icon/checkbox always enabled
This commit is contained in:
commit
c81ff64777
4 changed files with 41 additions and 6 deletions
|
@ -175,9 +175,10 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
dismiss()
|
||||
}
|
||||
binding.bgCheckboxIcon.setOnClickListener { binding.bgCheckbox.isChecked = !binding.bgCheckbox.isChecked }
|
||||
binding.ttCheckboxIcon.setOnClickListener { binding.ttCheckbox.isChecked = !binding.ttCheckbox.isChecked }
|
||||
binding.trendCheckboxIcon.setOnClickListener { binding.bgTrendCheckbox.isChecked = !binding.bgTrendCheckbox.isChecked }
|
||||
binding.cobCheckboxIcon.setOnClickListener { binding.cobCheckbox.isChecked = !binding.cobCheckbox.isChecked; processCobCheckBox(); }
|
||||
binding.iobCheckboxIcon.setOnClickListener { if (!binding.cobCheckbox.isChecked) binding.iobCheckbox.isChecked = !binding.iobCheckbox.isChecked }
|
||||
binding.iobCheckboxIcon.setOnClickListener { binding.iobCheckbox.isChecked = !binding.iobCheckbox.isChecked; processIobCheckBox(); }
|
||||
// cancel button
|
||||
binding.okcancel.cancel.setOnClickListener {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled: ${this.javaClass.name}")
|
||||
|
@ -265,35 +266,42 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
private fun onCheckedChanged(buttonView: CompoundButton, @Suppress("UNUSED_PARAMETER") state: Boolean) {
|
||||
saveCheckedStates()
|
||||
binding.ttCheckbox.isEnabled = binding.bgCheckbox.isChecked && repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing
|
||||
binding.ttCheckboxIcon.visibility = binding.ttCheckbox.isEnabled.toVisibility()
|
||||
if (buttonView.id == binding.cobCheckbox.id)
|
||||
processCobCheckBox()
|
||||
if (buttonView.id == binding.iobCheckbox.id)
|
||||
processIobCheckBox()
|
||||
processEnabledIcons()
|
||||
calculateInsulin()
|
||||
}
|
||||
|
||||
private fun processCobCheckBox() {
|
||||
if (binding.cobCheckbox.isChecked) {
|
||||
binding.iobCheckbox.isEnabled = false
|
||||
binding.iobCheckboxIcon.isEnabled = false
|
||||
binding.iobCheckbox.isChecked = true
|
||||
} else {
|
||||
binding.iobCheckbox.isEnabled = true
|
||||
binding.iobCheckboxIcon.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun processIobCheckBox() {
|
||||
if (!binding.iobCheckbox.isChecked) {
|
||||
binding.cobCheckbox.isChecked = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun processEnabledIcons() {
|
||||
binding.bgCheckboxIcon.isChecked = binding.bgCheckbox.isChecked
|
||||
binding.ttCheckboxIcon.isChecked = binding.ttCheckbox.isChecked
|
||||
binding.trendCheckboxIcon.isChecked = binding.bgTrendCheckbox.isChecked
|
||||
binding.iobCheckboxIcon.isChecked = binding.iobCheckbox.isChecked
|
||||
binding.cobCheckboxIcon.isChecked = binding.cobCheckbox.isChecked
|
||||
|
||||
binding.bgCheckboxIcon.alpha = if (binding.bgCheckbox.isChecked) 1.0f else 0.2f
|
||||
binding.ttCheckboxIcon.alpha = if (binding.ttCheckbox.isChecked) 1.0f else 0.2f
|
||||
binding.trendCheckboxIcon.alpha = if (binding.bgTrendCheckbox.isChecked) 1.0f else 0.2f
|
||||
binding.iobCheckboxIcon.alpha = if (binding.iobCheckbox.isChecked) 1.0f else 0.2f
|
||||
binding.cobCheckboxIcon.alpha = if (binding.cobCheckbox.isChecked) 1.0f else 0.2f
|
||||
|
||||
binding.bgCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
binding.ttCheckboxIcon.visibility = (binding.calculationCheckbox.isChecked.not() && binding.ttCheckbox.isEnabled).toVisibility()
|
||||
binding.trendCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
binding.iobCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
binding.cobCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
|
@ -345,7 +353,9 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
|
||||
// Set BG if not old
|
||||
binding.bgInput.value = iobCobCalculator.ads.actualBg()?.valueToUnits(units) ?: 0.0
|
||||
|
||||
binding.ttCheckbox.isEnabled = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing
|
||||
binding.ttCheckboxIcon.visibility = binding.ttCheckbox.isEnabled.toVisibility()
|
||||
|
||||
// IOB calculation
|
||||
val bolusIob = iobCobCalculator.calculateIobFromBolus().round()
|
||||
|
|
7
app/src/main/res/drawable/cb_background_tt.xml
Normal file
7
app/src/main/res/drawable/cb_background_tt.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:width="26dp"
|
||||
android:height="26dp"
|
||||
android:drawable="@drawable/ic_temptarget_high" />
|
||||
</layer-list>
|
4
app/src/main/res/drawable/checkbox_tt_icon.xml
Normal file
4
app/src/main/res/drawable/checkbox_tt_icon.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:drawable="@drawable/cb_background_tt" />
|
||||
</selector>
|
|
@ -262,6 +262,20 @@
|
|||
android:checked="true"
|
||||
android:contentDescription="@string/treatments_wizard_bg_label" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tt_checkbox_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:scaleX="0.7"
|
||||
android:scaleY="0.7"
|
||||
android:button="@drawable/checkbox_tt_icon"
|
||||
android:checked="true"
|
||||
android:visibility="gone"
|
||||
android:contentDescription="@string/treatments_wizard_tt_label" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/trend_checkbox_icon"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Loading…
Reference in a new issue