feat: show hide battery status light
This commit is contained in:
parent
a8694bb468
commit
e59e66e6bd
5 changed files with 24 additions and 11 deletions
|
@ -8,6 +8,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TableRow
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
|
@ -108,6 +109,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
private var insulinLevelLabel: TextView? = null
|
private var insulinLevelLabel: TextView? = null
|
||||||
private var pbLevelLabel: TextView? = null
|
private var pbLevelLabel: TextView? = null
|
||||||
private var cannulaOrPatch: TextView? = null
|
private var cannulaOrPatch: TextView? = null
|
||||||
|
private var batteryLayout: TableRow? = null
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
@ -143,7 +145,6 @@ class ActionsFragment : DaggerFragment() {
|
||||||
historyBrowser = view.findViewById(R.id.actions_historybrowser)
|
historyBrowser = view.findViewById(R.id.actions_historybrowser)
|
||||||
tddStats = view.findViewById(R.id.actions_tddstats)
|
tddStats = view.findViewById(R.id.actions_tddstats)
|
||||||
pumpBatteryChange = view.findViewById(R.id.actions_pumpbatterychange)
|
pumpBatteryChange = view.findViewById(R.id.actions_pumpbatterychange)
|
||||||
|
|
||||||
cannulaAge = view.findViewById(R.id.cannula_age)
|
cannulaAge = view.findViewById(R.id.cannula_age)
|
||||||
insulinAge = view.findViewById(R.id.insulin_age)
|
insulinAge = view.findViewById(R.id.insulin_age)
|
||||||
reservoirLevel = view.findViewById(R.id.reservoir_level)
|
reservoirLevel = view.findViewById(R.id.reservoir_level)
|
||||||
|
@ -155,6 +156,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
insulinLevelLabel = view.findViewById(R.id.insulin_level_label)
|
insulinLevelLabel = view.findViewById(R.id.insulin_level_label)
|
||||||
pbLevelLabel = view.findViewById(R.id.pb_level_label)
|
pbLevelLabel = view.findViewById(R.id.pb_level_label)
|
||||||
cannulaOrPatch = view.findViewById(R.id.cannula_or_patch)
|
cannulaOrPatch = view.findViewById(R.id.cannula_or_patch)
|
||||||
|
batteryLayout = view.findViewById(R.id.battery_layout)
|
||||||
|
|
||||||
profileSwitch?.setOnClickListener {
|
profileSwitch?.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
|
@ -335,10 +337,11 @@ class ActionsFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
tempTarget?.visibility = (profile != null && !loop.isDisconnected).toVisibility()
|
tempTarget?.visibility = (profile != null && !loop.isDisconnected).toVisibility()
|
||||||
tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
||||||
|
val isPatchPump = pump.pumpDescription.isPatchPump
|
||||||
cannulaOrPatch?.text = if (pump.pumpDescription.isPatchPump) rh.gs(R.string.patch_pump) else rh.gs(R.string.cannula)
|
cannulaOrPatch?.text = if (isPatchPump) rh.gs(R.string.patch_pump) else rh.gs(R.string.cannula)
|
||||||
val imageResource = if (pump.pumpDescription.isPatchPump) R.drawable.ic_patch_pump_outline else R.drawable.ic_cp_age_cannula
|
val imageResource = if (isPatchPump) R.drawable.ic_patch_pump_outline else R.drawable.ic_cp_age_cannula
|
||||||
cannulaOrPatch?.setCompoundDrawablesWithIntrinsicBounds(imageResource, 0, 0, 0)
|
cannulaOrPatch?.setCompoundDrawablesWithIntrinsicBounds(imageResource, 0, 0, 0)
|
||||||
|
batteryLayout?.visibility = (!isPatchPump || pump is OmnipodErosPumpPlugin).toVisibility()
|
||||||
|
|
||||||
if (!config.NSCLIENT) {
|
if (!config.NSCLIENT) {
|
||||||
statusLightHandler.updateStatusLights(cannulaAge, insulinAge, reservoirLevel, sensorAge, sensorLevel, pbAge, batteryLevel)
|
statusLightHandler.updateStatusLights(cannulaAge, insulinAge, reservoirLevel, sensorAge, sensorLevel, pbAge, batteryLevel)
|
||||||
|
|
|
@ -34,6 +34,7 @@ import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
||||||
import info.nightscout.androidaps.database.interfaces.end
|
import info.nightscout.androidaps.database.interfaces.end
|
||||||
import info.nightscout.androidaps.databinding.OverviewFragmentBinding
|
import info.nightscout.androidaps.databinding.OverviewFragmentBinding
|
||||||
|
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
|
||||||
import info.nightscout.androidaps.dialogs.*
|
import info.nightscout.androidaps.dialogs.*
|
||||||
import info.nightscout.androidaps.events.EventAcceptOpenLoopChange
|
import info.nightscout.androidaps.events.EventAcceptOpenLoopChange
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged
|
import info.nightscout.androidaps.events.EventInitializationChanged
|
||||||
|
@ -61,6 +62,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific
|
||||||
import info.nightscout.androidaps.plugins.general.wear.events.EventWearInitiateAction
|
import info.nightscout.androidaps.plugins.general.wear.events.EventWearInitiateAction
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.source.DexcomPlugin
|
import info.nightscout.androidaps.plugins.source.DexcomPlugin
|
||||||
import info.nightscout.androidaps.plugins.source.XdripPlugin
|
import info.nightscout.androidaps.plugins.source.XdripPlugin
|
||||||
import info.nightscout.androidaps.skins.SkinProvider
|
import info.nightscout.androidaps.skins.SkinProvider
|
||||||
|
@ -866,13 +868,24 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
fun updateTime(from: String) {
|
fun updateTime(from: String) {
|
||||||
binding.infoLayout.time.text = dateUtil.timeString(dateUtil.now())
|
binding.infoLayout.time.text = dateUtil.timeString(dateUtil.now())
|
||||||
// Status lights
|
// Status lights
|
||||||
val isPatchPump = activePlugin.activePump.pumpDescription.isPatchPump
|
val pump = activePlugin.activePump
|
||||||
|
val isPatchPump = pump.pumpDescription.isPatchPump
|
||||||
binding.statusLightsLayout.apply {
|
binding.statusLightsLayout.apply {
|
||||||
cannulaOrPatch.setImageResource(if (isPatchPump) R.drawable.ic_patch_pump_outline else R.drawable.ic_cp_age_cannula)
|
cannulaOrPatch.setImageResource(if (isPatchPump) R.drawable.ic_patch_pump_outline else R.drawable.ic_cp_age_cannula)
|
||||||
cannulaOrPatch.contentDescription = rh.gs(if (isPatchPump) R.string.statuslights_patch_pump_age else R.string.statuslights_cannula_age)
|
cannulaOrPatch.contentDescription = rh.gs(if (isPatchPump) R.string.statuslights_patch_pump_age else R.string.statuslights_cannula_age)
|
||||||
cannulaOrPatch.scaleX = if (isPatchPump) 1.4f else 2f
|
cannulaOrPatch.scaleX = if (isPatchPump) 1.4f else 2f
|
||||||
cannulaOrPatch.scaleY = cannulaOrPatch.scaleX
|
cannulaOrPatch.scaleY = cannulaOrPatch.scaleX
|
||||||
insulinAge.visibility = isPatchPump.not().toVisibility()
|
insulinAge.visibility = isPatchPump.not().toVisibility()
|
||||||
|
// Patch pumps discards batteries and do not need to shown the status battery light excepts for Omnipod Eros
|
||||||
|
batteryLayout.visibility = (!isPatchPump || pump is OmnipodErosPumpPlugin).toVisibility()
|
||||||
|
// Only show battery level if the action button change battery is available
|
||||||
|
val useBatteryAge = (pump is DiaconnG8Plugin && pump.pumpDescription.isBatteryReplaceable && !pump.isBatteryChangeLoggingEnabled())
|
||||||
|
|| (pump.pumpDescription.isBatteryReplaceable || (pump is OmnipodErosPumpPlugin && pump.isUseRileyLinkBatteryLevel && pump.isBatteryChangeLoggingEnabled))
|
||||||
|
pbAge.visibility = useBatteryAge.toVisibility()
|
||||||
|
// Only show battery level when supported by pump or link
|
||||||
|
val useBatteryLevel = (pump.model() == PumpType.OMNIPOD_EROS && pump is OmnipodErosPumpPlugin)
|
||||||
|
|| (pump.model() != PumpType.ACCU_CHEK_COMBO && pump.model() != PumpType.OMNIPOD_DASH)
|
||||||
|
batteryLevel.visibility = useBatteryLevel.toVisibility()
|
||||||
statusLights.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility()
|
statusLights.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility()
|
||||||
}
|
}
|
||||||
statusLightHandler.updateStatusLights(
|
statusLightHandler.updateStatusLights(
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/sensor_level_label"
|
android:id="@+id/sensor_level_label"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -96,7 +95,6 @@
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
app:drawableStartCompat="@drawable/ic_cp_age_insulin" />
|
app:drawableStartCompat="@drawable/ic_cp_age_insulin" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/insulin_age_label"
|
android:id="@+id/insulin_age_label"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -231,6 +229,7 @@
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
|
android:id="@+id/battery_layout"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:focusable="true">
|
android:focusable="true">
|
||||||
|
@ -246,7 +245,6 @@
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
app:drawableStartCompat="@drawable/ic_cp_age_battery" />
|
app:drawableStartCompat="@drawable/ic_cp_age_battery" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/pb_age_label"
|
android:id="@+id/pb_age_label"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -77,7 +77,6 @@
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
app:drawableStartCompat="@drawable/ic_cp_age_insulin" />
|
app:drawableStartCompat="@drawable/ic_cp_age_insulin" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/insulin_age"
|
android:id="@+id/insulin_age"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -88,7 +87,6 @@
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/reservoir_level"
|
android:id="@+id/reservoir_level"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -174,6 +172,7 @@
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
|
android:id="@+id/battery_layout"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:focusable="true">
|
android:focusable="true">
|
||||||
|
@ -189,7 +188,6 @@
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
app:drawableStartCompat="@drawable/ic_cp_age_battery" />
|
app:drawableStartCompat="@drawable/ic_cp_age_battery" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/pb_age"
|
android:id="@+id/pb_age"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/battery_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
|
Loading…
Reference in a new issue