improve statuslights layout

This commit is contained in:
Milos Kozak 2023-05-14 12:50:34 +02:00
parent fba804b2cb
commit c86edb94fd
4 changed files with 31 additions and 42 deletions

View file

@ -891,14 +891,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
binding.statusLightsLayout.apply { binding.statusLightsLayout.apply {
cannulaOrPatch.setImageResource(if (isPatchPump) info.nightscout.core.main.R.drawable.ic_patch_pump_outline else R.drawable.ic_cp_age_cannula) cannulaOrPatch.setImageResource(if (isPatchPump) info.nightscout.core.main.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.scaleY = cannulaOrPatch.scaleX
insulinAge.visibility = isPatchPump.not().toVisibility() insulinAge.visibility = isPatchPump.not().toVisibility()
batteryLayout.visibility = (!isPatchPump || pump.pumpDescription.useHardwareLink).toVisibility() batteryLayout.visibility = (!isPatchPump || pump.pumpDescription.useHardwareLink).toVisibility()
pbAge.visibility = (pump.pumpDescription.isBatteryReplaceable || pump.isBatteryChangeLoggingEnabled()).toVisibility() pbAge.visibility = (pump.pumpDescription.isBatteryReplaceable || pump.isBatteryChangeLoggingEnabled()).toVisibility()
val useBatteryLevel = (pump.model() == PumpType.OMNIPOD_EROS) val useBatteryLevel = (pump.model() == PumpType.OMNIPOD_EROS)
|| (pump.model() != PumpType.ACCU_CHEK_COMBO && pump.model() != PumpType.OMNIPOD_DASH) || (pump.model() != PumpType.ACCU_CHEK_COMBO && pump.model() != PumpType.OMNIPOD_DASH)
batteryLevel.visibility = useBatteryLevel.toVisibility() pbLevel.visibility = useBatteryLevel.toVisibility()
statusLightsLayout.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility() statusLightsLayout.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility()
} }
statusLightHandler.updateStatusLights( statusLightHandler.updateStatusLights(
@ -909,7 +907,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
binding.statusLightsLayout.sensorAge, binding.statusLightsLayout.sensorAge,
null, null,
binding.statusLightsLayout.pbAge, binding.statusLightsLayout.pbAge,
binding.statusLightsLayout.batteryLevel binding.statusLightsLayout.pbLevel
) )
} }

View file

@ -59,7 +59,7 @@ interface SkinInterface {
for (v in texts) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f) for (v in texts) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f)
} }
binding.statusLightsLayout.apply { binding.statusLightsLayout.apply {
val texts = listOf(cannulaAge, insulinAge, reservoirLevel, sensorAge, pbAge, batteryLevel) val texts = listOf(cannulaAge, insulinAge, reservoirLevel, sensorAge, pbAge, pbLevel)
for (v in texts) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f) for (v in texts) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f)
} }
timeLayout.orientation = LinearLayout.HORIZONTAL timeLayout.orientation = LinearLayout.HORIZONTAL

View file

@ -127,7 +127,7 @@
app:alignItems="stretch" app:alignItems="stretch"
app:flexDirection="row" app:flexDirection="row"
app:flexWrap="wrap" app:flexWrap="wrap"
app:justifyContent="center"> app:justifyContent="space_around">
<TextView <TextView
android:id="@+id/pump" android:id="@+id/pump"

View file

@ -1,32 +1,32 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/status_lights_layout" android:id="@+id/status_lights_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="3dp" android:layout_marginTop="-3dp"
android:layout_marginBottom="3dp" android:layout_marginBottom="-3dp"
android:orientation="horizontal"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingBottom="4dp" android:paddingBottom="4dp"
android:baselineAligned="false"> app:alignContent="stretch"
app:alignItems="stretch"
app:flexDirection="row"
app:flexWrap="wrap"
app:justifyContent="space_around">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true" android:focusable="true"
android:gravity="center_horizontal" android:gravity="center"
tools:ignore="UseCompoundDrawables"> tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
android:id="@+id/cannula_or_patch" android:id="@+id/cannula_or_patch"
android:layout_width="38dp" android:layout_width="28dp"
android:layout_height="fill_parent" android:layout_height="28dp"
android:contentDescription="@string/statuslights_cannula_age" android:contentDescription="@string/statuslights_cannula_age"
android:scaleX="2"
android:scaleY="2"
app:srcCompat="@drawable/ic_cp_age_cannula" /> app:srcCompat="@drawable/ic_cp_age_cannula" />
<TextView <TextView
@ -40,23 +40,20 @@
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true" android:focusable="true"
android:gravity="center_horizontal"> android:gravity="center">
<ImageView <ImageView
android:layout_width="26dp" android:layout_width="28dp"
android:layout_height="fill_parent" android:layout_height="28dp"
android:contentDescription="@string/a11y_insulin_label" android:contentDescription="@string/a11y_insulin_label"
android:scaleX="1.7"
android:scaleY="1.7"
app:srcCompat="@drawable/ic_cp_age_insulin" /> app:srcCompat="@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"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:lines="1" android:lines="1"
tools:text="12h" /> tools:text="12h" />
@ -73,18 +70,15 @@
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true" android:focusable="true"
android:gravity="center_horizontal" android:gravity="center"
tools:ignore="UseCompoundDrawables"> tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
android:layout_width="28dp" android:layout_width="28dp"
android:layout_height="fill_parent" android:layout_height="28dp"
android:contentDescription="@string/sensor_label" android:contentDescription="@string/sensor_label"
android:scaleX="1.6"
android:scaleY="1.6"
app:srcCompat="@drawable/ic_cp_age_sensor" /> app:srcCompat="@drawable/ic_cp_age_sensor" />
<TextView <TextView
@ -99,31 +93,28 @@
<LinearLayout <LinearLayout
android:id="@+id/battery_layout" android:id="@+id/battery_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true" android:focusable="true"
android:gravity="center_horizontal"> android:gravity="center">
<ImageView <ImageView
android:layout_width="32dp" android:layout_width="28dp"
android:layout_height="wrap_content" android:layout_height="28dp"
android:contentDescription="@string/battery_label" android:contentDescription="@string/battery_label"
android:scaleX="1.8"
android:scaleY="1.8"
app:srcCompat="@drawable/ic_cp_age_battery" /> app:srcCompat="@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"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:lines="1" android:lines="1"
android:text="-" android:text="-"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/battery_level" android:id="@+id/pb_level"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="wrap_content"
android:lines="1" android:lines="1"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingEnd="0dp" android:paddingEnd="0dp"
@ -131,4 +122,4 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </com.google.android.flexbox.FlexboxLayout>