Add LowRes Layout for action tab and additional function in Skininterface

This commit is contained in:
Philoul 2020-10-26 22:55:22 +01:00
parent 405a5526ab
commit fb95eb4f2f
6 changed files with 557 additions and 24 deletions

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.general.actions
import android.content.Intent
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -9,6 +10,7 @@ import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
@ -62,10 +64,23 @@ class ActionsFragment : DaggerFragment() {
private val pumpCustomActions = HashMap<String, CustomAction>()
private val pumpCustomButtons = ArrayList<SingleClickButton>()
private var smallWidth = false
private var smallHeight = false
private lateinit var dm: DisplayMetrics
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.actions_fragment, container, false)
//check screen width
dm = DisplayMetrics()
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
val screenWidth = dm.widthPixels
val screenHeight = dm.heightPixels
smallWidth = screenWidth <= Constants.SMALL_WIDTH
smallHeight = screenHeight <= Constants.SMALL_HEIGHT
val landscape = screenHeight < screenWidth
return inflater.inflate(skinProvider.activeSkin().actionsLayout(landscape, smallWidth), container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -242,29 +257,9 @@ class ActionsFragment : DaggerFragment() {
actions_temptarget?.visibility = (profile != null && config.APS).toVisibility()
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
val shortlabel = skinProvider.activeSkin().description == R.string.lowres_description
if (shortlabel) {
careportal_pblabel?.text = resourceHelper.gs(R.string.pump)
careportal_sensoragelabel?.text = ""
careportal_insulinagelabel?.text = ""
careportal_canulaagelabel?.text = ""
careportal_pbagelabel?.text = ""
} else {
careportal_pblabel.text = resourceHelper.gs(R.string.careportal_pb_label)
careportal_sensoragelabel.text = resourceHelper.gs(R.string.careportal_age_label)
careportal_insulinagelabel.text =resourceHelper.gs(R.string.careportal_age_label)
careportal_canulaagelabel.text =resourceHelper.gs(R.string.careportal_age_label)
careportal_pbagelabel.text =resourceHelper.gs(R.string.careportal_age_label)
}
if (!config.NSCLIENT) {
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_sensorlevel, careportal_pbage, careportal_batterylevel)
if (activeBgSource.sensorBatteryLevel == -1)
careportal_senslevellabel?.text = ""
else
careportal_senslevellabel?.text = if (shortlabel) "" else resourceHelper.gs(R.string.careportal_level_label)
careportal_inslevellabel?.text = if (shortlabel) "" else resourceHelper.gs(R.string.careportal_level_label)
careportal_pblevellabel?.text = if (shortlabel) "" else resourceHelper.gs(R.string.careportal_level_label)
careportal_senslevellabel?.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 = ""

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.skins
import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import info.nightscout.androidaps.R
interface SkinInterface {
@get:StringRes val description : Int
@ -9,4 +10,5 @@ interface SkinInterface {
val mainGraphHeight : Int // in dp
val secondaryGraphHeight : Int // in dp
@LayoutRes fun overviewLayout(isLandscape : Boolean, isTablet : Boolean, isSmallHeight : Boolean): Int
@LayoutRes fun actionsLayout(isLandscape : Boolean, isSmallWidth : Boolean): Int = R.layout.actions_fragment
}

View file

@ -19,5 +19,9 @@ class SkinLowRes @Inject constructor(private val config: Config): SkinInterface
isSmallHeight || isLandscape -> R.layout.overview_fragment_landscape
else -> R.layout.overview_fragment
}
override fun actionsLayout(isLandscape : Boolean, isSmallWidth : Boolean): Int =
when {
isLandscape || !isSmallWidth -> R.layout.actions_fragment
else -> R.layout.actions_fragment_lowres
}
}

View file

@ -0,0 +1,304 @@
<ScrollView 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="match_parent"
android:layout_height="match_parent"
tools:context=".plugins.general.actions.ActionsFragment">
<LinearLayout
android:id="@+id/action_buttons_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:text="@string/actions" />
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
app:columnCount="2">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_profileswitch"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_actions_profileswitch"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_profileswitch"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="0" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_temptarget"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_actions_temptarget"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_temporarytarget"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="0" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_settempbasal"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_actions_starttempbasal"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/overview_tempbasal_button"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="1" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_canceltempbasal"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_cancelbasal"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/canceltemp"
android:visibility="gone"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="1" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_extendedbolus"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_actions_startextbolus"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/overview_extendedbolus_button"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="1" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_extendedbolus_cancel"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_actions_cancelextbolus"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/overview_extendedbolus_cancel_button"
android:visibility="gone"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="1" />
</androidx.gridlayout.widget.GridLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:text="@string/careportal" />
<include
android:id="@+id/careportal_stats"
layout="@layout/careportal_stats_fragment_lowres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
app:columnCount="2">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_bgcheck"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_bgcheck"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_bgcheck"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="2" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_fill"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_cp_pump_canula"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/primefill"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="2" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_cgmsensorinsert"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_cgm_insert"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_cgmsensorinsert"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="3" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_pumpbatterychange"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_pump_battery"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_pumpbatterychange"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="3" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_note"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_note"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_note"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="4" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_exercise"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_exercise"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_exercise"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="4" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_announcement"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_announcement"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_announcement"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="5" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_question"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_question"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_question"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="5" />
</androidx.gridlayout.widget.GridLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:text="@string/tools" />
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
app:columnCount="2">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_historybrowser"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_danarhistory"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/nav_historybrowser"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="6" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_tddstats"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_cp_stats"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/tdd"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="6" />
</androidx.gridlayout.widget.GridLayout>
</LinearLayout>
</ScrollView>

View file

@ -4,7 +4,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
tools:context=".plugins.general.careportal.CareportalFragment">
tools:context=".plugins.general.actions.ActionsFragment">
<ScrollView

View file

@ -0,0 +1,228 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
tools:context=".plugins.general.actions.ActionsFragment">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,2,4">
<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_sensor"
android:gravity="center_vertical"
android:paddingRight="2dp"
android:paddingStart="15dp"
android:text="@string/careportal_sensor_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/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" />
</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="3"
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: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" />
<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/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
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_span="3"
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: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_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: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="3"
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/pump"
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_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="3"
android:layout_marginLeft="20dp"
android:layout_marginTop="2dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="2dp"
android:background="@color/listdelimiter" />
</TableRow>
</TableLayout>
</FrameLayout>