ActionsFragment -> jetpack

This commit is contained in:
Milos Kozak 2021-02-04 10:06:19 +01:00
parent ff28f26bda
commit f5eba51d5a
2 changed files with 300 additions and 279 deletions

View file

@ -8,6 +8,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.Config
@ -40,7 +41,6 @@ import info.nightscout.androidaps.utils.ui.SingleClickButton
import info.nightscout.androidaps.utils.ui.UIRunnable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.careportal_stats_fragment.*
import java.util.*
import javax.inject.Inject
@ -81,6 +81,17 @@ class ActionsFragment : DaggerFragment() {
private var tddStats: SingleClickButton? = null
private var pumpBatteryChange: SingleClickButton? = null
private var cannulaAge: TextView? = null
private var insulinAge: TextView? = null
private var reservoirLevel: TextView? = null
private var sensorAge: TextView? = null
private var sensorLevel: TextView? = null
private var pbAge: TextView? = null
private var batteryLevel: TextView? = null
private var sensorLevelLabel: TextView? = null
private var insulinLevelLabel: TextView? = null
private var pbLevelLabel: TextView? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
//check screen width
@ -111,6 +122,17 @@ class ActionsFragment : DaggerFragment() {
tddStats = view.findViewById(R.id.actions_tddstats)
pumpBatteryChange = view.findViewById(R.id.actions_pumpbatterychange)
cannulaAge = view.findViewById(R.id.cannula_age)
insulinAge = view.findViewById(R.id.insulin_age)
reservoirLevel = view.findViewById(R.id.reservoir_level)
sensorAge = view.findViewById(R.id.sensor_age)
sensorLevel = view.findViewById(R.id.sensor_level)
pbAge = view.findViewById(R.id.pb_age)
batteryLevel = view.findViewById(R.id.battery_level)
sensorLevelLabel = view.findViewById(R.id.sensor_level_label)
insulinLevelLabel = view.findViewById(R.id.insulin_level_label)
pbLevelLabel = view.findViewById(R.id.pb_level_label)
profileSwitch?.setOnClickListener {
ProfileSwitchDialog().show(childFragmentManager, "Actions")
}
@ -283,13 +305,13 @@ class ActionsFragment : DaggerFragment() {
tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
if (!config.NSCLIENT) {
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_sensorlevel, careportal_pbage, careportal_batterylevel)
careportal_senslevellabel?.text = if (activeBgSource.sensorBatteryLevel == -1) "" else resourceHelper.gs(R.string.careportal_level_label)
statusLightHandler.updateStatusLights(cannulaAge, insulinAge, reservoirLevel, sensorAge, sensorLevel, pbAge, batteryLevel)
sensorLevelLabel?.text = if (activeBgSource.sensorBatteryLevel == -1) "" else resourceHelper.gs(R.string.careportal_level_label)
} else {
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, null, careportal_pbage, null)
careportal_senslevellabel?.text = ""
careportal_inslevellabel?.text = ""
careportal_pblevellabel?.text = ""
statusLightHandler.updateStatusLights(cannulaAge, insulinAge, null, sensorAge, null, pbAge, null)
sensorLevelLabel?.text = ""
insulinLevelLabel?.text = ""
pbLevelLabel?.text = ""
}
checkPumpCustomActions()

View file

@ -1,306 +1,305 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,2,4"
tools:context=".plugins.general.actions.ActionsFragment">
<TableLayout
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,2,4">
android:layout_height="wrap_content">
<TableRow
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:gravity="center_vertical"
android:paddingStart="15dp"
android:paddingEnd="2dp"
android:text="@string/careportal_sensor_label"
android:textSize="14sp"
app:drawableStartCompat="@drawable/ic_cp_age_sensor" />
<TextView
android:id="@+id/sensor_age_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:text="@string/careportal_age_label"
android:textSize="14sp" />
<TextView
android:id="@+id/sensor_age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/sensor_level_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:text="@string/careportal_level_label"
android:textSize="14sp" />
<TextView
android:id="@+id/sensor_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:textColor="@android:color/white"
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="2dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="2dp"
android:layout_span="5"
android:background="@color/listdelimiter" />
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:drawableLeft="@drawable/ic_cp_age_sensor"
android:gravity="center_vertical"
android:paddingRight="2dp"
android:paddingStart="15dp"
android:text="@string/careportal_sensor_label"
android:textSize="14sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:gravity="center_vertical"
android:paddingStart="15dp"
android:paddingEnd="2dp"
android:text="@string/careportal_insulin_label"
android:textSize="14sp"
app:drawableStartCompat="@drawable/ic_cp_age_insulin" />
<TextView
android:id="@+id/careportal_sensoragelabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_age_label"
android:textSize="14sp" />
<TextView
android:id="@+id/insulin_age_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:text="@string/careportal_age_label"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_sensorage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingRight="2dp"
android:paddingLeft="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/insulin_age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_senslevellabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_level_label"
android:textSize="14sp" />
<TextView
android:id="@+id/insulin_level_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:text="@string/careportal_level_label"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_sensorlevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginRight="20dp"
android:paddingLeft="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/reservoir_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:textColor="@android:color/white"
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</TableRow>
</TableRow>
<TableRow
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="2dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="2dp"
android:layout_span="5"
android:background="@color/listdelimiter" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_span="5"
android:layout_marginLeft="20dp"
android:layout_marginTop="2dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="2dp"
android:background="@color/listdelimiter" />
</TableRow>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:gravity="center_vertical"
android:paddingStart="15dp"
android:paddingEnd="2dp"
android:text="@string/careportal_canula_label"
android:textSize="14sp"
app:drawableStartCompat="@drawable/ic_cp_age_canula" />
<TextView
android:id="@+id/cannula_age_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:text="@string/careportal_age_label"
android:textSize="14sp" />
<TextView
android:id="@+id/cannula_age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:text=""
android:textColor="@android:color/white"
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="2dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="2dp"
android:layout_span="5"
android:background="@color/listdelimiter" />
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:drawableLeft="@drawable/ic_cp_age_insulin"
android:gravity="center_vertical"
android:paddingStart="15dp"
android:paddingRight="2dp"
android:text="@string/careportal_insulin_label"
android:textSize="14sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/pb_label"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:gravity="center_vertical"
android:paddingStart="15dp"
android:paddingEnd="2dp"
android:text="@string/careportal_pb_label"
android:textSize="14sp"
app:drawableStartCompat="@drawable/ic_cp_age_battery" />
<TextView
android:id="@+id/careportal_insulinagelabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_age_label"
android:textSize="14sp" />
<TextView
android:id="@+id/pb_age_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:text="@string/careportal_age_label"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_insulinage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingRight="2dp"
android:paddingLeft="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/pb_age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/pb_level_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:text="@string/careportal_level_label"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_inslevellabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_level_label"
android:textSize="14sp" />
<TextView
android:id="@+id/battery_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:textColor="@android:color/white"
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:id="@+id/careportal_reservoirlevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginRight="20dp"
android:paddingLeft="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
</TableRow>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow
<View
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:layout_height="2dip"
android:layout_marginLeft="20dp"
android:layout_marginTop="2dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="2dp"
android:layout_span="5"
android:background="@color/listdelimiter" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_span="5"
android:layout_marginLeft="20dp"
android:layout_marginTop="2dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="2dp"
android:background="@color/listdelimiter" />
</TableRow>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:drawableLeft="@drawable/ic_cp_age_canula"
android:gravity="center_vertical"
android:paddingStart="15dp"
android:paddingRight="2dp"
android:text="@string/careportal_canula_label"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_canulaagelabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_age_label"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_canulaage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingRight="2dp"
android:paddingLeft="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingRight="0dp"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginRight="20dp"
android:text=""
android:paddingLeft="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_span="5"
android:layout_marginLeft="20dp"
android:layout_marginTop="2dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="2dp"
android:background="@color/listdelimiter" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/careportal_pblabel"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:drawableLeft="@drawable/ic_cp_age_battery"
android:gravity="center_vertical"
android:paddingRight="2dp"
android:paddingStart="15dp"
android:text="@string/careportal_pb_label"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_pbagelabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_age_label"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_pbage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingRight="2dp"
android:paddingLeft="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_pblevellabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_level_label"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_batterylevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginRight="20dp"
android:paddingLeft="2dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_span="5"
android:layout_marginLeft="20dp"
android:layout_marginTop="2dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="2dp"
android:background="@color/listdelimiter" />
</TableRow>
</TableLayout>
</FrameLayout>
</TableLayout>