diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/SkinsModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/SkinsModule.kt index cd71cc8fd2..feb0b2f812 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/SkinsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/SkinsModule.kt @@ -9,6 +9,7 @@ import info.nightscout.androidaps.skins.SkinButtonsOn import info.nightscout.androidaps.skins.SkinClassic import info.nightscout.androidaps.skins.SkinInterface import info.nightscout.androidaps.skins.SkinLargeDisplay +import info.nightscout.androidaps.skins.SkinLowRes import javax.inject.Qualifier @Module @@ -32,6 +33,12 @@ open class SkinsModule { @IntKey(20) fun bindsSkinLargeDisplay(skinLargeDisplay: SkinLargeDisplay): SkinInterface = skinLargeDisplay + @Provides + @Skin + @IntoMap + @IntKey(30) + fun bindsSkinLowRes(skinLowRes: SkinLowRes): SkinInterface = skinLowRes + @Qualifier annotation class Skin } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index 900b15bde6..86e4212def 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -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 @@ -24,6 +26,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler import info.nightscout.androidaps.queue.Callback +import info.nightscout.androidaps.skins.SkinProvider import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.buildHelper.BuildHelper @@ -54,16 +57,30 @@ class ActionsFragment : DaggerFragment() { @Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var buildHelper: BuildHelper @Inject lateinit var protectionCheck: ProtectionCheck + @Inject lateinit var skinProvider: SkinProvider @Inject lateinit var config: Config private var disposable: CompositeDisposable = CompositeDisposable() private val pumpCustomActions = HashMap() private val pumpCustomButtons = ArrayList() + 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?) { @@ -233,15 +250,24 @@ 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() - statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null) + 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) + } else { + statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, null, careportal_pbage, null) + careportal_senslevellabel?.text = "" + careportal_inslevellabel?.text = "" + careportal_pblevellabel?.text = "" + } checkPumpCustomActions() + } private fun checkPumpCustomActions() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 1760ea45d0..0afab008c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -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) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt index 8a95e34e1e..af361236fa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt @@ -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(), "%") } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt index 9141d57214..ff28aa3f2a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt @@ -41,6 +41,8 @@ class EversensePlugin @Inject constructor( aapsLogger, resourceHelper, injector ), BgSourceInterface { + private var sensorBatteryLevel = -1 + override fun advancedFilteringSupported(): Boolean { return false } @@ -53,7 +55,10 @@ class EversensePlugin @Inject constructor( if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel")) if (bundle.containsKey("glucoseTrendDirection")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTrendDirection: " + bundle.getString("glucoseTrendDirection")) if (bundle.containsKey("glucoseTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamp: " + dateUtil.dateAndTimeString(bundle.getLong("glucoseTimestamp"))) - if (bundle.containsKey("batteryLevel")) aapsLogger.debug(LTag.BGSOURCE, "batteryLevel: " + bundle.getString("batteryLevel")) + if (bundle.containsKey("batteryLevel")) { + aapsLogger.debug(LTag.BGSOURCE, "batteryLevel: " + bundle.getString("batteryLevel")) + //sensorBatteryLevel = bundle.getString("batteryLevel").toInt() // TODO: Philoul: Line to check I don't have eversens so I don't know what kind of information is sent... + } if (bundle.containsKey("signalStrength")) aapsLogger.debug(LTag.BGSOURCE, "signalStrength: " + bundle.getString("signalStrength")) if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber")) if (bundle.containsKey("isXLVersion")) aapsLogger.debug(LTag.BGSOURCE, "isXLVersion: " + bundle.getBoolean("isXLVersion")) @@ -113,4 +118,8 @@ class EversensePlugin @Inject constructor( } } } + + override fun getSensorBatteryLevel(): Int { + return sensorBatteryLevel + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt index aaf38b93b6..bc27489da6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt @@ -31,6 +31,7 @@ class XdripPlugin @Inject constructor( ), BgSourceInterface { private var advancedFiltering = false + private var sensorBatteryLevel = -1 override fun advancedFilteringSupported(): Boolean { return advancedFiltering @@ -45,6 +46,7 @@ class XdripPlugin @Inject constructor( bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME) bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP) bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW) + //if (bundle.containsKey(Intents.EXTRA_SENSOR_BATTERY)) sensorBatteryLevel = bundle.getInt(Intents.EXTRA_SENSOR_BATTERY) val source = bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, "no Source specified") setSource(source) MainApp.getDbHelper().createIfNotExists(bgReading, "XDRIP") @@ -53,4 +55,8 @@ class XdripPlugin @Inject constructor( private fun setSource(source: String) { advancedFiltering = source.contains("G5 Native") || source.contains("G6 Native") } + + override fun getSensorBatteryLevel(): Int { + return sensorBatteryLevel + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt index 73c047d100..0722029b25 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt @@ -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 } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt new file mode 100644 index 0000000000..529ff83e08 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt @@ -0,0 +1,27 @@ +package info.nightscout.androidaps.skins + +import info.nightscout.androidaps.Config +import info.nightscout.androidaps.R +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class SkinLowRes @Inject constructor(private val config: Config): SkinInterface { + + override val description: Int get() = R.string.lowres_description + override val mainGraphHeight: Int get() = 200 + override val secondaryGraphHeight: Int get() = 100 + + override fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int = + when { + config.NSCLIENT && isTablet -> R.layout.overview_fragment_nsclient_tablet + config.NSCLIENT -> R.layout.overview_fragment_nsclient + 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 + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/actions_fragment_lowres.xml b/app/src/main/res/layout/actions_fragment_lowres.xml new file mode 100644 index 0000000000..dc7a4fc204 --- /dev/null +++ b/app/src/main/res/layout/actions_fragment_lowres.xml @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/careportal_fragment.xml b/app/src/main/res/layout/careportal_fragment.xml index ec0bd04bc7..f926492f62 100644 --- a/app/src/main/res/layout/careportal_fragment.xml +++ b/app/src/main/res/layout/careportal_fragment.xml @@ -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"> + tools:context=".plugins.general.actions.ActionsFragment"> - - + android:stretchColumns="0,2,4"> - + + - - - - - + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + - + - + + + + + android:layout_height="wrap_content"> - + + + + + diff --git a/app/src/main/res/layout/careportal_stats_fragment_lowres.xml b/app/src/main/res/layout/careportal_stats_fragment_lowres.xml new file mode 100644 index 0000000000..eb6a1dc8ed --- /dev/null +++ b/app/src/main/res/layout/careportal_stats_fragment_lowres.xml @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9b6011b98e..1798103f16 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -528,6 +528,10 @@ Threshold warning sensor age [h] statuslights_sage_critical Threshold critical sensor age [h] + statuslights_sbat_warning + Threshold warning sensor battery level [%] + statuslights_sbat_critical + Threshold critical sensor battery level [%] statuslights_bage_warning Threshold warning battery age [h] statuslights_bage_critical @@ -566,6 +570,12 @@ Insulin age Do Profile Switch Pump battery age + Sensor + Canula + Insulin + Pump battery + age: + level: Alarm options ns_announcements ns_alarms @@ -1405,6 +1415,7 @@ Copy NS settings (if exists)? statuslights_overview_advanced Original skin + Low Resolution skin Buttons are always displayed on bottom of screen Large display skin diff --git a/app/src/main/res/xml/pref_overview.xml b/app/src/main/res/xml/pref_overview.xml index 77e21cab7b..75f81c96c4 100644 --- a/app/src/main/res/xml/pref_overview.xml +++ b/app/src/main/res/xml/pref_overview.xml @@ -360,6 +360,32 @@ validate:minNumber="24" validate:testType="numericRange" /> + + + +