From bd3cba8a1afe60b90928d518ec26568ce40053d0 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 17 Oct 2020 11:00:38 +0200 Subject: [PATCH 01/17] First version of Layout and interface --- .../general/actions/ActionsFragment.kt | 8 +- app/src/main/res/layout/actions_fragment.xml | 2 +- .../res/layout/careportal_stats_fragment2.xml | 454 ++++++++++++++++++ app/src/main/res/values/strings.xml | 10 + 4 files changed, 470 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/layout/careportal_stats_fragment2.xml 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..ef97f95a3c 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 @@ -37,7 +37,7 @@ import info.nightscout.androidaps.utils.ui.UIRunnable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import kotlinx.android.synthetic.main.actions_fragment.* -import kotlinx.android.synthetic.main.careportal_stats_fragment.* +import kotlinx.android.synthetic.main.careportal_stats_fragment2.* import java.util.* import javax.inject.Inject @@ -239,8 +239,10 @@ class ActionsFragment : DaggerFragment() { 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_pbage, careportal_batterylevel) + else + statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null) checkPumpCustomActions() } diff --git a/app/src/main/res/layout/actions_fragment.xml b/app/src/main/res/layout/actions_fragment.xml index 427000813d..6e232dfeed 100644 --- a/app/src/main/res/layout/actions_fragment.xml +++ b/app/src/main/res/layout/actions_fragment.xml @@ -128,7 +128,7 @@ diff --git a/app/src/main/res/layout/careportal_stats_fragment2.xml b/app/src/main/res/layout/careportal_stats_fragment2.xml new file mode 100644 index 0000000000..ecc01aa416 --- /dev/null +++ b/app/src/main/res/layout/careportal_stats_fragment2.xml @@ -0,0 +1,454 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7ce5ed2790..186ebbfe27 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -527,6 +527,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 @@ -565,6 +569,12 @@ Insulin age Do Profile Switch Pump battery age + Sensor + Canula + Insulin + Pump battery + Age: + Level: Alarm options ns_announcements ns_alarms From 3f4b3149db2684666bd48cdd22799649e8790ba9 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 17 Oct 2020 20:12:58 +0200 Subject: [PATCH 02/17] Add new interface for BgSource to get SensorBatteryLevel Note, for xDrip, an Int is sent but I don't know what type of value is sent for Eversens that has a sensor battery level too... --- .../androidaps/plugins/source/DexcomPlugin.kt | 4 ++++ .../androidaps/plugins/source/EversensePlugin.kt | 11 ++++++++++- .../androidaps/plugins/source/GlimpPlugin.kt | 4 ++++ .../androidaps/plugins/source/MM640gPlugin.kt | 4 ++++ .../androidaps/plugins/source/NSClientSourcePlugin.kt | 4 ++++ .../androidaps/plugins/source/PoctechPlugin.kt | 4 ++++ .../androidaps/plugins/source/RandomBgPlugin.kt | 5 +++++ .../androidaps/plugins/source/TomatoPlugin.kt | 4 ++++ .../androidaps/plugins/source/XdripPlugin.kt | 6 ++++++ .../androidaps/interfaces/BgSourceInterface.java | 2 ++ 10 files changed, 47 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt index 27ad7fec82..25d4175a16 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt @@ -145,6 +145,10 @@ class DexcomPlugin @Inject constructor( } } + override fun getSensorBatteryLevel(): Int { + return -1 + } + companion object { private val PACKAGE_NAMES = arrayOf("com.dexcom.cgm.region1.mgdl", "com.dexcom.cgm.region1.mmol", "com.dexcom.cgm.region2.mgdl", "com.dexcom.cgm.region2.mmol", 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..43a3cb0669 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/GlimpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt index c2cd1d84e9..0cffbbde82 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt @@ -45,4 +45,8 @@ class GlimpPlugin @Inject constructor( bgReading.raw = 0.0 MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP") } + + override fun getSensorBatteryLevel(): Int { + return -1 + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt index 4d082c0133..7c9c39cf76 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt @@ -65,4 +65,8 @@ class MM640gPlugin @Inject constructor( } } } + + override fun getSensorBatteryLevel(): Int { + return -1 + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt index 4e10a9c728..365aab4911 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt @@ -91,4 +91,8 @@ class NSClientSourcePlugin @Inject constructor( lastBGTimeStamp = timeStamp } } + + override fun getSensorBatteryLevel(): Int { + return -1 + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt index 2032dd4479..2e161363e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt @@ -69,4 +69,8 @@ class PoctechPlugin @Inject constructor( aapsLogger.error("Exception: ", e) } } + + override fun getSensorBatteryLevel(): Int { + return -1 + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt index 3678f130a4..ed3101f727 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt @@ -100,4 +100,9 @@ class RandomBgPlugin @Inject constructor( } aapsLogger.debug(LTag.BGSOURCE, "Generated BG: $bgReading") } + + + override fun getSensorBatteryLevel(): Int { + return -1 + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt index 1ba7958b61..b80db46e5d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt @@ -53,4 +53,8 @@ class TomatoPlugin @Inject constructor( nsUpload.sendToXdrip(bgReading) } } + + override fun getSensorBatteryLevel(): Int { + return -1 + } } \ 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..bb5ef91db0 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/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java index d42ead7950..3903e40250 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java @@ -9,4 +9,6 @@ public interface BgSourceInterface { boolean advancedFilteringSupported(); void handleNewData(Intent intent); + + int getSensorBatteryLevel(); } From 961ee4ccf4940c0769cee59d4f333cebfc4c96c3 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 17 Oct 2020 22:22:09 +0200 Subject: [PATCH 03/17] Add Sensor Battery Level information It works with xDrip and Miaomiao2, but today there is a bug in xDrip (xDrip sends Phone battery level and not Sensor Battery level...) --- .../general/actions/ActionsFragment.kt | 10 ++++--- .../general/overview/OverviewFragment.kt | 2 +- .../general/overview/StatusLightHandler.kt | 10 +++++-- .../res/layout/careportal_stats_fragment2.xml | 22 ++++++++-------- app/src/main/res/xml/pref_overview.xml | 26 +++++++++++++++++++ 5 files changed, 53 insertions(+), 17 deletions(-) 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 ef97f95a3c..83a697e9f7 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 @@ -233,17 +233,21 @@ 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() if (!config.NSCLIENT) - statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_pbage, careportal_batterylevel) + statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_sensorlevel, careportal_pbage, careportal_batterylevel) else - statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null) + statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, null, careportal_pbage, null) checkPumpCustomActions() + if (activeBgSource.sensorBatteryLevel == -1) + careportal_senslevellabel?.text = "" + else + careportal_senslevellabel?.text = resourceHelper.gs(R.string.careportal_level_label) } 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/res/layout/careportal_stats_fragment2.xml b/app/src/main/res/layout/careportal_stats_fragment2.xml index ecc01aa416..0ea3d66f77 100644 --- a/app/src/main/res/layout/careportal_stats_fragment2.xml +++ b/app/src/main/res/layout/careportal_stats_fragment2.xml @@ -191,12 +191,12 @@ @@ -324,7 +324,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingStart="5dp" + android:paddingStart="15dp" android:paddingRight="5dp" android:textSize="14sp" /> @@ -345,7 +345,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingStart="5dp" + android:paddingStart="15dp" android:paddingRight="5dp" android:text="@string/careportal_level_label" android:textSize="14sp" /> @@ -363,7 +363,7 @@ + + + + Date: Sat, 17 Oct 2020 22:26:03 +0200 Subject: [PATCH 04/17] Patch of xDripPlugin and Eversens plugin to disable Sensor battery level in Action tab - xDrip disabled because of an issue in xDrip today (Phone battery level sent and not Sensor battery level) - Eversens disabled because I'm not sure of data sent (String, Int ?) to avoid error or crash --- .../nightscout/androidaps/plugins/source/EversensePlugin.kt | 2 +- .../info/nightscout/androidaps/plugins/source/XdripPlugin.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 43a3cb0669..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 @@ -57,7 +57,7 @@ class EversensePlugin @Inject constructor( 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")) - 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... + //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")) 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 bb5ef91db0..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 @@ -46,7 +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) + //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") From 84c2e7e86e81fa86f6590328aa9835be5049abbc Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 17 Oct 2020 23:07:40 +0200 Subject: [PATCH 05/17] Update of layout for low res screen to avoid line feed in level values --- .../res/layout/careportal_stats_fragment2.xml | 56 +++++++++---------- app/src/main/res/values/strings.xml | 4 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/app/src/main/res/layout/careportal_stats_fragment2.xml b/app/src/main/res/layout/careportal_stats_fragment2.xml index 0ea3d66f77..3c2203308e 100644 --- a/app/src/main/res/layout/careportal_stats_fragment2.xml +++ b/app/src/main/res/layout/careportal_stats_fragment2.xml @@ -24,7 +24,7 @@ android:layout_weight="1" android:gravity="center_vertical" android:drawableLeft="@drawable/ic_cp_age_sensor" - android:paddingRight="5dp" + android:paddingRight="2dp" android:paddingStart="15dp" android:text="@string/careportal_sensor_label" android:textSize="14sp" /> @@ -45,7 +45,7 @@ android:drawableLeft="@drawable/ic_cp_age_insulin" android:gravity="center_vertical" android:paddingStart="15dp" - android:paddingRight="5dp" + android:paddingRight="2dp" android:text="@string/careportal_insulin_label" android:textSize="14sp" /> @@ -66,7 +66,7 @@ android:drawableLeft="@drawable/ic_cp_age_canula" android:gravity="center_vertical" android:paddingStart="15dp" - android:paddingRight="5dp" + android:paddingRight="2dp" android:text="@string/careportal_canula_label" android:textSize="14sp" /> @@ -85,7 +85,7 @@ android:layout_height="25dp" android:gravity="center_vertical" android:drawableLeft="@drawable/ic_cp_age_battery" - android:paddingRight="5dp" + android:paddingRight="2dp" android:paddingStart="15dp" android:text="@string/careportal_pb_label" android:textSize="14sp" /> @@ -113,8 +113,8 @@ android:layout_height="wrap_content" android:gravity="center_vertical" android:layout_weight="1" - android:paddingStart="5dp" - android:paddingRight="5dp" + android:paddingStart="2dp" + android:paddingRight="2dp" android:text="@string/careportal_age_label" android:textSize="14sp" /> @@ -132,8 +132,8 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingStart="5dp" - android:paddingRight="5dp" + android:paddingStart="2dp" + android:paddingRight="2dp" android:text="@string/careportal_age_label" android:textSize="14sp" /> @@ -152,8 +152,8 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingStart="5dp" - android:paddingRight="5dp" + android:paddingStart="2dp" + android:paddingRight="2dp" android:text="@string/careportal_age_label" android:textSize="14sp" /> @@ -172,8 +172,8 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingStart="5dp" - android:paddingRight="5dp" + android:paddingStart="2dp" + android:paddingRight="2dp" android:text="@string/careportal_age_label" android:textSize="14sp" /> @@ -200,7 +200,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingLeft="5dp" + android:paddingLeft="2dp" android:textColor="@android:color/white" android:textSize="14sp" /> @@ -219,7 +219,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingLeft="5dp" + android:paddingLeft="2dp" android:textColor="@android:color/white" android:textSize="14sp" /> @@ -238,7 +238,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingLeft="5dp" + android:paddingLeft="2dp" android:textColor="@android:color/white" android:textSize="14sp" /> @@ -257,7 +257,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingLeft="5dp" + android:paddingLeft="2dp" android:textColor="@android:color/white" android:textSize="14sp" /> @@ -284,8 +284,8 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingStart="15dp" - android:paddingRight="5dp" + android:paddingStart="5dp" + android:paddingRight="2dp" android:text="@string/careportal_level_label" android:textSize="14sp" /> @@ -304,8 +304,8 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingStart="15dp" - android:paddingRight="5dp" + android:paddingStart="5dp" + android:paddingRight="2dp" android:text="@string/careportal_level_label" android:textSize="14sp" /> @@ -324,8 +324,8 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingStart="15dp" - android:paddingRight="5dp" + android:paddingStart="5dp" + android:paddingRight="2dp" android:textSize="14sp" /> @@ -345,8 +345,8 @@ android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical" - android:paddingStart="15dp" - android:paddingRight="5dp" + android:paddingStart="5dp" + android:paddingRight="2dp" android:text="@string/careportal_level_label" android:textSize="14sp" /> @@ -373,7 +373,7 @@ android:layout_weight="1" android:gravity="center_vertical" android:layout_marginRight="20dp" - android:paddingLeft="5dp" + android:paddingLeft="0dp" android:textColor="@android:color/white" android:textSize="14sp" /> @@ -393,7 +393,7 @@ android:layout_weight="1" android:gravity="center_vertical" android:layout_marginRight="20dp" - android:paddingLeft="5dp" + android:paddingLeft="0dp" android:textColor="@android:color/white" android:textSize="14sp" /> @@ -412,7 +412,7 @@ android:layout_weight="1" android:gravity="center_vertical" android:layout_marginRight="20dp" - android:paddingLeft="5dp" + android:paddingLeft="0dp" android:textColor="@android:color/white" android:textSize="14sp" /> @@ -432,7 +432,7 @@ android:layout_weight="1" android:gravity="center_vertical" android:layout_marginRight="20dp" - android:paddingLeft="5dp" + android:paddingLeft="0dp" android:textColor="@android:color/white" android:textSize="14sp" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 186ebbfe27..231997b66c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -573,8 +573,8 @@ Canula Insulin Pump battery - Age: - Level: + age: + level: Alarm options ns_announcements ns_alarms From 9f0f2c2c2fde671c65eaac8ef3a51a7131e3cf5b Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 18 Oct 2020 16:20:14 +0200 Subject: [PATCH 06/17] Replace LinearLayout by TableLayout --- .../res/layout/careportal_stats_fragment2.xml | 503 ++++++------------ 1 file changed, 173 insertions(+), 330 deletions(-) diff --git a/app/src/main/res/layout/careportal_stats_fragment2.xml b/app/src/main/res/layout/careportal_stats_fragment2.xml index 3c2203308e..5d6af1912c 100644 --- a/app/src/main/res/layout/careportal_stats_fragment2.xml +++ b/app/src/main/res/layout/careportal_stats_fragment2.xml @@ -4,41 +4,87 @@ android:layout_height="wrap_content" tools:context=".plugins.general.actions.ActionsFragment"> - - + android:stretchColumns="0,2,4"> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - + + From 4dc042a772118fb4c59a0771b8f65c43ef824eec Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 18 Oct 2020 16:52:05 +0200 Subject: [PATCH 07/17] Remove addition Layout and update to remove Level in NsClient Version --- .../general/actions/ActionsFragment.kt | 23 +- app/src/main/res/layout/actions_fragment.xml | 2 +- .../res/layout/careportal_stats_fragment.xml | 351 +++++++++++------- .../res/layout/careportal_stats_fragment2.xml | 297 --------------- 4 files changed, 238 insertions(+), 435 deletions(-) delete mode 100644 app/src/main/res/layout/careportal_stats_fragment2.xml 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 83a697e9f7..7d55c33782 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 @@ -37,7 +37,7 @@ import info.nightscout.androidaps.utils.ui.UIRunnable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import kotlinx.android.synthetic.main.actions_fragment.* -import kotlinx.android.synthetic.main.careportal_stats_fragment2.* +import kotlinx.android.synthetic.main.careportal_stats_fragment.* import java.util.* import javax.inject.Inject @@ -239,15 +239,22 @@ class ActionsFragment : DaggerFragment() { actions_pumpbatterychange?.visibility = pump.pumpDescription.isBatteryReplaceable.toVisibility() actions_temptarget?.visibility = (profile != null && config.APS).toVisibility() actions_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) - else + 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 = resourceHelper.gs(R.string.careportal_level_label) + careportal_inslevellabel?.text = resourceHelper.gs(R.string.careportal_level_label) + careportal_pblevellabel?.text = resourceHelper.gs(R.string.careportal_level_label) + } else { statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, null, careportal_pbage, null) - checkPumpCustomActions() - if (activeBgSource.sensorBatteryLevel == -1) careportal_senslevellabel?.text = "" - else - careportal_senslevellabel?.text = resourceHelper.gs(R.string.careportal_level_label) + careportal_inslevellabel?.text = "" + careportal_pblevellabel?.text = "" + } + checkPumpCustomActions() + } private fun checkPumpCustomActions() { diff --git a/app/src/main/res/layout/actions_fragment.xml b/app/src/main/res/layout/actions_fragment.xml index 6e232dfeed..427000813d 100644 --- a/app/src/main/res/layout/actions_fragment.xml +++ b/app/src/main/res/layout/actions_fragment.xml @@ -128,7 +128,7 @@ diff --git a/app/src/main/res/layout/careportal_stats_fragment.xml b/app/src/main/res/layout/careportal_stats_fragment.xml index bcd7f38f21..5d6af1912c 100644 --- a/app/src/main/res/layout/careportal_stats_fragment.xml +++ b/app/src/main/res/layout/careportal_stats_fragment.xml @@ -2,203 +2,296 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="wrap_content" - tools:context=".plugins.general.careportal.CareportalFragment"> + 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_fragment2.xml b/app/src/main/res/layout/careportal_stats_fragment2.xml deleted file mode 100644 index 5d6af1912c..0000000000 --- a/app/src/main/res/layout/careportal_stats_fragment2.xml +++ /dev/null @@ -1,297 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From a548b9c55c9ee1383872526272c276e054aa91f5 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 18 Oct 2020 18:15:37 +0200 Subject: [PATCH 08/17] Try to Fix Linefeed in level values --- app/src/main/res/layout/careportal_stats_fragment.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/layout/careportal_stats_fragment.xml b/app/src/main/res/layout/careportal_stats_fragment.xml index 5d6af1912c..7e6bcf4d74 100644 --- a/app/src/main/res/layout/careportal_stats_fragment.xml +++ b/app/src/main/res/layout/careportal_stats_fragment.xml @@ -55,7 +55,7 @@ @@ -266,7 +267,7 @@ Date: Mon, 19 Oct 2020 21:03:10 +0200 Subject: [PATCH 09/17] Replace override function by default in BGSourceInterface --- .../nightscout/androidaps/plugins/source/DexcomPlugin.kt | 4 ---- .../info/nightscout/androidaps/plugins/source/GlimpPlugin.kt | 4 ---- .../nightscout/androidaps/plugins/source/MM640gPlugin.kt | 4 ---- .../androidaps/plugins/source/NSClientSourcePlugin.kt | 4 ---- .../nightscout/androidaps/plugins/source/PoctechPlugin.kt | 4 ---- .../nightscout/androidaps/plugins/source/RandomBgPlugin.kt | 5 ----- .../nightscout/androidaps/plugins/source/TomatoPlugin.kt | 4 ---- .../nightscout/androidaps/interfaces/BgSourceInterface.java | 4 +++- 8 files changed, 3 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt index 25d4175a16..27ad7fec82 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt @@ -145,10 +145,6 @@ class DexcomPlugin @Inject constructor( } } - override fun getSensorBatteryLevel(): Int { - return -1 - } - companion object { private val PACKAGE_NAMES = arrayOf("com.dexcom.cgm.region1.mgdl", "com.dexcom.cgm.region1.mmol", "com.dexcom.cgm.region2.mgdl", "com.dexcom.cgm.region2.mmol", diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt index 0cffbbde82..c2cd1d84e9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt @@ -45,8 +45,4 @@ class GlimpPlugin @Inject constructor( bgReading.raw = 0.0 MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP") } - - override fun getSensorBatteryLevel(): Int { - return -1 - } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt index 7c9c39cf76..4d082c0133 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt @@ -65,8 +65,4 @@ class MM640gPlugin @Inject constructor( } } } - - override fun getSensorBatteryLevel(): Int { - return -1 - } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt index 365aab4911..4e10a9c728 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt @@ -91,8 +91,4 @@ class NSClientSourcePlugin @Inject constructor( lastBGTimeStamp = timeStamp } } - - override fun getSensorBatteryLevel(): Int { - return -1 - } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt index 2e161363e2..2032dd4479 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt @@ -69,8 +69,4 @@ class PoctechPlugin @Inject constructor( aapsLogger.error("Exception: ", e) } } - - override fun getSensorBatteryLevel(): Int { - return -1 - } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt index ed3101f727..3678f130a4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt @@ -100,9 +100,4 @@ class RandomBgPlugin @Inject constructor( } aapsLogger.debug(LTag.BGSOURCE, "Generated BG: $bgReading") } - - - override fun getSensorBatteryLevel(): Int { - return -1 - } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt index b80db46e5d..1ba7958b61 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt @@ -53,8 +53,4 @@ class TomatoPlugin @Inject constructor( nsUpload.sendToXdrip(bgReading) } } - - override fun getSensorBatteryLevel(): Int { - return -1 - } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java index 3903e40250..6a38de63b7 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java @@ -10,5 +10,7 @@ public interface BgSourceInterface { void handleNewData(Intent intent); - int getSensorBatteryLevel(); + default int getSensorBatteryLevel() { + return -1; + } } From ee79588449b755329444b2516ac744cd73b17438 Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 19 Oct 2020 22:14:28 +0200 Subject: [PATCH 10/17] Add setting for shorten label on very low res --- .../general/actions/ActionsFragment.kt | 21 ++++++++++++++++--- .../res/layout/careportal_stats_fragment.xml | 6 +++++- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/pref_overview.xml | 5 +++++ 4 files changed, 30 insertions(+), 4 deletions(-) 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 7d55c33782..86a120a1d6 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 @@ -239,14 +239,29 @@ class ActionsFragment : DaggerFragment() { actions_pumpbatterychange?.visibility = pump.pumpDescription.isBatteryReplaceable.toVisibility() actions_temptarget?.visibility = (profile != null && config.APS).toVisibility() actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility() + val shortlabel = sp.getBoolean(R.string.key_short_cp_label,false) + 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 = resourceHelper.gs(R.string.careportal_level_label) - careportal_inslevellabel?.text = resourceHelper.gs(R.string.careportal_level_label) - careportal_pblevellabel?.text = resourceHelper.gs(R.string.careportal_level_label) + 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) } else { statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, null, careportal_pbage, null) careportal_senslevellabel?.text = "" diff --git a/app/src/main/res/layout/careportal_stats_fragment.xml b/app/src/main/res/layout/careportal_stats_fragment.xml index 7e6bcf4d74..87ce0f6719 100644 --- a/app/src/main/res/layout/careportal_stats_fragment.xml +++ b/app/src/main/res/layout/careportal_stats_fragment.xml @@ -25,6 +25,7 @@ - WEAR SMS Shorten tab titles + Shorten Careportal labels in Actions tab Always use short average delta instead of simple delta Useful when data from unfiltered sources like xDrip gets noisy. key_advancedsettings @@ -1031,6 +1032,7 @@ Minimal request change [%] Open Loop will popup new change request only if change is bigger than this value in %. Default value is 20% short_tabtitles + short_cplabel Searching for devices… Pairing completed Do the codes displayed on this device and on your pump match? diff --git a/app/src/main/res/xml/pref_overview.xml b/app/src/main/res/xml/pref_overview.xml index 75f81c96c4..907d82d026 100644 --- a/app/src/main/res/xml/pref_overview.xml +++ b/app/src/main/res/xml/pref_overview.xml @@ -282,6 +282,11 @@ android:key="@string/key_show_statuslights" android:title="@string/show_statuslights" /> + + Date: Tue, 20 Oct 2020 21:17:28 +0200 Subject: [PATCH 11/17] Replace dedicated setting by Low Res Skin Just a copy of Classic skin for initialization --- .../dependencyInjection/SkinsModule.kt | 7 ++++++ .../general/actions/ActionsFragment.kt | 5 +++- .../nightscout/androidaps/skins/SkinLowRes.kt | 23 +++++++++++++++++++ app/src/main/res/values/strings.xml | 3 +-- app/src/main/res/xml/pref_overview.xml | 5 ---- 5 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt 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 86a120a1d6..6f19bc1fa7 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 @@ -24,6 +24,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,6 +55,7 @@ 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() @@ -239,7 +241,8 @@ class ActionsFragment : DaggerFragment() { actions_pumpbatterychange?.visibility = pump.pumpDescription.isBatteryReplaceable.toVisibility() actions_temptarget?.visibility = (profile != null && config.APS).toVisibility() actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility() - val shortlabel = sp.getBoolean(R.string.key_short_cp_label,false) + + val shortlabel = skinProvider.activeSkin().description == R.string.lowres_description if (shortlabel) { careportal_pblabel?.text = resourceHelper.gs(R.string.pump) careportal_sensoragelabel?.text = "" 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..b6c76f66bd --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt @@ -0,0 +1,23 @@ +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 + } + +} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 38304e695b..1d7ce1e024 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -403,7 +403,6 @@ WEAR SMS Shorten tab titles - Shorten Careportal labels in Actions tab Always use short average delta instead of simple delta Useful when data from unfiltered sources like xDrip gets noisy. key_advancedsettings @@ -1032,7 +1031,6 @@ Minimal request change [%] Open Loop will popup new change request only if change is bigger than this value in %. Default value is 20% short_tabtitles - short_cplabel Searching for devices… Pairing completed Do the codes displayed on this device and on your pump match? @@ -1410,6 +1408,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 907d82d026..75f81c96c4 100644 --- a/app/src/main/res/xml/pref_overview.xml +++ b/app/src/main/res/xml/pref_overview.xml @@ -282,11 +282,6 @@ android:key="@string/key_show_statuslights" android:title="@string/show_statuslights" /> - - Date: Tue, 20 Oct 2020 21:22:50 +0200 Subject: [PATCH 12/17] Little more compact Low Res layout --- .../general/actions/ActionsFragment.kt | 6 +-- .../res/layout/careportal_stats_fragment.xml | 44 ++++++++++--------- 2 files changed, 27 insertions(+), 23 deletions(-) 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 6f19bc1fa7..a767da136a 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 @@ -262,9 +262,9 @@ class ActionsFragment : DaggerFragment() { 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 (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) } else { statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, null, careportal_pbage, null) careportal_senslevellabel?.text = "" diff --git a/app/src/main/res/layout/careportal_stats_fragment.xml b/app/src/main/res/layout/careportal_stats_fragment.xml index 87ce0f6719..cd4e3452ab 100644 --- a/app/src/main/res/layout/careportal_stats_fragment.xml +++ b/app/src/main/res/layout/careportal_stats_fragment.xml @@ -29,8 +29,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" - android:paddingStart="2dp" - android:paddingRight="2dp" + android:paddingStart="0dp" + android:paddingRight="0dp" android:text="@string/careportal_age_label" android:textSize="14sp" /> @@ -39,6 +39,7 @@ 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" /> @@ -49,8 +50,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" - android:paddingStart="5dp" - android:paddingRight="2dp" + android:paddingStart="0dp" + android:paddingRight="0dp" android:text="@string/careportal_level_label" android:textSize="14sp" /> @@ -60,7 +61,7 @@ android:layout_height="wrap_content" android:gravity="center_vertical" android:layout_marginRight="20dp" - android:paddingLeft="0dp" + android:paddingLeft="2dp" android:textColor="@android:color/white" android:textSize="14sp" /> @@ -102,8 +103,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" - android:paddingStart="2dp" - android:paddingRight="2dp" + android:paddingStart="0dp" + android:paddingRight="0dp" android:text="@string/careportal_age_label" android:textSize="14sp" /> @@ -112,6 +113,7 @@ 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" /> @@ -122,8 +124,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" - android:paddingStart="5dp" - android:paddingRight="2dp" + android:paddingStart="0dp" + android:paddingRight="0dp" android:text="@string/careportal_level_label" android:textSize="14sp" /> @@ -133,7 +135,7 @@ android:layout_height="wrap_content" android:gravity="center_vertical" android:layout_marginRight="20dp" - android:paddingLeft="0dp" + android:paddingLeft="2dp" android:textColor="@android:color/white" android:textSize="14sp" /> @@ -174,8 +176,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" - android:paddingStart="2dp" - android:paddingRight="2dp" + android:paddingStart="0dp" + android:paddingRight="0dp" android:text="@string/careportal_age_label" android:textSize="14sp" /> @@ -184,6 +186,7 @@ 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" /> @@ -192,8 +195,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" - android:paddingStart="5dp" - android:paddingRight="2dp" + android:paddingStart="0dp" + android:paddingRight="0dp" android:textSize="14sp" /> @@ -245,8 +248,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" - android:paddingStart="2dp" - android:paddingRight="2dp" + android:paddingStart="0dp" + android:paddingRight="0dp" android:text="@string/careportal_age_label" android:textSize="14sp" /> @@ -255,6 +258,7 @@ 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" /> @@ -264,8 +268,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" - android:paddingStart="5dp" - android:paddingRight="2dp" + android:paddingStart="0dp" + android:paddingRight="0dp" android:text="@string/careportal_level_label" android:textSize="14sp" /> @@ -275,7 +279,7 @@ android:layout_height="wrap_content" android:gravity="center_vertical" android:layout_marginRight="20dp" - android:paddingLeft="0dp" + android:paddingLeft="2dp" android:textColor="@android:color/white" android:textSize="14sp" /> From fb95eb4f2f92cadddb06ee8eb5248003398604f4 Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 26 Oct 2020 22:55:22 +0100 Subject: [PATCH 13/17] Add LowRes Layout for action tab and additional function in Skininterface --- .../general/actions/ActionsFragment.kt | 39 +-- .../androidaps/skins/SkinInterface.kt | 2 + .../nightscout/androidaps/skins/SkinLowRes.kt | 6 +- .../res/layout/actions_fragment_lowres.xml | 304 ++++++++++++++++++ .../main/res/layout/careportal_fragment.xml | 2 +- .../careportal_stats_fragment_lowres.xml | 228 +++++++++++++ 6 files changed, 557 insertions(+), 24 deletions(-) create mode 100644 app/src/main/res/layout/actions_fragment_lowres.xml create mode 100644 app/src/main/res/layout/careportal_stats_fragment_lowres.xml 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 a767da136a..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 @@ -62,10 +64,23 @@ class ActionsFragment : DaggerFragment() { 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?) { @@ -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 = "" 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 index b6c76f66bd..529ff83e08 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt @@ -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 + } } \ 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"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 21b1117655bd63a97eaa8344f1545c0d99c11436 Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Thu, 29 Oct 2020 12:53:01 +0000 Subject: [PATCH 14/17] Add 'pregnant' age option to allow for higher insulin requirements during pregnancy --- .../aps/openAPSAMA/OpenAPSAMAPlugin.java | 4 +-- .../aps/openAPSSMB/OpenAPSSMBPlugin.java | 4 +-- .../profile/local/LocalProfileFragment.kt | 4 +-- .../nightscout/androidaps/utils/HardLimits.kt | 28 +++++++++++++++---- app/src/main/res/values/arrays.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java index 0cb082f368..25d3981c47 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java @@ -189,9 +189,9 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { } - if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.getMINDIA(), hardLimits.getMAXDIA())) + if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.minDia(), hardLimits.maxDia())) return; - if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.getMINIC(), hardLimits.getMAXIC())) + if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.minIC(), hardLimits.maxIC())) return; if (!hardLimits.checkOnlyHardLimits(profile.getIsfMgdl(), "sens", hardLimits.getMINISF(), hardLimits.getMAXISF())) return; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java index b952a6a909..e631a84955 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java @@ -220,9 +220,9 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr } - if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.getMINDIA(), hardLimits.getMAXDIA())) + if (!hardLimits.checkOnlyHardLimits(profile.getDia(), "dia", hardLimits.minDia(), hardLimits.maxDia())) return; - if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.getMINIC(), hardLimits.getMAXIC())) + if (!hardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", hardLimits.minIC(), hardLimits.maxIC())) return; if (!hardLimits.checkOnlyHardLimits(profile.getIsfMgdl(), "sens", hardLimits.getMINISF(), hardLimits.getMAXISF())) return; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index b0a1203170..b8bcd244ea 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -106,9 +106,9 @@ class LocalProfileFragment : DaggerFragment() { localprofile_name.removeTextChangedListener(textWatch) localprofile_name.setText(currentProfile.name) localprofile_name.addTextChangedListener(textWatch) - localprofile_dia.setParams(currentProfile.dia, hardLimits.MINDIA, hardLimits.MAXDIA, 0.1, DecimalFormat("0.0"), false, localprofile_save, textWatch) + localprofile_dia.setParams(currentProfile.dia, hardLimits.minDia(), hardLimits.maxDia(), 0.1, DecimalFormat("0.0"), false, localprofile_save, textWatch) localprofile_dia.tag = "LP_DIA" - TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.ic_label), currentProfile.ic, null, hardLimits.MINIC, hardLimits.MAXIC, 0.1, DecimalFormat("0.0"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.ic_label), currentProfile.ic, null, hardLimits.minIC(), hardLimits.maxIC(), 0.1, DecimalFormat("0.0"), save) basalView = TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_basal, "BASAL", resourceHelper.gs(R.string.basal_label) + ": " + sumLabel(), currentProfile.basal, null, pumpDescription.basalMinimumRate, 10.0, 0.01, DecimalFormat("0.00"), save) if (units == Constants.MGDL) { TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.isf_label), currentProfile.isf, null, hardLimits.MINISF, hardLimits.MAXISF, 1.0, DecimalFormat("0"), save) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt b/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt index 37b0c0beb6..74b6743bc8 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt @@ -24,6 +24,7 @@ class HardLimits @Inject constructor( val TEENAGE = 1 val ADULT = 2 val RESISTANTADULT = 3 + val PREGNANT = 3 val MAXBOLUS = doubleArrayOf(5.0, 10.0, 17.0, 25.0) // Very Hard Limits Ranges @@ -36,10 +37,10 @@ class HardLimits @Inject constructor( val VERY_HARD_LIMIT_TEMP_MIN_BG = intArrayOf(72, 180) val VERY_HARD_LIMIT_TEMP_MAX_BG = intArrayOf(72, 270) val VERY_HARD_LIMIT_TEMP_TARGET_BG = intArrayOf(72, 200) - val MINDIA = 5.0 - val MAXDIA = 7.0 - val MINIC = 2.0 - val MAXIC = 100.0 + val MINDIA = doubleArrayOf(5.0, 5.0, 5.0, 5.0) + val MAXDIA = doubleArrayOf(7.0, 7.0, 7.0, 10.0) + val MINIC = doubleArrayOf(2.0, 2.0, 2.0, 0.5) + val MAXIC = doubleArrayOf(100.0, 100.0, 100.0, 100.0) val MINISF = 2.0 // mgdl val MAXISF = 720.0 // mgdl val MAXIOB_AMA = doubleArrayOf(3.0, 5.0, 7.0, 12.0) @@ -57,6 +58,7 @@ class HardLimits @Inject constructor( else if (sp_age == resourceHelper.gs(R.string.key_teenage)) TEENAGE else if (sp_age == resourceHelper.gs(R.string.key_adult)) ADULT else if (sp_age == resourceHelper.gs(R.string.key_resistantadult)) RESISTANTADULT + else if (sp_age == resourceHelper.gs(R.string.key_resistantadult)) PREGNANT else ADULT return age } @@ -77,6 +79,22 @@ class HardLimits @Inject constructor( return MAXBASAL[loadAge()] } + fun minDia(): Double { + return MINDIA[loadAge()] + } + + fun maxDia(): Double { + return MAXDIA[loadAge()] + } + + fun minIC(): Double { + return MINIC[loadAge()] + } + + fun maxIC(): Double { + return MAXIC[loadAge()] + } + // safety checks fun checkOnlyHardLimits(value: Double, valueName: String?, lowLimit: Double, highLimit: Double): Boolean { return value == verifyHardLimits(value, valueName, lowLimit, highLimit) @@ -96,4 +114,4 @@ class HardLimits @Inject constructor( } return newvalue } -} \ No newline at end of file +} diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 9d3c758f57..b8fb302f4d 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -77,12 +77,14 @@ @string/teenage @string/adult @string/resistantadult + @string/pregnant @string/key_child @string/key_teenage @string/key_adult @string/key_resistantadult + @string/key_pregnant diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9b6011b98e..bdaf216ceb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -469,11 +469,13 @@ Teenage Adult Insulin resistant adult + Pregnancy age child teenage adult resistantadult + pregnant Please select patient age to setup safety limits Patient name Please provide patient name or nickname to differentiate among multiple setups From cc55649eba46f6122d0e1d8fa7edd77749676b54 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Thu, 29 Oct 2020 20:45:49 +0100 Subject: [PATCH 15/17] Add translation for Omnipod exception --- .../plugins/pump/omnipod/manager/AapsOmnipodManager.java | 3 +++ omnipod/src/main/res/values/strings.xml | 1 + 2 files changed, 4 insertions(+) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java index bf51916268..51c7fb499d 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java @@ -70,6 +70,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.NonceRes import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.NotEnoughDataException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.OmnipodException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodFaultException; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodProgressStatusVerificationFailedException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodReturnedErrorResponseException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.RileyLinkInterruptedException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.RileyLinkTimeoutException; @@ -795,6 +796,8 @@ public class AapsOmnipodManager { } else if (ex instanceof IllegalPodProgressException || ex instanceof IllegalActivationProgressException || ex instanceof IllegalDeliveryStatusException) { comment = getStringResource(R.string.omnipod_error_invalid_progress_state); + } else if (ex instanceof PodProgressStatusVerificationFailedException) { + comment = getStringResource(R.string.omnipod_error_failed_to_verify_activation_progress); } else if (ex instanceof IllegalVersionResponseTypeException) { comment = getStringResource(R.string.omnipod_error_invalid_response); } else if (ex instanceof IllegalResponseException) { diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index 8d8f940e62..76cb53c7f5 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -131,6 +131,7 @@ Failed to initialize the Pod Failed to insert cannula The Pod\'s activation time has been exceeded. This Pod can no longer be activated. + Failed to verify activation progress. Please retry. Confirmation From aa53ac11f2bfca7f0ab33d1ece882885de09cc1f Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Sun, 8 Nov 2020 00:45:49 +0000 Subject: [PATCH 16/17] Move PREGNANT to a correct key/value pair --- .../nightscout/androidaps/utils/HardLimits.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt b/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt index 74b6743bc8..0c213af0ff 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt @@ -24,8 +24,8 @@ class HardLimits @Inject constructor( val TEENAGE = 1 val ADULT = 2 val RESISTANTADULT = 3 - val PREGNANT = 3 - val MAXBOLUS = doubleArrayOf(5.0, 10.0, 17.0, 25.0) + val PREGNANT = 4 + val MAXBOLUS = doubleArrayOf(5.0, 10.0, 17.0, 25.0, 30.0) // Very Hard Limits Ranges // First value is the Lowest and second value is the Highest a Limit can define @@ -37,15 +37,15 @@ class HardLimits @Inject constructor( val VERY_HARD_LIMIT_TEMP_MIN_BG = intArrayOf(72, 180) val VERY_HARD_LIMIT_TEMP_MAX_BG = intArrayOf(72, 270) val VERY_HARD_LIMIT_TEMP_TARGET_BG = intArrayOf(72, 200) - val MINDIA = doubleArrayOf(5.0, 5.0, 5.0, 5.0) - val MAXDIA = doubleArrayOf(7.0, 7.0, 7.0, 10.0) - val MINIC = doubleArrayOf(2.0, 2.0, 2.0, 0.5) + val MINDIA = doubleArrayOf(5.0, 5.0, 5.0, 5.0, 5.0) + val MAXDIA = doubleArrayOf(7.0, 7.0, 7.0, 7.0, 10.0) + val MINIC = doubleArrayOf(2.0, 2.0, 2.0, 2.0, 0.5) val MAXIC = doubleArrayOf(100.0, 100.0, 100.0, 100.0) val MINISF = 2.0 // mgdl val MAXISF = 720.0 // mgdl - val MAXIOB_AMA = doubleArrayOf(3.0, 5.0, 7.0, 12.0) - val MAXIOB_SMB = doubleArrayOf(3.0, 7.0, 12.0, 25.0) - val MAXBASAL = doubleArrayOf(2.0, 5.0, 10.0, 12.0) + val MAXIOB_AMA = doubleArrayOf(3.0, 5.0, 7.0, 12.0, 15.0) + val MAXIOB_SMB = doubleArrayOf(3.0, 7.0, 12.0, 25.0, 30.0) + val MAXBASAL = doubleArrayOf(2.0, 5.0, 10.0, 12.0, 15.0) //LGS Hard limits //No IOB at all @@ -58,7 +58,7 @@ class HardLimits @Inject constructor( else if (sp_age == resourceHelper.gs(R.string.key_teenage)) TEENAGE else if (sp_age == resourceHelper.gs(R.string.key_adult)) ADULT else if (sp_age == resourceHelper.gs(R.string.key_resistantadult)) RESISTANTADULT - else if (sp_age == resourceHelper.gs(R.string.key_resistantadult)) PREGNANT + else if (sp_age == resourceHelper.gs(R.string.key_pregnant)) PREGNANT else ADULT return age } From e89eb67236f28d79e8cdc3bbf47cd21982e6e495 Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Sun, 8 Nov 2020 16:31:10 +0000 Subject: [PATCH 17/17] Update hard limits based on looping in pregnancy group feedback --- .../info/nightscout/androidaps/utils/HardLimits.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt b/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt index 0c213af0ff..61839a8bf4 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt @@ -25,7 +25,7 @@ class HardLimits @Inject constructor( val ADULT = 2 val RESISTANTADULT = 3 val PREGNANT = 4 - val MAXBOLUS = doubleArrayOf(5.0, 10.0, 17.0, 25.0, 30.0) + val MAXBOLUS = doubleArrayOf(5.0, 10.0, 17.0, 25.0, 60.0) // Very Hard Limits Ranges // First value is the Lowest and second value is the Highest a Limit can define @@ -39,13 +39,13 @@ class HardLimits @Inject constructor( val VERY_HARD_LIMIT_TEMP_TARGET_BG = intArrayOf(72, 200) val MINDIA = doubleArrayOf(5.0, 5.0, 5.0, 5.0, 5.0) val MAXDIA = doubleArrayOf(7.0, 7.0, 7.0, 7.0, 10.0) - val MINIC = doubleArrayOf(2.0, 2.0, 2.0, 2.0, 0.5) - val MAXIC = doubleArrayOf(100.0, 100.0, 100.0, 100.0) + val MINIC = doubleArrayOf(2.0, 2.0, 2.0, 2.0, 0.3) + val MAXIC = doubleArrayOf(100.0, 100.0, 100.0, 100.0, 100.0) val MINISF = 2.0 // mgdl val MAXISF = 720.0 // mgdl - val MAXIOB_AMA = doubleArrayOf(3.0, 5.0, 7.0, 12.0, 15.0) - val MAXIOB_SMB = doubleArrayOf(3.0, 7.0, 12.0, 25.0, 30.0) - val MAXBASAL = doubleArrayOf(2.0, 5.0, 10.0, 12.0, 15.0) + val MAXIOB_AMA = doubleArrayOf(3.0, 5.0, 7.0, 12.0, 25.0) + val MAXIOB_SMB = doubleArrayOf(3.0, 7.0, 12.0, 25.0, 40.0) + val MAXBASAL = doubleArrayOf(2.0, 5.0, 10.0, 12.0, 25.0) //LGS Hard limits //No IOB at all