Merge pull request #1253 from Andries-Smit/a11y/treatment-dialog
Improve a11y wizard dialog
This commit is contained in:
commit
6499fe053f
15 changed files with 292 additions and 201 deletions
|
@ -4,11 +4,7 @@ import android.content.Context
|
|||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import android.view.*
|
||||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import android.widget.ArrayAdapter
|
||||
|
@ -136,33 +132,36 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
val maxCorrection = constraintChecker.getMaxBolusAllowed().value()
|
||||
bolusStep = activePlugin.activePump.pumpDescription.bolusStep
|
||||
|
||||
if (profileFunction.getUnits() == GlucoseUnit.MGDL)
|
||||
binding.bgInput.setParams(savedInstanceState?.getDouble("bg_input")
|
||||
?: 0.0, 0.0, 500.0, 1.0, DecimalFormat("0"), false, binding.ok, timeTextWatcher)
|
||||
else
|
||||
binding.bgInput.setParams(savedInstanceState?.getDouble("bg_input")
|
||||
?: 0.0, 0.0, 30.0, 0.1, DecimalFormat("0.0"), false, binding.ok, textWatcher)
|
||||
if (profileFunction.getUnits() == GlucoseUnit.MGDL) {
|
||||
binding.bgInput.setParams(
|
||||
savedInstanceState?.getDouble("bg_input")
|
||||
?: 0.0, 0.0, 500.0, 1.0, DecimalFormat("0"), false, binding.okcancel.ok, timeTextWatcher)
|
||||
} else {
|
||||
binding.bgInput.setParams(
|
||||
savedInstanceState?.getDouble("bg_input")
|
||||
?: 0.0, 0.0, 30.0, 0.1, DecimalFormat("0.0"), false, binding.okcancel.ok, textWatcher)
|
||||
}
|
||||
binding.carbsInput.setParams(savedInstanceState?.getDouble("carbs_input")
|
||||
?: 0.0, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false, binding.ok, textWatcher)
|
||||
?: 0.0, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher)
|
||||
|
||||
if (correctionPercent) {
|
||||
calculatedPercentage = sp.getInt(R.string.key_boluswizard_percentage, 100).toDouble()
|
||||
binding.correctionInput.setParams(calculatedPercentage, 10.0, 200.0, 1.0, DecimalFormat("0"), false, binding.ok, textWatcher)
|
||||
binding.correctionInput.setParams(calculatedPercentage, 10.0, 200.0, 1.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher)
|
||||
binding.correctionInput.value = calculatedPercentage
|
||||
binding.correctionUnit.text = "%"
|
||||
} else {
|
||||
binding.correctionInput.setParams(
|
||||
savedInstanceState?.getDouble("correction_input")
|
||||
?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.ok, textWatcher)
|
||||
?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.okcancel.ok, textWatcher)
|
||||
binding.correctionUnit.text = rh.gs(R.string.insulin_unit_shortname)
|
||||
}
|
||||
binding.carbTimeInput.setParams(savedInstanceState?.getDouble("carb_time_input")
|
||||
?: 0.0, -60.0, 60.0, 5.0, DecimalFormat("0"), false, binding.ok, timeTextWatcher)
|
||||
?: 0.0, -60.0, 60.0, 5.0, DecimalFormat("0"), false, binding.okcancel.ok, timeTextWatcher)
|
||||
initDialog()
|
||||
calculatedPercentage = sp.getInt(R.string.key_boluswizard_percentage, 100).toDouble()
|
||||
binding.percentUsed.text = rh.gs(R.string.format_percent, sp.getInt(R.string.key_boluswizard_percentage, 100))
|
||||
// ok button
|
||||
binding.ok.setOnClickListener {
|
||||
binding.okcancel.ok.setOnClickListener {
|
||||
if (okClicked) {
|
||||
aapsLogger.debug(LTag.UI, "guarding: ok already clicked")
|
||||
} else {
|
||||
|
@ -175,12 +174,12 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
}
|
||||
dismiss()
|
||||
}
|
||||
binding.bgEnabledIcon.setOnClickListener { binding.bgCheckbox.isChecked = !binding.bgCheckbox.isChecked }
|
||||
binding.trendEnabledIcon.setOnClickListener { binding.bgTrendCheckbox.isChecked = !binding.bgTrendCheckbox.isChecked }
|
||||
binding.cobEnabledIcon.setOnClickListener { binding.cobCheckbox.isChecked = !binding.cobCheckbox.isChecked; processCobCheckBox(); }
|
||||
binding.iobEnabledIcon.setOnClickListener { if (!binding.cobCheckbox.isChecked) binding.iobCheckbox.isChecked = !binding.iobCheckbox.isChecked }
|
||||
binding.bgCheckboxIcon.setOnClickListener { binding.bgCheckbox.isChecked = !binding.bgCheckbox.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 }
|
||||
// cancel button
|
||||
binding.cancel.setOnClickListener {
|
||||
binding.okcancel.cancel.setOnClickListener {
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled: ${this.javaClass.name}")
|
||||
dismiss()
|
||||
}
|
||||
|
@ -212,11 +211,17 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
sp.putBoolean(rh.gs(R.string.key_wizard_correction_percent), isChecked)
|
||||
binding.correctionUnit.text = if (isChecked) "%" else rh.gs(R.string.insulin_unit_shortname)
|
||||
correctionPercent = binding.correctionPercent.isChecked
|
||||
if (correctionPercent)
|
||||
binding.correctionInput.setParams(calculatedPercentage, 10.0, 200.0, 1.0, DecimalFormat("0"), false, binding.ok, textWatcher)
|
||||
else
|
||||
binding.correctionInput.setParams(savedInstanceState?.getDouble("correction_input")
|
||||
?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.ok, textWatcher)
|
||||
if (correctionPercent) {
|
||||
binding.correctionInput.setParams(calculatedPercentage, 10.0, 200.0, 1.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher)
|
||||
binding.correctionInput.customContentDescription = rh.gs(R.string.a11_correction_percentage)
|
||||
} else {
|
||||
binding.correctionInput.setParams(
|
||||
savedInstanceState?.getDouble("correction_input")
|
||||
?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.okcancel.ok, textWatcher
|
||||
)
|
||||
binding.correctionInput.customContentDescription = rh.gs(R.string.a11_correction_units)
|
||||
}
|
||||
binding.correctionInput.updateA11yDescription()
|
||||
binding.correctionInput.value = if (correctionPercent) calculatedPercentage else Round.roundTo(calculatedCorrection, bolusStep)
|
||||
}
|
||||
}
|
||||
|
@ -224,12 +229,12 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
binding.profile.onItemSelectedListener = object : OnItemSelectedListener {
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
ToastUtils.showToastInUiThread(ctx, rh.gs(R.string.noprofileset))
|
||||
binding.ok.visibility = View.GONE
|
||||
binding.okcancel.ok.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
calculateInsulin()
|
||||
binding.ok.visibility = View.VISIBLE
|
||||
binding.okcancel.ok.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
// bus
|
||||
|
@ -241,6 +246,14 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
}, fabricPrivacy::logException)
|
||||
)
|
||||
|
||||
setA11yLabels()
|
||||
}
|
||||
|
||||
private fun setA11yLabels() {
|
||||
binding.bgInput.editText?.id?.let { binding.bgInputLabel.labelFor = it }
|
||||
binding.carbsInput.editText?.id?.let { binding.carbsInputLabel.labelFor = it }
|
||||
binding.correctionInput.editText?.id?.let { binding.correctionInputLabel.labelFor = it }
|
||||
binding.carbTimeInput.editText?.id?.let { binding.carbTimeInputLabel.labelFor = it }
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -268,14 +281,14 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
}
|
||||
|
||||
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()
|
||||
binding.bgCheckboxIcon.alpha = if (binding.bgCheckbox.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.trendCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
binding.iobCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
binding.cobCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility()
|
||||
}
|
||||
|
||||
private fun saveCheckedStates() {
|
||||
|
@ -442,10 +455,10 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
val insulinText = if (wizard.calculatedTotalInsulin > 0.0) rh.gs(R.string.formatinsulinunits, wizard.calculatedTotalInsulin).formatColor(rh, R.color.bolus) else ""
|
||||
val carbsText = if (carbsAfterConstraint > 0.0) rh.gs(R.string.format_carbs, carbsAfterConstraint).formatColor(rh, R.color.carbs) else ""
|
||||
binding.total.text = HtmlHelper.fromHtml(rh.gs(R.string.result_insulin_carbs, insulinText, carbsText))
|
||||
binding.ok.visibility = View.VISIBLE
|
||||
binding.okcancel.ok.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.total.text = HtmlHelper.fromHtml(rh.gs(R.string.missing_carbs, wizard.carbsEquivalent.toInt()).formatColor(rh, R.color.carbs))
|
||||
binding.ok.visibility = View.INVISIBLE
|
||||
binding.okcancel.ok.visibility = View.INVISIBLE
|
||||
}
|
||||
binding.percentUsed.text = rh.gs(R.string.format_percent, wizard.percentageCorrection)
|
||||
calculatedPercentage = wizard.calculatedPercentage
|
||||
|
|
|
@ -347,6 +347,8 @@ class BolusWizard @Inject constructor(
|
|||
)
|
||||
else
|
||||
commonProcessing(ctx)
|
||||
} else {
|
||||
OKDialog.show(ctx, rh.gs(R.string.boluswizard), rh.gs(R.string.no_action_selected))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
7
app/src/main/res/drawable/cb_backgroud_bg.xml
Normal file
7
app/src/main/res/drawable/cb_backgroud_bg.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_xdrip" />
|
||||
</layer-list>
|
7
app/src/main/res/drawable/cb_backgroud_cob.xml
Normal file
7
app/src/main/res/drawable/cb_backgroud_cob.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_cp_bolus_carbs" />
|
||||
</layer-list>
|
7
app/src/main/res/drawable/cb_backgroud_iob.xml
Normal file
7
app/src/main/res/drawable/cb_backgroud_iob.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_bolus" />
|
||||
</layer-list>
|
7
app/src/main/res/drawable/cb_backgroud_trend.xml
Normal file
7
app/src/main/res/drawable/cb_backgroud_trend.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_fortyfiveup" />
|
||||
</layer-list>
|
4
app/src/main/res/drawable/checkbox_bg_icon.xml
Normal file
4
app/src/main/res/drawable/checkbox_bg_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_backgroud_bg" />
|
||||
</selector>
|
4
app/src/main/res/drawable/checkbox_cob_icon.xml
Normal file
4
app/src/main/res/drawable/checkbox_cob_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_backgroud_cob" />
|
||||
</selector>
|
4
app/src/main/res/drawable/checkbox_iob_icon.xml
Normal file
4
app/src/main/res/drawable/checkbox_iob_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_backgroud_iob" />
|
||||
</selector>
|
4
app/src/main/res/drawable/checkbox_trend_icon.xml
Normal file
4
app/src/main/res/drawable/checkbox_trend_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_backgroud_trend" />
|
||||
</selector>
|
|
@ -59,6 +59,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bg_input_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -70,7 +71,8 @@
|
|||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/bg_input"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
android:layout_height="40dp"
|
||||
app:customContentDescription="@string/a11y_current_bg" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bg_units"
|
||||
|
@ -89,9 +91,11 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/carbs_input_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:labelFor="@id/carbs_input"
|
||||
android:padding="10dp"
|
||||
android:text="@string/treatments_wizard_carbs_label"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
|
@ -101,8 +105,8 @@
|
|||
android:id="@+id/carbs_input"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:customContentDescription="@string/treatments_wizard_carbs_label" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -127,6 +131,7 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/correction_input_label"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -135,32 +140,26 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text=" %"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textStyle="bold"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/correction_percent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="false"
|
||||
android:padding="2dp" />
|
||||
android:layoutDirection="rtl"
|
||||
android:padding="2dp"
|
||||
android:text="%"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/correction_input"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:customContentDescription="@string/a11_correction_units" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/correction_unit"
|
||||
|
@ -255,77 +254,48 @@
|
|||
<CheckBox
|
||||
android:id="@+id/calculation_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="false" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="false"
|
||||
android:contentDescription="@string/show_calculation"
|
||||
app:srcCompat="@drawable/ic_visibility" />
|
||||
android:drawableEnd="@drawable/ic_visibility" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bg_enabled_icon"
|
||||
<CheckBox
|
||||
android:id="@+id/bg_checkbox_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"/>
|
||||
android:layout_height="fill_parent"
|
||||
android:button="@drawable/checkbox_bg_icon"
|
||||
android:checked="true"
|
||||
android:contentDescription="@string/treatments_wizard_bg_label" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/trend_enabled_icon"
|
||||
<CheckBox
|
||||
android:id="@+id/trend_checkbox_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" />
|
||||
android:layout_height="fill_parent"
|
||||
android:button="@drawable/checkbox_trend_icon"
|
||||
android:checked="true"
|
||||
android:contentDescription="@string/bg_trend_label" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iob_enabled_icon"
|
||||
<CheckBox
|
||||
android:id="@+id/iob_checkbox_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" />
|
||||
android:layout_height="fill_parent"
|
||||
android:button="@drawable/checkbox_iob_icon"
|
||||
android:checked="true"
|
||||
android:contentDescription="@string/iob" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cob_enabled_icon"
|
||||
<CheckBox
|
||||
android:id="@+id/cob_checkbox_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" />
|
||||
android:layout_height="fill_parent"
|
||||
android:button="@drawable/checkbox_cob_icon"
|
||||
android:checked="true"
|
||||
android:contentDescription="@string/treatments_wizard_cob_label" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel"
|
||||
style="@style/mdtp_ActionButton.Text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/mdtp_cancel"
|
||||
android:textAlignment="textEnd" />
|
||||
<include
|
||||
android:id="@+id/okcancel"
|
||||
layout="@layout/okcancel" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/ok"
|
||||
style="@style/mdtp_ActionButton.Text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="@string/mdtp_ok" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
|
@ -350,6 +320,7 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/carb_time_input_label"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -360,27 +331,23 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/alarm"
|
||||
android:src="@drawable/ic_access_alarm_24dp" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/alarm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="false"
|
||||
android:contentDescription="set carb timer alarm"
|
||||
android:drawableEnd="@drawable/ic_access_alarm_24dp"
|
||||
android:layoutDirection="rtl"
|
||||
android:padding="2dp" />
|
||||
|
||||
<info.nightscout.androidaps.utils.ui.NumberPicker
|
||||
android:id="@+id/carb_time_input"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center" />
|
||||
android:layout_gravity="center"
|
||||
app:contentDescription="carb time" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -402,6 +369,7 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@id/profile"
|
||||
android:padding="10dp"
|
||||
android:text="@string/profile_label"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
|
@ -414,7 +382,6 @@
|
|||
android:layout_gravity="center_vertical|center_horizontal"
|
||||
android:layout_weight="0.5" />
|
||||
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/sb_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -445,38 +412,24 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/bg_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="32dp"
|
||||
android:checked="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="24dp"
|
||||
android:text="@string/treatments_wizard_bg_label"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
android:checked="true"
|
||||
android:text="@string/treatments_wizard_bg_label" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/tt_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="32dp"
|
||||
android:checked="false" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="30dp"
|
||||
android:text="@string/treatments_wizard_tt_label"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
android:checked="false"
|
||||
android:text="@string/treatments_wizard_tt_label" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -506,15 +459,9 @@
|
|||
android:id="@+id/bg_trend_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="32dp"
|
||||
android:checked="false" />
|
||||
android:checked="false"
|
||||
android:text="@string/bg_trend_label" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="86dp"
|
||||
android:text="@string/bg_trend_label"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bg_trend"
|
||||
|
@ -542,15 +489,8 @@
|
|||
android:id="@+id/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/iob"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
android:checked="true"
|
||||
android:text="@string/iob" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -578,14 +518,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="32dp"
|
||||
android:checked="false" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:width="86dp"
|
||||
android:text="@string/treatments_wizard_cob_label"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
android:checked="false"
|
||||
android:text="@string/treatments_wizard_cob_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cob"
|
||||
|
@ -607,7 +541,13 @@
|
|||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -621,6 +561,8 @@
|
|||
android:text="@string/treatments_wizard_carbs_label"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/carbs"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -642,7 +584,13 @@
|
|||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -656,6 +604,8 @@
|
|||
android:text="@string/superbolus"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sb"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -676,7 +626,13 @@
|
|||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -690,6 +646,8 @@
|
|||
android:text="@string/treatments_wizard_correction_label"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -704,6 +662,7 @@
|
|||
android:width="50dp"
|
||||
android:gravity="end"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
|
|
@ -1141,6 +1141,27 @@
|
|||
<string name="key_last_processed_glunovo_timestamp" translatable="false">last_processed_glunovo_timestamp</string>
|
||||
<string name="identification">Identification (email, FB or Discord nick etc)</string>
|
||||
<string name="identification_not_set">Identification not set in dev mode</string>
|
||||
<string name="a11y_high">heigh</string>
|
||||
<string name="a11y_inrange">in range</string>
|
||||
<string name="a11y_low">low</string>
|
||||
<string name="a11y_arrow_double_down">down fast</string>
|
||||
<string name="a11y_arrow_single_down">down</string>
|
||||
<string name="a11y_arrow_forty_five_down">down trending</string>
|
||||
<string name="a11y_arrow_flat">flat</string>
|
||||
<string name="a11y_arrow_forty_five_up">up trending</string>
|
||||
<string name="a11y_arrow_single_up">up</string>
|
||||
<string name="a11y_arrow_double_up">up fast</string>
|
||||
<string name="a11y_arrow_none">none</string>
|
||||
<string name="a11y_arrow_unknown">unknown</string>
|
||||
<string name="a11y_graph">graph</string>
|
||||
<string name="a11y_bg_quality">Blood glucose quality</string>
|
||||
<string name="a11_bg_quality_recalculated">recalculated</string>
|
||||
<string name="a11_bg_quality_doubles">double entries</string>
|
||||
<string name="a11y_insulin_label">insulin</string>
|
||||
<string name="a11y_dialog">dialog</string>
|
||||
<string name="a11y_current_bg">current blood glucode</string>
|
||||
<string name="a11_correction_percentage">correct outcome with %</string>
|
||||
<string name="a11_correction_units">correct outcome with units</string>
|
||||
<string name="not_available_full">Not available</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -15,6 +15,8 @@ import android.view.MotionEvent
|
|||
import android.view.View
|
||||
import android.view.View.OnFocusChangeListener
|
||||
import android.view.View.OnTouchListener
|
||||
import android.view.accessibility.AccessibilityEvent
|
||||
import android.view.accessibility.AccessibilityManager
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
|
@ -50,6 +52,7 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
protected var focused = false
|
||||
private var mUpdater: ScheduledExecutorService? = null
|
||||
private var mOnValueChangedListener: OnValueChangedListener? = null
|
||||
private var mCustomContentDescription: String? = null
|
||||
|
||||
private var mHandler: Handler = Handler(Looper.getMainLooper(), Handler.Callback { msg: Message ->
|
||||
when (msg.what) {
|
||||
|
@ -86,6 +89,13 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
}
|
||||
}
|
||||
|
||||
var customContentDescription: String?
|
||||
get() = mCustomContentDescription
|
||||
set(value) {
|
||||
mCustomContentDescription = value
|
||||
updateA11yDescription()
|
||||
}
|
||||
|
||||
protected open fun inflate(context: Context) {
|
||||
LayoutInflater.from(context).inflate(R.layout.number_picker_layout, this, true)
|
||||
}
|
||||
|
@ -121,6 +131,29 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
if (!focused) value // check min/max
|
||||
updateEditText()
|
||||
}
|
||||
updateA11yDescription()
|
||||
}
|
||||
|
||||
fun updateA11yDescription() {
|
||||
val description = if (mCustomContentDescription != null) mCustomContentDescription else ""
|
||||
minusButton?.contentDescription = context.getString(R.string.a11y_min_button_description, description, formatter?.format(this.step))
|
||||
plusButton?.contentDescription = context.getString(R.string.a11y_plus_button_description, description, formatter?.format(this.step))
|
||||
}
|
||||
|
||||
fun announceValue() {
|
||||
val manager: AccessibilityManager = context
|
||||
.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
|
||||
if (manager.isEnabled) {
|
||||
val valueDescription = formatter?.format(currentValue)
|
||||
AccessibilityEvent.obtain().apply {
|
||||
eventType = AccessibilityEvent.TYPE_ANNOUNCEMENT
|
||||
className = javaClass.name
|
||||
packageName = context.packageName
|
||||
text.add(valueDescription)
|
||||
}.also {
|
||||
manager.sendAccessibilityEvent(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setTag(tag: Any) {
|
||||
|
@ -173,6 +206,7 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
this.okButton = okButton
|
||||
editText?.keyListener = DigitsKeyListenerWithComma.getInstance(minValue < 0, step != round(step))
|
||||
if (watcher != null) editText?.removeTextChangedListener(watcher)
|
||||
updateA11yDescription()
|
||||
updateEditText()
|
||||
if (watcher != null) editText?.addTextChangedListener(watcher)
|
||||
}
|
||||
|
@ -253,6 +287,7 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
private fun stopUpdating() {
|
||||
mUpdater?.shutdownNow()
|
||||
mUpdater = null
|
||||
announceValue()
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
|
@ -265,6 +300,7 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
} else {
|
||||
dec(1)
|
||||
}
|
||||
announceValue()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,5 +335,16 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
|
||||
init {
|
||||
initialize(context)
|
||||
context.theme.obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.NumberPicker,
|
||||
0, 0).apply {
|
||||
|
||||
try {
|
||||
mCustomContentDescription = getString(R.styleable.NumberPicker_customContentDescription)
|
||||
} finally {
|
||||
recycle()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,4 +4,7 @@
|
|||
<attr name="dialogTitleColor" format="reference" />
|
||||
<attr name="dialogTitleIconTint" format="reference" />
|
||||
|
||||
<declare-styleable name="NumberPicker">
|
||||
<attr name="customContentDescription" format="string" />
|
||||
</declare-styleable>
|
||||
</resources>
|
|
@ -540,6 +540,8 @@
|
|||
<string name="bolus_ok" comment="26 characters max for translation">Bolus OK</string>
|
||||
<string name="pump_paired" comment="26 characters max for translation">Pump paired</string>
|
||||
<string name="insight_refresh_button" comment="26 characters max for translation">Insight Refresh Button</string>
|
||||
<string name="a11y_min_button_description">decrement %1$s by %2$s</string>
|
||||
<string name="a11y_plus_button_description">increment %1$s by %2$s</string>
|
||||
|
||||
<plurals name="days">
|
||||
<item quantity="one">%1$d day</item>
|
||||
|
|
Loading…
Reference in a new issue