Add Sensor Battery Level information

It works with xDrip and Miaomiao2, but today there is a bug in xDrip (xDrip sends Phone battery level and not Sensor Battery level...)
This commit is contained in:
Philoul 2020-10-17 22:22:09 +02:00
parent 3f4b3149db
commit 961ee4ccf4
5 changed files with 53 additions and 17 deletions

View file

@ -233,17 +233,21 @@ class ActionsFragment : DaggerFragment() {
actions_canceltempbasal?.visibility = View.GONE
}
}
val activeBgSource = activePlugin.activeBgSource
actions_historybrowser.visibility = (profile != null).toVisibility()
actions_fill?.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized && !pump.isSuspended).toVisibility()
actions_pumpbatterychange?.visibility = pump.pumpDescription.isBatteryReplaceable.toVisibility()
actions_temptarget?.visibility = (profile != null && config.APS).toVisibility()
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
if (!config.NSCLIENT)
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_pbage, careportal_batterylevel)
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_sensorlevel, careportal_pbage, careportal_batterylevel)
else
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, null, careportal_pbage, null)
checkPumpCustomActions()
if (activeBgSource.sensorBatteryLevel == -1)
careportal_senslevellabel?.text = ""
else
careportal_senslevellabel?.text = resourceHelper.gs(R.string.careportal_level_label)
}
private fun checkPumpCustomActions() {

View file

@ -741,7 +741,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
// Status lights
overview_statuslights?.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility()
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_pbage, careportal_batterylevel)
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, null, careportal_pbage, careportal_batterylevel)
// cob
var cobText: String = resourceHelper.gs(R.string.value_unavailable_short)

View file

@ -27,14 +27,20 @@ class StatusLightHandler @Inject constructor(
/**
* applies the extended statusLight subview on the overview fragment
*/
fun updateStatusLights(careportal_canulaage: TextView?, careportal_insulinage: TextView?, careportal_reservoirlevel: TextView?, careportal_sensorage: TextView?, careportal_pbage: TextView?, careportal_batterylevel: TextView?) {
fun updateStatusLights(careportal_canulaage: TextView?, careportal_insulinage: TextView?, careportal_reservoirlevel: TextView?, careportal_sensorage: TextView?, careportal_sensorbatterylevel: TextView?, careportal_pbage: TextView?, careportal_batterylevel: TextView?) {
val pump = activePlugin.activePump
val bgSource = activePlugin.activeBgSource
handleAge(careportal_canulaage, CareportalEvent.SITECHANGE, R.string.key_statuslights_cage_warning, 48.0, R.string.key_statuslights_cage_critical, 72.0)
handleAge(careportal_insulinage, CareportalEvent.INSULINCHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0)
handleAge(careportal_sensorage, CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
handleAge(careportal_pbage, CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)
if (!config.NSCLIENT)
if (!config.NSCLIENT) {
handleLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U")
if (bgSource.sensorBatteryLevel != -1)
handleLevel(careportal_sensorbatterylevel, R.string.key_statuslights_sbat_critical, 5.0, R.string.key_statuslights_sbat_warning, 20.0, bgSource.sensorBatteryLevel.toDouble(), "%")
else
careportal_sensorbatterylevel?.text = ""
}
if (!config.NSCLIENT && pump.model() != PumpType.AccuChekCombo)
handleLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%")
}

View file

@ -191,12 +191,12 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_weight="0"
android:orientation="vertical">
<TextView
android:id="@+id/careportal_sensorage"
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
@ -215,7 +215,7 @@
<TextView
android:id="@+id/careportal_insulinage"
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
@ -234,7 +234,7 @@
<TextView
android:id="@+id/careportal_canulaage"
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
@ -253,7 +253,7 @@
<TextView
android:id="@+id/careportal_pbage"
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
@ -284,9 +284,9 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:paddingStart="15dp"
android:paddingRight="5dp"
android:text=""
android:text="@string/careportal_level_label"
android:textSize="14sp" />
<View
@ -304,7 +304,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:paddingStart="15dp"
android:paddingRight="5dp"
android:text="@string/careportal_level_label"
android:textSize="14sp" />
@ -324,7 +324,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:paddingStart="15dp"
android:paddingRight="5dp"
android:textSize="14sp" />
@ -345,7 +345,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:paddingStart="15dp"
android:paddingRight="5dp"
android:text="@string/careportal_level_label"
android:textSize="14sp" />
@ -363,7 +363,7 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_weight="0"
android:orientation="vertical">
<TextView

View file

@ -360,6 +360,32 @@
validate:minNumber="24"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="25"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
android:key="@string/key_statuslights_sbat_warning"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/statuslights_sbat_warning"
validate:maxNumber="100"
validate:minNumber="0"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="5"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
android:key="@string/key_statuslights_sbat_critical"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/statuslights_sbat_critical"
validate:maxNumber="100"
validate:minNumber="0"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="216"
android:dependency="@string/key_show_statuslights"