diff --git a/app/build.gradle b/app/build.gradle index 2ba21b4d43..c9e31881d3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -246,7 +246,7 @@ dependencies { testImplementation "junit:junit:$junit_version" testImplementation 'org.json:json:20200518' - testImplementation "org.mockito:mockito-core:2.8.47" + testImplementation "org.mockito:mockito-core:${mockitoVersion}" testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}" testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}" testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}" diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index 709e290e8d..951638d9ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -95,6 +95,7 @@ class MainActivity : NoSplashAppCompatActivity() { private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle private var pluginPreferencesMenuItem: MenuItem? = null + private var menu: Menu? = null val callForPrefFile = registerForActivityResult(PrefsFileContract()) { it?.let { @@ -122,6 +123,7 @@ class MainActivity : NoSplashAppCompatActivity() { override fun onPageScrollStateChanged(state: Int) {} override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {} override fun onPageSelected(position: Int) { + setPluginPreferenceMenuName() checkPluginPreferences(main_pager) } }) @@ -200,6 +202,12 @@ class MainActivity : NoSplashAppCompatActivity() { if (p.isEnabled() && p.hasFragment() && !p.isFragmentVisible() && !p.pluginDescription.neverVisible) { val menuItem = menu.add(p.name) menuItem.isCheckable = true + if(p.menuIcon != -1) { + menuItem.setIcon(p.menuIcon) + } else + { + menuItem.setIcon(R.drawable.ic_settings) + } menuItem.setOnMenuItemClickListener { val intent = Intent(this, SingleFragmentActivity::class.java) intent.putExtra("plugin", activePlugin.getPluginsList().indexOf(p)) @@ -266,9 +274,16 @@ class MainActivity : NoSplashAppCompatActivity() { return super.dispatchTouchEvent(event) } + private fun setPluginPreferenceMenuName() { + val plugin = (main_pager.adapter as TabPageAdapter).getPluginAt(main_pager.currentItem) + this.menu?.findItem(R.id.nav_plugin_preferences)?.title = resourceHelper.gs(R.string.nav_preferences_plugin, plugin.name) + } + override fun onCreateOptionsMenu(menu: Menu): Boolean { + this.menu = menu menuInflater.inflate(R.menu.menu_main, menu) pluginPreferencesMenuItem = menu.findItem(R.id.nav_plugin_preferences) + setPluginPreferenceMenuName() checkPluginPreferences(main_pager) return true } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt index 9bdf58287f..b11d256efd 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -13,6 +13,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TempTarget +import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin @@ -32,6 +33,9 @@ class TempTargetDialog : DialogFragmentWithDate() { @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var defaultValueHelper: DefaultValueHelper @Inject lateinit var treatmentsPlugin: TreatmentsPlugin + @Inject lateinit var activePlugin: ActivePluginProvider + + lateinit var reasonList: List override fun onSaveInstanceState(savedInstanceState: Bundle) { super.onSaveInstanceState(savedInstanceState) @@ -64,52 +68,81 @@ class TempTargetDialog : DialogFragmentWithDate() { val units = profileFunction.getUnits() overview_temptarget_units.text = if (units == Constants.MMOL) resourceHelper.gs(R.string.mmol) else resourceHelper.gs(R.string.mgdl) + // temp target context?.let { context -> - val reasonList: List = Lists.newArrayList( + if (activePlugin.activeTreatments.tempTargetFromHistory != null) + overview_temptarget_cancel?.visibility = View.VISIBLE + else + overview_temptarget_cancel?.visibility = View.GONE + + reasonList = Lists.newArrayList( resourceHelper.gs(R.string.manual), - resourceHelper.gs(R.string.cancel), resourceHelper.gs(R.string.eatingsoon), resourceHelper.gs(R.string.activity), resourceHelper.gs(R.string.hypo) ) val adapterReason = ArrayAdapter(context, R.layout.spinner_centered, reasonList) overview_temptarget_reason.adapter = adapterReason - overview_temptarget_reason.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { - override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { - val defaultDuration: Double - val defaultTarget: Double - when (reasonList[position]) { - resourceHelper.gs(R.string.eatingsoon) -> { - defaultDuration = defaultValueHelper.determineEatingSoonTTDuration().toDouble() - defaultTarget = defaultValueHelper.determineEatingSoonTT() - } - resourceHelper.gs(R.string.activity) -> { - defaultDuration = defaultValueHelper.determineActivityTTDuration().toDouble() - defaultTarget = defaultValueHelper.determineActivityTT() - } + overview_temptarget_custom?.setOnClickListener { + overview_temptarget_temptarget.value = savedInstanceState?.getDouble("overview_temptarget_temptarget") ?: if (profileFunction.getUnits() == Constants.MMOL) Constants.MIN_TT_MMOL else Constants.MIN_TT_MGDL + overview_temptarget_duration.value = savedInstanceState?.getDouble("overview_temptarget_duration") ?: 0.0 + overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.manual))); + } - resourceHelper.gs(R.string.hypo) -> { - defaultDuration = defaultValueHelper.determineHypoTTDuration().toDouble() - defaultTarget = defaultValueHelper.determineHypoTT() - } + overview_temptarget_cancel?.setOnClickListener { shortClick(it) } + overview_temptarget_eating_soon?.setOnClickListener { shortClick(it) } + overview_temptarget_activity?.setOnClickListener { shortClick(it) } + overview_temptarget_hypo?.setOnClickListener { shortClick(it) } + /* + overview_temptarget_cancel?.setOnLongClickListener { + longClick(it) + return@setOnLongClickListener true + } - resourceHelper.gs(R.string.cancel) -> { - defaultDuration = 0.0 - defaultTarget = 0.0 - } + */ + overview_temptarget_eating_soon?.setOnLongClickListener { + longClick(it) + return@setOnLongClickListener true + } + overview_temptarget_activity?.setOnLongClickListener { + longClick(it) + return@setOnLongClickListener true + } + overview_temptarget_hypo?.setOnLongClickListener { + longClick(it) + return@setOnLongClickListener true + } + } + } - else -> { - defaultDuration = overview_temptarget_duration.value - defaultTarget = overview_temptarget_temptarget.value - } - } - overview_temptarget_temptarget.value = defaultTarget - overview_temptarget_duration.value = defaultDuration - } + private fun shortClick(v:View){ + v.performLongClick() + if (submit()) dismiss() + } - override fun onNothingSelected(parent: AdapterView<*>?) {} + private fun longClick(v:View) { + when (v.id) { + R.id.overview_temptarget_cancel -> { + overview_temptarget_temptarget.value = 0.0 + overview_temptarget_duration.value = 0.0 + overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.cancel))) + } + R.id.overview_temptarget_eating_soon -> { + overview_temptarget_temptarget.value = defaultValueHelper.determineEatingSoonTT() + overview_temptarget_duration.value = defaultValueHelper.determineEatingSoonTTDuration().toDouble() + overview_temptarget_reason.setSelection(reasonList.indexOf( resourceHelper.gs(R.string.eatingsoon))) + } + R.id.overview_temptarget_activity -> { + overview_temptarget_temptarget.value = defaultValueHelper.determineActivityTT() + overview_temptarget_duration.value = defaultValueHelper.determineActivityTTDuration().toDouble() + overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.activity))) + } + R.id.overview_temptarget_hypo -> { + overview_temptarget_temptarget.value = defaultValueHelper.determineHypoTT() + overview_temptarget_duration.value = defaultValueHelper.determineHypoTTDuration().toDouble() + overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.hypo))) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java index af8f4e3125..0c27aeac44 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java @@ -145,6 +145,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface { super(new PluginDescription() .mainType(PluginType.LOOP) .fragmentClass(LoopFragment.class.getName()) + .pluginIcon(R.drawable.ic_loop_closed_white) .pluginName(R.string.loop) .shortName(R.string.loop_shortname) .preferencesId(R.xml.pref_loop) 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 25d3981c47..7d132db4d3 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 @@ -80,6 +80,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { super(new PluginDescription() .mainType(PluginType.APS) .fragmentClass(OpenAPSAMAFragment.class.getName()) + .pluginIcon(R.drawable.ic_generic_icon) .pluginName(R.string.openapsama) .shortName(R.string.oaps_shortname) .preferencesId(R.xml.pref_openapsama) 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 e631a84955..4a6ec60b7d 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 @@ -88,6 +88,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr super(new PluginDescription() .mainType(PluginType.APS) .fragmentClass(OpenAPSSMBFragment.class.getName()) + .pluginIcon(R.drawable.ic_generic_icon) .pluginName(R.string.openapssmb) .shortName(R.string.smb_shortname) .preferencesId(R.xml.pref_openapssmb) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt index 58d31eb29b..4fb140d55a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt @@ -32,6 +32,7 @@ class ConfigBuilderPlugin @Inject constructor( .showInList(true) .alwaysEnabled(true) .alwaysVisible(false) + .pluginIcon(R.drawable.ic_cogs) .pluginName(R.string.configbuilder) .shortName(R.string.configbuilder_shortname) .description(R.string.description_config_builder), diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt index 1c33eb7a2f..c28085f425 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -32,6 +32,7 @@ class ObjectivesPlugin @Inject constructor( .fragmentClass(ObjectivesFragment::class.qualifiedName) .alwaysEnabled(config.APS) .showInList(config.APS) + .pluginIcon(R.drawable.ic_graduation) .pluginName(R.string.objectives) .shortName(R.string.objectives_shortname) .description(R.string.description_objectives), diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt index ff3927da71..9b4e4478b7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt @@ -22,6 +22,7 @@ class ActionsPlugin @Inject constructor( .fragmentClass(ActionsFragment::class.qualifiedName) .enableByDefault(config.APS || config.PUMPCONTROL) .visibleByDefault(config.APS || config.PUMPCONTROL) + .pluginIcon(R.drawable.ic_action) .pluginName(R.string.actions) .shortName(R.string.actions_shortname) .description(R.string.description_actions), diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt index 040f01a141..ed6e758da1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt @@ -57,6 +57,7 @@ class AutomationPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(AutomationFragment::class.qualifiedName) + .pluginIcon(R.drawable.ic_automation) .pluginName(R.string.automation) .shortName(R.string.automation_short) .preferencesId(R.xml.pref_automation) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt index 3482a9b11a..d44550a11d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt @@ -18,6 +18,7 @@ class FoodPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(FoodFragment::class.java.name) + .pluginIcon(R.drawable.ic_food) .pluginName(R.string.food) .shortName(R.string.food_short) .description(R.string.description_food), diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt index 86b1e71db6..6f7cd7401e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt @@ -40,6 +40,7 @@ class MaintenancePlugin @Inject constructor( .fragmentClass(MaintenanceFragment::class.java.name) .alwaysVisible(false) .alwaysEnabled(true) + .pluginIcon(R.drawable.ic_maintenance) .pluginName(R.string.maintenance) .shortName(R.string.maintenance_shortname) .preferencesId(R.xml.pref_maintenance) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java index 82f7ab44ef..a82a989e19 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java @@ -90,6 +90,7 @@ public class NSClientPlugin extends PluginBase { super(new PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(NSClientFragment.class.getName()) + .pluginIcon(R.drawable.ic_nightscout_syncs) .pluginName(R.string.nsclientinternal) .shortName(R.string.nsclientinternal_shortname) .preferencesId(R.xml.pref_nsclientinternal) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/openhumans/OpenHumansUploader.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/openhumans/OpenHumansUploader.kt index b1c80f5b25..af530665f0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/openhumans/OpenHumansUploader.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/openhumans/OpenHumansUploader.kt @@ -59,6 +59,7 @@ class OpenHumansUploader @Inject constructor( ) : PluginBase( PluginDescription() .mainType(PluginType.GENERAL) + .pluginIcon(R.drawable.open_humans_white) .pluginName(R.string.open_humans) .shortName(R.string.open_humans_short) .description(R.string.donate_your_data_to_science) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt index 3691de301d..7f82ccbd09 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt @@ -41,6 +41,7 @@ class OverviewPlugin @Inject constructor( .fragmentClass(OverviewFragment::class.qualifiedName) .alwaysVisible(true) .alwaysEnabled(true) + .pluginIcon(R.drawable.ic_home) .pluginName(R.string.overview) .shortName(R.string.overview_shortname) .preferencesId(R.xml.pref_overview) 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 af361236fa..dbdfe39bb4 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 @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.general.overview +import android.graphics.Color import android.widget.TextView import androidx.annotation.StringRes import info.nightscout.androidaps.Config @@ -8,6 +9,8 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.pump.common.defs.PumpType +import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin +import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.WarnColors import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -33,16 +36,28 @@ class StatusLightHandler @Inject constructor( 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 (pump.pumpDescription.isBatteryReplaceable) { + handleAge(careportal_pbage, CareportalEvent.PUMPBATTERYCHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0) + } 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 (pump.model() == PumpType.Insulet_Omnipod) { + handleOmnipodReservoirLevel(careportal_reservoirlevel, R.string.key_statuslights_res_critical, 10.0, R.string.key_statuslights_res_warning, 80.0, pump.reservoirLevel, "U") + } else { + 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(), "%") + + if (!config.NSCLIENT) { + if (pump.model() == PumpType.Insulet_Omnipod && pump is OmnipodPumpPlugin) { // instanceof check is needed because at startup, pump can still be VirtualPumpPlugin and that will cause a crash because of the class cast below + handleOmnipodBatteryLevel(careportal_batterylevel, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%", (pump as OmnipodPumpPlugin).isUseRileyLinkBatteryLevel) + } else if (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(), "%") + } + } } private fun handleAge(view: TextView?, eventName: String, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) { @@ -64,4 +79,24 @@ class StatusLightHandler @Inject constructor( view?.text = " " + DecimalFormatter.to0Decimal(level) + units warnColors.setColorInverse(view, level, resWarn, resUrgent) } + + // Omnipod only reports reservoir level when it's 50 units or less, so we display "50+U" for any value > 50 + private fun handleOmnipodReservoirLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double, units: String) { + if (level > OmnipodConstants.MAX_RESERVOIR_READING) { + @Suppress("SetTextI18n") + view?.text = " 50+$units" + view?.setTextColor(Color.WHITE) + } else { + handleLevel(view, criticalSetting, criticalDefaultValue, warnSetting, warnDefaultValue, level, units) + } + } + + private fun handleOmnipodBatteryLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double, units: String, useRileyLinkBatteryLevel: Boolean) { + if (useRileyLinkBatteryLevel) { + handleLevel(view, criticalSetting, criticalDefaultValue, warnSetting, warnDefaultValue, level, units) + } else { + view?.text = resourceHelper.gs(R.string.notavailable) + view?.setTextColor(Color.WHITE) + } + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index d6c48043cf..ed177167c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -66,6 +66,7 @@ class SmsCommunicatorPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(SmsCommunicatorFragment::class.java.name) + .pluginIcon(R.drawable.ic_sms) .pluginName(R.string.smscommunicator) .shortName(R.string.smscommunicator_shortname) .preferencesId(R.xml.pref_smscommunicator) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt index 02b201f5ab..3325e48ca1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt @@ -39,6 +39,7 @@ class WearPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(WearFragment::class.java.name) + .pluginIcon(R.drawable.ic_watch) .pluginName(R.string.wear) .shortName(R.string.wear_shortname) .preferencesId(R.xml.pref_wear) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt index 067c444eaa..f5285334f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt @@ -43,6 +43,7 @@ class StatusLinePlugin @Inject constructor( ) : PluginBase( PluginDescription() .mainType(PluginType.GENERAL) + .pluginIcon((R.drawable.ic_blooddrop_48)) .pluginName(R.string.xdripstatus) .shortName(R.string.xdripstatus_shortname) .neverVisible(true) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPlugin.kt index c9f2a6d96e..717429eb44 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPlugin.kt @@ -31,6 +31,7 @@ class InsulinLyumjevPlugin @Inject constructor( init { pluginDescription + .pluginIcon(R.drawable.ic_insulin) .pluginName(R.string.lyumjev) .description(R.string.description_insulin_lyumjev) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt index 1e90792d25..1ffb885866 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt @@ -29,6 +29,7 @@ abstract class InsulinOrefBasePlugin( ) : PluginBase(PluginDescription() .mainType(PluginType.INSULIN) .fragmentClass(InsulinFragment::class.java.name) + .pluginIcon(R.drawable.ic_insulin) .shortName(R.string.insulin_shortname) .visibleByDefault(false), aapsLogger, resourceHelper, injector diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt index b5df82a4e8..7200032b3c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt @@ -49,6 +49,7 @@ class InsulinOrefFreePeakPlugin @Inject constructor( init { pluginDescription + .pluginIcon(R.drawable.ic_insulin) .pluginName(R.string.free_peak_oref) .preferencesId(R.xml.pref_insulinoreffreepeak) .description(R.string.description_insulin_free_peak) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index e0e0ee8e55..07be4da165 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -37,6 +37,7 @@ class LocalProfilePlugin @Inject constructor( .mainType(PluginType.PROFILE) .fragmentClass(LocalProfileFragment::class.java.name) .enableByDefault(true) + .pluginIcon(R.drawable.ic_local_profile) .pluginName(R.string.localprofile) .shortName(R.string.localprofile_shortname) .description(R.string.description_profile_local) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt index 31aa4a2df1..eb2b3ffe89 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt @@ -32,6 +32,7 @@ class NSProfilePlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.PROFILE) .fragmentClass(NSProfileFragment::class.java.name) + .pluginIcon(R.drawable.ic_nightscout_profile) .pluginName(R.string.nsprofile) .shortName(R.string.profileviewer_shortname) .alwaysEnabled(config.NSCLIENT) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index 8b9c39fce9..cee77a2303 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -147,7 +147,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr super(new PluginDescription() .mainType(PluginType.PUMP) .fragmentClass(ComboFragment.class.getName()) - .pluginIcon(R.drawable.ic_combo) + .pluginIcon(R.drawable.ic_combo_128) .pluginName(R.string.combopump) .shortName(R.string.combopump_shortname) .description(R.string.description_pump_combo), @@ -338,7 +338,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr * Runs pump initialization if needed and reads the pump state from the main screen. */ @Override - public synchronized void getPumpStatus() { + public synchronized void getPumpStatus(String reason) { getAapsLogger().debug(LTag.PUMP, "getPumpStatus called"); if (!pump.initialized) { initializePump(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index dc58e98d8c..c02404ff69 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -219,7 +219,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, DateUtil dateUtil ) { super(new PluginDescription() - .pluginIcon(R.drawable.ic_insight) + .pluginIcon(R.drawable.ic_insight_128) .pluginName(R.string.insight_local) .shortName(R.string.insightpump_shortname) .mainType(PluginType.PUMP) @@ -370,7 +370,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, } @Override - public void getPumpStatus() { + public void getPumpStatus(String reason) { try { tbrOverNotificationBlock = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, TBROverNotificationBlock.class); readHistory(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java index 9810aecc38..c3aedab567 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java @@ -57,6 +57,7 @@ public class MDIPlugin extends PumpPluginBase implements PumpInterface { ) { super(new PluginDescription() .mainType(PluginType.PUMP) + .pluginIcon(R.drawable.ic_ict) .pluginName(R.string.mdi) .description(R.string.description_pump_mdi), injector, aapsLogger, resourceHelper, commandQueue @@ -132,7 +133,7 @@ public class MDIPlugin extends PumpPluginBase implements PumpInterface { } @Override - public void getPumpStatus() { + public void getPumpStatus(String reason) { } @NonNull @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt index 1d6ab21c4e..d5eab6b5d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt @@ -58,6 +58,7 @@ class VirtualPumpPlugin @Inject constructor( ) : PumpPluginBase(PluginDescription() .mainType(PluginType.PUMP) .fragmentClass(VirtualPumpFragment::class.java.name) + .pluginIcon(R.drawable.ic_virtual_pump) .pluginName(R.string.virtualpump) .shortName(R.string.virtualpump_shortname) .preferencesId(R.xml.pref_virtualpump) @@ -178,7 +179,7 @@ class VirtualPumpPlugin @Inject constructor( override fun disconnect(reason: String) {} override fun stopConnecting() {} - override fun getPumpStatus() { + override fun getPumpStatus(reason: String?) { lastDataTime = System.currentTimeMillis() } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java index dbfaa9c8cd..500518a419 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java @@ -56,6 +56,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { ) { super(new PluginDescription() .mainType(PluginType.SENSITIVITY) + .pluginIcon(R.drawable.ic_generic_icon) .pluginName(R.string.sensitivityaaps) .shortName(R.string.sensitivity_shortname) .preferencesId(R.xml.pref_absorption_aaps) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java index f4da392efa..233cd675d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java @@ -55,6 +55,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { ) { super(new PluginDescription() .mainType(PluginType.SENSITIVITY) + .pluginIcon(R.drawable.ic_generic_icon) .pluginName(R.string.sensitivityoref1) .shortName(R.string.sensitivity_shortname) .enableByDefault(true) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java index 7d957bf39d..3cc34908a5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java @@ -51,6 +51,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin ) { super(new PluginDescription() .mainType(PluginType.SENSITIVITY) + .pluginIcon(R.drawable.ic_generic_icon) .pluginName(R.string.sensitivityweightedaverage) .shortName(R.string.sensitivity_shortname) .preferencesId(R.xml.pref_absorption_aaps) 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..29497ff29b 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 @@ -38,6 +38,7 @@ class DexcomPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) + .pluginIcon(R.drawable.ic_dexcom_g6) .pluginName(R.string.dexcom_app_patched) .shortName(R.string.dexcom_short) .preferencesId(R.xml.pref_bgsourcedexcom) 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 ff28aa3f2a..d447602d37 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 @@ -34,6 +34,7 @@ class EversensePlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) + .pluginIcon(R.drawable.ic_eversense) .pluginName(R.string.eversense) .shortName(R.string.eversense_shortname) .preferencesId(R.xml.pref_bgsource) 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..e14503bfbb 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 @@ -24,6 +24,7 @@ class GlimpPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) + .pluginIcon(R.drawable.ic_glimp) .pluginName(R.string.Glimp) .preferencesId(R.xml.pref_bgsource) .description(R.string.description_source_glimp), 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..064830b175 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 @@ -25,6 +25,7 @@ class MM640gPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) + .pluginIcon(R.drawable.ic_generic_cgm) .pluginName(R.string.MM640g) .description(R.string.description_source_mm640g), aapsLogger, resourceHelper, injector 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..7f3d4707d4 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 @@ -32,6 +32,7 @@ class NSClientSourcePlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) + .pluginIcon(R.drawable.ic_nsclient_bg) .pluginName(R.string.nsclientbg) .description(R.string.description_source_ns_client), aapsLogger, resourceHelper, injector 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..eace9e0e0e 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 @@ -31,6 +31,7 @@ class PoctechPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) + .pluginIcon(R.drawable.ic_poctech) .pluginName(R.string.poctech) .preferencesId(R.xml.pref_bgsource) .description(R.string.description_source_poctech), 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..fe98aad3e1 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 @@ -40,6 +40,7 @@ class RandomBgPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) + .pluginIcon(R.drawable.ic_dice) .pluginName(R.string.randombg) .shortName(R.string.randombg_short) .preferencesId(R.xml.pref_bgsource) 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..6d62468cd7 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 @@ -27,6 +27,7 @@ class TomatoPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) + .pluginIcon(R.drawable.ic_sensor) .pluginName(R.string.tomato) .preferencesId(R.xml.pref_bgsource) .shortName(R.string.tomato_short) 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..130a985853 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 @@ -25,6 +25,7 @@ class XdripPlugin @Inject constructor( ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) + .pluginIcon((R.drawable.ic_blooddrop_48)) .pluginName(R.string.xdrip) .description(R.string.description_source_xdrip), aapsLogger, resourceHelper, injector diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java index 8f16999cf8..507f649a55 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java @@ -111,6 +111,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface super(new PluginDescription() .mainType(PluginType.TREATMENT) .fragmentClass(TreatmentsFragment.class.getName()) + .pluginIcon(R.drawable.ic_treatments) .pluginName(R.string.treatments) .shortName(R.string.treatments_shortname) .alwaysEnabled(true) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt index 6c2e4ca83f..052ad8a515 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt @@ -11,7 +11,7 @@ import javax.inject.Inject class CommandReadStatus( injector: HasAndroidInjector, - private val reason: String, + val reason: String, callback: Callback? ) : Command(injector, CommandType.READSTATUS, callback) { @@ -19,7 +19,7 @@ class CommandReadStatus( @Inject lateinit var localAlertUtils: LocalAlertUtils override fun execute() { - activePlugin.activePump.getPumpStatus() + activePlugin.activePump.getPumpStatus(reason) localAlertUtils.notifyPumpStatusRead() aapsLogger.debug(LTag.PUMPQUEUE, "CommandReadStatus executed. Reason: $reason") val pump = activePlugin.activePump diff --git a/app/src/main/res/drawable/ic_action.xml b/app/src/main/res/drawable/ic_action.xml new file mode 100644 index 0000000000..d8f9511303 --- /dev/null +++ b/app/src/main/res/drawable/ic_action.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_automation.xml b/app/src/main/res/drawable/ic_automation.xml new file mode 100644 index 0000000000..1b237ebe15 --- /dev/null +++ b/app/src/main/res/drawable/ic_automation.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_cogs.xml b/app/src/main/res/drawable/ic_cogs.xml new file mode 100644 index 0000000000..683af44c47 --- /dev/null +++ b/app/src/main/res/drawable/ic_cogs.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_combo_128.xml b/app/src/main/res/drawable/ic_combo_128.xml new file mode 100644 index 0000000000..967f8d7aac --- /dev/null +++ b/app/src/main/res/drawable/ic_combo_128.xml @@ -0,0 +1,351 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_dice.xml b/app/src/main/res/drawable/ic_dice.xml new file mode 100644 index 0000000000..de1b02ea11 --- /dev/null +++ b/app/src/main/res/drawable/ic_dice.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_eversense.xml b/app/src/main/res/drawable/ic_eversense.xml new file mode 100644 index 0000000000..dcd2558cf8 --- /dev/null +++ b/app/src/main/res/drawable/ic_eversense.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_food.xml b/app/src/main/res/drawable/ic_food.xml new file mode 100644 index 0000000000..11e36cf01c --- /dev/null +++ b/app/src/main/res/drawable/ic_food.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_generic_cgm.xml b/app/src/main/res/drawable/ic_generic_cgm.xml new file mode 100644 index 0000000000..9690973615 --- /dev/null +++ b/app/src/main/res/drawable/ic_generic_cgm.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_generic_icon.xml b/app/src/main/res/drawable/ic_generic_icon.xml new file mode 100644 index 0000000000..21ad8c26fa --- /dev/null +++ b/app/src/main/res/drawable/ic_generic_icon.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_glimp.xml b/app/src/main/res/drawable/ic_glimp.xml new file mode 100644 index 0000000000..73b42ccd97 --- /dev/null +++ b/app/src/main/res/drawable/ic_glimp.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_graduation.xml b/app/src/main/res/drawable/ic_graduation.xml new file mode 100644 index 0000000000..b482163d20 --- /dev/null +++ b/app/src/main/res/drawable/ic_graduation.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_home.xml b/app/src/main/res/drawable/ic_home.xml new file mode 100644 index 0000000000..977dc1f183 --- /dev/null +++ b/app/src/main/res/drawable/ic_home.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_ict.xml b/app/src/main/res/drawable/ic_ict.xml new file mode 100644 index 0000000000..c7d77b4d0a --- /dev/null +++ b/app/src/main/res/drawable/ic_ict.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_insight_128.xml b/app/src/main/res/drawable/ic_insight_128.xml new file mode 100644 index 0000000000..c9b0614b22 --- /dev/null +++ b/app/src/main/res/drawable/ic_insight_128.xml @@ -0,0 +1,422 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_local_profile.xml b/app/src/main/res/drawable/ic_local_profile.xml new file mode 100644 index 0000000000..d103cafaa7 --- /dev/null +++ b/app/src/main/res/drawable/ic_local_profile.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_loop_closed_white.xml b/app/src/main/res/drawable/ic_loop_closed_white.xml new file mode 100644 index 0000000000..05b246460b --- /dev/null +++ b/app/src/main/res/drawable/ic_loop_closed_white.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_maintenance.xml b/app/src/main/res/drawable/ic_maintenance.xml index 7f606d8b44..12313e8445 100644 --- a/app/src/main/res/drawable/ic_maintenance.xml +++ b/app/src/main/res/drawable/ic_maintenance.xml @@ -1,9 +1,12 @@ + android:width="64dp" + android:height="64dp" + android:viewportWidth="64" + android:viewportHeight="64"> + android:pathData="M30.342,24.318c1.366,3.679 4.175,6.646 7.729,8.193c-0.101,0.988 -0.53,1.949 -1.287,2.705l-19.957,19.958c-1.746,1.746 -4.582,1.746 -6.329,-0l-3.26,-3.26c-1.746,-1.747 -1.746,-4.583 0,-6.329l19.958,-19.957c0.868,-0.869 2.007,-1.306 3.146,-1.31ZM16.307,44.823c1.159,0 2.1,0.932 2.1,2.079c-0,1.147 -0.941,2.078 -2.1,2.078c-1.159,0 -2.099,-0.931 -2.099,-2.078c-0,-1.147 0.94,-2.079 2.099,-2.079Z" + android:fillColor="@android:color/white"/> + diff --git a/app/src/main/res/drawable/ic_nightscout_profile.xml b/app/src/main/res/drawable/ic_nightscout_profile.xml new file mode 100644 index 0000000000..43067c125e --- /dev/null +++ b/app/src/main/res/drawable/ic_nightscout_profile.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_nightscout_syncs.xml b/app/src/main/res/drawable/ic_nightscout_syncs.xml new file mode 100644 index 0000000000..1558d5705b --- /dev/null +++ b/app/src/main/res/drawable/ic_nightscout_syncs.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/ic_nsclient_bg.xml b/app/src/main/res/drawable/ic_nsclient_bg.xml new file mode 100644 index 0000000000..21b7076454 --- /dev/null +++ b/app/src/main/res/drawable/ic_nsclient_bg.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_poctech.xml b/app/src/main/res/drawable/ic_poctech.xml new file mode 100644 index 0000000000..6fe7de817b --- /dev/null +++ b/app/src/main/res/drawable/ic_poctech.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_sms.xml b/app/src/main/res/drawable/ic_sms.xml new file mode 100644 index 0000000000..2ec87c9e5e --- /dev/null +++ b/app/src/main/res/drawable/ic_sms.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_target_activity.xml b/app/src/main/res/drawable/ic_target_activity.xml new file mode 100644 index 0000000000..4439597b75 --- /dev/null +++ b/app/src/main/res/drawable/ic_target_activity.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_target_cancel.xml b/app/src/main/res/drawable/ic_target_cancel.xml new file mode 100644 index 0000000000..50d7304662 --- /dev/null +++ b/app/src/main/res/drawable/ic_target_cancel.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_target_eatingsoon.xml b/app/src/main/res/drawable/ic_target_eatingsoon.xml new file mode 100644 index 0000000000..54b6162546 --- /dev/null +++ b/app/src/main/res/drawable/ic_target_eatingsoon.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_target_hypo.xml b/app/src/main/res/drawable/ic_target_hypo.xml new file mode 100644 index 0000000000..30721cbf14 --- /dev/null +++ b/app/src/main/res/drawable/ic_target_hypo.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_target_manual.xml b/app/src/main/res/drawable/ic_target_manual.xml new file mode 100644 index 0000000000..fc41c52757 --- /dev/null +++ b/app/src/main/res/drawable/ic_target_manual.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_treatments.xml b/app/src/main/res/drawable/ic_treatments.xml new file mode 100644 index 0000000000..a9880c927d --- /dev/null +++ b/app/src/main/res/drawable/ic_treatments.xml @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_virtual_pump.xml b/app/src/main/res/drawable/ic_virtual_pump.xml new file mode 100644 index 0000000000..1f813674ff --- /dev/null +++ b/app/src/main/res/drawable/ic_virtual_pump.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_watch.xml b/app/src/main/res/drawable/ic_watch.xml new file mode 100644 index 0000000000..533dd8723a --- /dev/null +++ b/app/src/main/res/drawable/ic_watch.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/open_humans_white.xml b/app/src/main/res/drawable/open_humans_white.xml new file mode 100644 index 0000000000..afe86dee75 --- /dev/null +++ b/app/src/main/res/drawable/open_humans_white.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 28164e3ef3..dafd9e55eb 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -50,9 +50,11 @@ android:id="@+id/main_navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" - app:itemBackground="?selectableItemBackground" - app:itemTextColor="#FFFFFF" - android:layout_gravity="start" /> + app:itemBackground="?attr/selectableItemBackground" + android:fitsSystemWindows="true" + android:layout_gravity="start" + app:itemIconTint="@android:color/white" + app:itemTextColor="@android:color/white"/> \ No newline at end of file diff --git a/app/src/main/res/layout/configbuilder_fragment.xml b/app/src/main/res/layout/configbuilder_fragment.xml index 954bc314a1..1073643100 100644 --- a/app/src/main/res/layout/configbuilder_fragment.xml +++ b/app/src/main/res/layout/configbuilder_fragment.xml @@ -1,6 +1,7 @@ @@ -11,10 +12,11 @@ android:background="@android:color/transparent" android:text="@string/unlock_settings" /> - + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + \ No newline at end of file diff --git a/app/src/main/res/layout/configbuilder_single_category.xml b/app/src/main/res/layout/configbuilder_single_category.xml index 4c7d9787de..2f6177b593 100644 --- a/app/src/main/res/layout/configbuilder_single_category.xml +++ b/app/src/main/res/layout/configbuilder_single_category.xml @@ -20,14 +20,14 @@ android:id="@+id/category_title" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textColor="@color/colorAccent" + android:textColor="?android:attr/colorAccent" android:textSize="16sp" /> @@ -36,6 +36,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:layout_margin="4dp" + app:tint="?android:attr/colorAccent" app:srcCompat="@drawable/ic_visibility" /> diff --git a/app/src/main/res/layout/configbuilder_single_plugin.xml b/app/src/main/res/layout/configbuilder_single_plugin.xml index 4e78d990db..94d6468828 100644 --- a/app/src/main/res/layout/configbuilder_single_plugin.xml +++ b/app/src/main/res/layout/configbuilder_single_plugin.xml @@ -12,51 +12,58 @@ android:saveEnabled="false" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="16dp" /> + android:layout_marginEnd="6dp" /> + android:layout_marginEnd="6dp" /> + android:orientation="horizontal"> + android:layout_height="36dp" + android:layout_marginEnd="8dp" + android:layout_gravity="center_vertical"/> - + android:layout_marginBottom="12dp" + android:layout_marginTop="12dp" + android:orientation="vertical"> + + + + + - diff --git a/app/src/main/res/layout/dialog_temptarget.xml b/app/src/main/res/layout/dialog_temptarget.xml index f770f8ba98..1c723e1fd8 100644 --- a/app/src/main/res/layout/dialog_temptarget.xml +++ b/app/src/main/res/layout/dialog_temptarget.xml @@ -48,29 +48,6 @@ android:orientation="horizontal" android:padding="5dp" /> - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 36b0fb5df8..7d9ae84bf1 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -25,6 +25,7 @@ #77dd77 #77dd77 + #67DFE8 #779ECB diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7f3ce45b83..b95cad27a2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -31,6 +31,7 @@ Max allowed bolus [U] Max allowed carbs [g] + %1$s Preferences Preferences Refresh treatments from NS Reset Databases diff --git a/build.gradle b/build.gradle index a7ce6acdb8..3eca243412 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,7 @@ buildscript { work_version = '2.4.0' junit_version = '4.13.1' + mockitoVersion = '2.8.47' powermockVersion = "1.7.3" dexmakerVersion = "1.2" retrofit2Version = '2.9.0' diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java index 6d895506f7..3ea1479666 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java @@ -43,7 +43,7 @@ public interface PumpInterface { void stopConnecting(); - void getPumpStatus(); + void getPumpStatus(String reason); // Upload to pump new basal profile @NotNull diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java index ff466b409f..b35d65e62c 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java @@ -73,7 +73,7 @@ public class Notification { public static final int OMNIPOD_POD_SUSPENDED = 61; public static final int OMNIPOD_POD_ALERTS_UPDATED = 62; public static final int OMNIPOD_POD_ALERTS = 63; - public static final int OMNIPOD_UNCERTAIN_TBR = 64; + public static final int OMNIPOD_TBR_ALERTS = 64; public static final int OMNIPOD_POD_FAULT = 66; public static final int OMNIPOD_UNCERTAIN_SMB = 67; public static final int OMNIPOD_UNKNOWN_TBR = 68; diff --git a/core/src/main/res/drawable/ic_blooddrop_48.xml b/core/src/main/res/drawable/ic_blooddrop_48.xml new file mode 100644 index 0000000000..c9d3a46552 --- /dev/null +++ b/core/src/main/res/drawable/ic_blooddrop_48.xml @@ -0,0 +1,4 @@ + + + diff --git a/core/src/main/res/drawable/ic_dexcom_g6.xml b/core/src/main/res/drawable/ic_dexcom_g6.xml new file mode 100644 index 0000000000..8df5acbb7c --- /dev/null +++ b/core/src/main/res/drawable/ic_dexcom_g6.xml @@ -0,0 +1,16 @@ + + + + diff --git a/core/src/main/res/drawable/ic_insulin.xml b/core/src/main/res/drawable/ic_insulin.xml new file mode 100644 index 0000000000..14f6c0634b --- /dev/null +++ b/core/src/main/res/drawable/ic_insulin.xml @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/core/src/main/res/drawable/ic_sensor.xml b/core/src/main/res/drawable/ic_sensor.xml new file mode 100644 index 0000000000..39caee867c --- /dev/null +++ b/core/src/main/res/drawable/ic_sensor.xml @@ -0,0 +1,5 @@ + + + + diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 1995c932be..8398b9a9eb 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -53,5 +53,29 @@ #FF8C00 #03A9F4 + + #1A000000 + #33000000 + #4D000000 + #66000000 + #80000000 + #99000000 + #A6000000 + #B3000000 + #CC000000 + #E6000000 + + #10FFFFFF + #1AFFFFFF + #33FFFFFF + #4DFFFFFF + #66FFFFFF + #80FFFFFF + #99FFFFFF + #A6FFFFFF + #B3FFFFFF + #CCFFFFFF + #E6FFFFFF + diff --git a/dana/src/main/res/drawable/ic_danars_128.xml b/dana/src/main/res/drawable/ic_danars_128.xml new file mode 100644 index 0000000000..c7f45fa181 --- /dev/null +++ b/dana/src/main/res/drawable/ic_danars_128.xml @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java b/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java index 3b9e98cbe8..22c206ede5 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java @@ -85,7 +85,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump super(new PluginDescription() .mainType(PluginType.PUMP) .fragmentClass(DanaFragment.class.getName()) - .pluginIcon(R.drawable.ic_dana_rs) + .pluginIcon(R.drawable.ic_danars_128) .pluginName(R.string.danarspump) .shortName(R.string.danarpump_shortname) .preferencesId(R.xml.pref_danar) @@ -361,7 +361,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump } @Override - public void getPumpStatus() { + public void getPumpStatus(String reason) { if (sExecutionService != null) { sExecutionService.getPumpStatus(); pumpDescription.basalStep = danaPump.getBasalStep(); diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt b/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt index 7d4cf7c21c..a5f2758c17 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt @@ -63,7 +63,7 @@ class DanaRSPlugin @Inject constructor( ) : PumpPluginBase(PluginDescription() .mainType(PluginType.PUMP) .fragmentClass(info.nightscout.androidaps.dana.DanaFragment::class.java.name) - .pluginIcon(R.drawable.ic_dana_rs) + .pluginIcon(R.drawable.ic_danars_128) .pluginName(R.string.danarspump) .shortName(R.string.danarspump_shortname) .preferencesId(R.xml.pref_danars) @@ -165,7 +165,7 @@ class DanaRSPlugin @Inject constructor( danaRSService?.stopConnecting() } - override fun getPumpStatus() { + override fun getPumpStatus(reason: String?) { danaRSService?.readPumpStatus() pumpDesc.basalStep = danaPump.basalStep pumpDesc.bolusStep = danaPump.bolusStep diff --git a/icons/target_activity.svg b/icons/target_activity.svg new file mode 100644 index 0000000000..2fb2409888 --- /dev/null +++ b/icons/target_activity.svg @@ -0,0 +1,43 @@ + + + + + + + + + diff --git a/icons/target_cancel.svg b/icons/target_cancel.svg new file mode 100644 index 0000000000..894110a14c --- /dev/null +++ b/icons/target_cancel.svg @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/icons/target_eatingsoon.svg b/icons/target_eatingsoon.svg new file mode 100644 index 0000000000..3ef25775bf --- /dev/null +++ b/icons/target_eatingsoon.svg @@ -0,0 +1,38 @@ + + + + + + + + + + diff --git a/icons/target_hypo.svg b/icons/target_hypo.svg new file mode 100644 index 0000000000..cc9585c5ba --- /dev/null +++ b/icons/target_hypo.svg @@ -0,0 +1,34 @@ + + + + + + + + + + diff --git a/icons/target_manual.svg b/icons/target_manual.svg new file mode 100644 index 0000000000..08b51538b3 --- /dev/null +++ b/icons/target_manual.svg @@ -0,0 +1,37 @@ + + + + + + + + diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index d491ebd1bc..4a9f29f4be 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -146,7 +146,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter super(new PluginDescription() // .mainType(PluginType.PUMP) // .fragmentClass(MedtronicFragment.class.getName()) // - .pluginIcon(R.drawable.ic_medtronic_veo) + .pluginIcon(R.drawable.ic_veo_128) .pluginName(R.string.medtronic_name) // .shortName(R.string.medtronic_name_short) // .preferencesId(R.xml.pref_medtronic) @@ -421,7 +421,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter @Override - public void getPumpStatus() { + public void getPumpStatus(String reason) { if (firstRun) { initializePump(!isRefresh); diff --git a/medtronic/src/main/res/drawable/ic_veo_128.xml b/medtronic/src/main/res/drawable/ic_veo_128.xml new file mode 100644 index 0000000000..ecea4fe5b9 --- /dev/null +++ b/medtronic/src/main/res/drawable/ic_veo_128.xml @@ -0,0 +1,356 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/omnipod/build.gradle b/omnipod/build.gradle index 5e2efbf15b..8fb1b2d51f 100644 --- a/omnipod/build.gradle +++ b/omnipod/build.gradle @@ -59,7 +59,7 @@ dependencies { kapt "com.google.dagger:dagger-compiler:$dagger_version" testImplementation "junit:junit:$junit_version" - testImplementation "org.mockito:mockito-core:2.8.47" + testImplementation "org.mockito:mockito-core:${mockitoVersion}" testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion" testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}" testImplementation 'joda-time:joda-time:2.10.6' diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index c19a314755..fb21956b2e 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -75,6 +75,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.driver.util.TimeUtil; import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodActiveAlertsChanged; @@ -89,6 +90,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandPlay import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandUpdateAlertConfiguration; import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.OmnipodCustomCommand; import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.OmnipodCustomCommandType; +import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.service.RileyLinkOmnipodService; import info.nightscout.androidaps.plugins.pump.omnipod.ui.OmnipodOverviewFragment; import info.nightscout.androidaps.plugins.pump.omnipod.util.AapsOmnipodUtil; @@ -117,6 +119,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, private static final long RILEY_LINK_CONNECT_TIMEOUT_MILLIS = 3 * 60 * 1000L; // 3 minutes private static final long STATUS_CHECK_INTERVAL_MILLIS = 60 * 1000L; // 1 minute public static final int STARTUP_STATUS_REQUEST_TRIES = 2; + public static final double RESERVOIR_OVER_50_UNITS_DEFAULT = 75.0; private final PodStateManager podStateManager; private final RileyLinkServiceData rileyLinkServiceData; @@ -135,8 +138,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, private final DateUtil dateUtil; private final PumpDescription pumpDescription; private final ServiceConnection serviceConnection; + private final OmnipodRileyLinkCommunicationManager omnipodRileyLinkCommunicationManager; private final PumpType pumpType = PumpType.Insulet_Omnipod; - private final CompositeDisposable disposables = new CompositeDisposable(); private final NSUpload nsUpload; @@ -173,12 +176,13 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, RileyLinkUtil rileyLinkUtil, OmnipodAlertUtil omnipodAlertUtil, ProfileFunction profileFunction, - NSUpload nsUpload + NSUpload nsUpload, + OmnipodRileyLinkCommunicationManager omnipodRileyLinkCommunicationManager ) { super(new PluginDescription() // .mainType(PluginType.PUMP) // .fragmentClass(OmnipodOverviewFragment.class.getName()) // - .pluginIcon(R.drawable.ic_pod) + .pluginIcon(R.drawable.ic_pod_128) .pluginName(R.string.omnipod_name) // .shortName(R.string.omnipod_name_short) // .preferencesId(R.xml.pref_omnipod) // @@ -200,6 +204,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, this.omnipodAlertUtil = omnipodAlertUtil; this.profileFunction = profileFunction; this.nsUpload = nsUpload; + this.omnipodRileyLinkCommunicationManager = omnipodRileyLinkCommunicationManager; pumpDescription = new PumpDescription(pumpType); @@ -309,7 +314,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.SMB_BEEPS_ENABLED) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED) || - event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.RILEYLINK_STATS_BUTTON_ENABLED) || + event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.RILEY_LINK_STATS_BUTTON_ENABLED) || + event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.USE_RILEY_LINK_BATTERY_LEVEL) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED) || @@ -390,7 +396,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, activePlugin.getActiveTreatments().removeTempBasal(tempBasal); } - rxBus.send(new EventDismissNotification(Notification.OMNIPOD_UNCERTAIN_TBR)); + rxBus.send(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS)); } private void handleActivePodAlerts() { @@ -537,18 +543,24 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, /** * We don't do periodical status requests because that could drain the Pod's battery - * The only actual status requests we send to the Pod here are on startup (in {@link #initializeAfterRileyLinkConnection() initializeAfterRileyLinkConnection()}) + * The only actual status requests we send to the Pod here are on startup (in {@link #initializeAfterRileyLinkConnection() initializeAfterRileyLinkConnection()}), + * When explicitly requested through SMS commands * And when the basal and/or temp basal status is uncertain * When the user explicitly requested it by clicking the Refresh button on the Omnipod tab (which is executed through {@link #executeCustomCommand(CustomCommand)}) */ @Override - public void getPumpStatus() { + public void getPumpStatus(String reason) { if (firstRun) { initializeAfterRileyLinkConnection(); firstRun = false; - } else if (!podStateManager.isBasalCertain() || !podStateManager.isTempBasalCertain()) { - aapsLogger.info(LTag.PUMP, "Acknowledged AAPS getPumpStatus request because basal and/or temp basal is uncertain"); - getPodStatus(); + } else { + if ("SMS".equals(reason)) { + aapsLogger.info(LTag.PUMP, "Acknowledged AAPS getPumpStatus request it was requested through an SMS"); + getPodStatus(); + } else if (podStateManager.isPodRunning() && (!podStateManager.isBasalCertain() || !podStateManager.isTempBasalCertain())) { + aapsLogger.info(LTag.PUMP, "Acknowledged AAPS getPumpStatus request because basal and/or temp basal is uncertain"); + getPodStatus(); + } } } @@ -596,15 +608,19 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, return 0.0d; } Double reservoirLevel = podStateManager.getReservoirLevel(); - return reservoirLevel == null ? 75.0 : reservoirLevel; + // Omnipod only reports reservoir level when it's 50 units or less. + // When it's over 50 units, we don't know, so return some default over 50 units + return reservoirLevel == null ? RESERVOIR_OVER_50_UNITS_DEFAULT : reservoirLevel; } @Override public int getBatteryLevel() { - if (!podStateManager.isPodRunning()) { - return 0; + if (aapsOmnipodManager.isUseRileyLinkBatteryLevel()) { + Integer batteryLevel = omnipodRileyLinkCommunicationManager.getBatteryLevel(); + return batteryLevel == null ? 0 : batteryLevel; } - return 75; + + return 0; } @NonNull @Override @@ -728,11 +744,22 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, status.put("timestamp", DateUtil.toISOString(new Date())); - pump.put("battery", battery); + if (isUseRileyLinkBatteryLevel()) { + pump.put("battery", battery); + } + pump.put("status", status); pump.put("extended", extended); - pump.put("reservoir", getReservoirLevel()); - pump.put("clock", DateUtil.toISOString(new Date())); + + double reservoirLevel = getReservoirLevel(); + if (reservoirLevel > OmnipodConstants.MAX_RESERVOIR_READING) { + pump.put("reservoir_display_override", "50+"); + pump.put("reservoir", OmnipodConstants.MAX_RESERVOIR_READING); + } else { + pump.put("reservoir", reservoirLevel); + } + + pump.put("clock", DateUtil.toISOString(podStateManager.getTime().toDate())); } catch (JSONException e) { aapsLogger.error(LTag.PUMP, "Unhandled exception", e); } @@ -758,34 +785,35 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, return pumpDescription; } - // FIXME i18n, null checks: iob, TDD @NonNull @Override public String shortStatus(boolean veryShort) { if (!podStateManager.isPodActivationCompleted()) { - return "No active pod"; + return resourceHelper.gs(R.string.omnipod_short_status_no_active_pod); } String ret = ""; if (lastConnectionTimeMillis != 0) { long agoMsec = System.currentTimeMillis() - lastConnectionTimeMillis; int agoMin = (int) (agoMsec / 60d / 1000d); - ret += "LastConn: " + agoMin + " min ago\n"; + ret += resourceHelper.gs(R.string.omnipod_short_status_last_connection, agoMin) + "\n"; } if (podStateManager.getLastBolusStartTime() != null) { - ret += "LastBolus: " + DecimalFormatter.to2Decimal(podStateManager.getLastBolusAmount()) + "U @" + // - android.text.format.DateFormat.format("HH:mm", podStateManager.getLastBolusStartTime().toDate()) + "\n"; + ret += resourceHelper.gs(R.string.omnipod_short_status_last_bolus, DecimalFormatter.to2Decimal(podStateManager.getLastBolusAmount()), + android.text.format.DateFormat.format("HH:mm", podStateManager.getLastBolusStartTime().toDate())) + "\n"; } TemporaryBasal activeTemp = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(System.currentTimeMillis()); if (activeTemp != null) { - ret += "Temp: " + activeTemp.toStringFull() + "\n"; + ret += resourceHelper.gs(R.string.omnipod_short_status_temp_basal, activeTemp.toStringFull()) + "\n"; } ExtendedBolus activeExtendedBolus = activePlugin.getActiveTreatments().getExtendedBolusFromHistory( System.currentTimeMillis()); if (activeExtendedBolus != null) { - ret += "Extended: " + activeExtendedBolus.toString() + "\n"; + ret += resourceHelper.gs(R.string.omnipod_short_status_extended_bolus, activeExtendedBolus.toString()) + "\n"; } - ret += "Reserv: " + DecimalFormatter.to0Decimal(getReservoirLevel()) + "U\n"; - ret += "Batt: " + getBatteryLevel(); - return ret; + ret += resourceHelper.gs(R.string.omnipod_short_status_reservoir, (getReservoirLevel() > OmnipodConstants.MAX_RESERVOIR_READING ? "50+" : DecimalFormatter.to0Decimal(getReservoirLevel()))) + "\n"; + if (isUseRileyLinkBatteryLevel()) { + ret += resourceHelper.gs(R.string.omnipod_short_status_rl_battery, getBatteryLevel()) + "\n"; + } + return ret.trim(); } @Override @@ -1020,6 +1048,10 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver); } + public boolean isUseRileyLinkBatteryLevel() { + return aapsOmnipodManager.isUseRileyLinkBatteryLevel(); + } + private void initializeAfterRileyLinkConnection() { if (podStateManager.getActivationProgress().isAtLeast(ActivationProgress.PAIRING_COMPLETED)) { boolean success = false; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java index 07601bb9bd..8327f300bc 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java @@ -21,7 +21,8 @@ public class OmnipodStorageKeys { public static final int NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_smb_sound_enabled; public static final int NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_bolus_sound_enabled; public static final int AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED = R.string.key_omnipod_automatically_acknowledge_alerts_enabled; - public static final int RILEYLINK_STATS_BUTTON_ENABLED = R.string.key_omnipod_rileylink_stats_button_enabled; + public static final int RILEY_LINK_STATS_BUTTON_ENABLED = R.string.key_omnipod_riley_link_stats_button_enabled; + public static final int USE_RILEY_LINK_BATTERY_LEVEL = R.string.key_omnipod_use_riley_link_battery_level; } public static class Statistics { 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 27f3565ded..a18408d47b 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 @@ -120,8 +120,8 @@ public class AapsOmnipodManager { private boolean notificationUncertainSmbSoundEnabled; private boolean notificationUncertainBolusSoundEnabled; private boolean automaticallyAcknowledgeAlertsEnabled; - private boolean testBeepButtonEnabled; private boolean rileylinkStatsButtonEnabled; + private boolean useRileyLinkBatteryLevel; @Inject public AapsOmnipodManager(OmnipodRileyLinkCommunicationManager communicationService, @@ -165,7 +165,8 @@ public class AapsOmnipodManager { tbrBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TBR_BEEPS_ENABLED, false); suspendDeliveryButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED, false); pulseLogButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED, false); - rileylinkStatsButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.RILEYLINK_STATS_BUTTON_ENABLED, false); + rileylinkStatsButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.RILEY_LINK_STATS_BUTTON_ENABLED, false); + useRileyLinkBatteryLevel = sp.getBoolean(OmnipodStorageKeys.Preferences.USE_RILEY_LINK_BATTERY_LEVEL, false); timeChangeEventEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED, true); notificationUncertainTbrSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED, false); notificationUncertainSmbSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED, true); @@ -218,7 +219,6 @@ public class AapsOmnipodManager { addToHistory(System.currentTimeMillis(), PodHistoryEntryType.INSERT_CANNULA, result.comment, result.success); if (result.success) { - uploadCareportalEvent(System.currentTimeMillis() - 2000, CareportalEvent.PUMPBATTERYCHANGE); uploadCareportalEvent(System.currentTimeMillis() - 1000, CareportalEvent.INSULINCHANGE); uploadCareportalEvent(System.currentTimeMillis(), CareportalEvent.SITECHANGE); @@ -493,7 +493,7 @@ public class AapsOmnipodManager { String errorMessage = translateException(ex.getCause()); addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); - showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); + showNotification(Notification.OMNIPOD_TBR_ALERTS, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); splitActiveTbr(); // Split any active TBR so when we recover from the uncertain TBR status,we only cancel the part after the cancellation @@ -503,7 +503,7 @@ public class AapsOmnipodManager { long pumpId = addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); if (!OmnipodManager.isCertainFailure(ex)) { - showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); + showNotification(Notification.OMNIPOD_TBR_ALERTS, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); // Assume that setting the temp basal succeeded here, because in case it didn't succeed, // The next StatusResponse that we receive will allow us to recover from the wrong state @@ -522,6 +522,8 @@ public class AapsOmnipodManager { addTempBasalTreatment(System.currentTimeMillis(), pumpId, tempBasalPair); + sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS)); + return new PumpEnactResult(injector) .duration(tempBasalPair.getDurationMinutes()) .absolute(PumpType.Insulet_Omnipod.determineCorrectBasalSize(tempBasalPair.getInsulinRate())) @@ -533,7 +535,7 @@ public class AapsOmnipodManager { executeCommand(() -> delegate.cancelTemporaryBasal(isTbrBeepsEnabled())); } catch (Exception ex) { if (OmnipodManager.isCertainFailure(ex)) { - showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); + showNotification(Notification.OMNIPOD_TBR_ALERTS, getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); } else { splitActiveTbr(); // Split any active TBR so when we recover from the uncertain TBR status,we only cancel the part after the cancellation } @@ -552,6 +554,8 @@ public class AapsOmnipodManager { activePlugin.getActiveTreatments().addToHistoryTempBasal(tempBasal); + sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS)); + return new PumpEnactResult(injector).success(true).enacted(true); } @@ -656,14 +660,14 @@ public class AapsOmnipodManager { return pulseLogButtonEnabled; } - public boolean isTestBeepButtonEnabled() { - return testBeepButtonEnabled; - } - public boolean isRileylinkStatsButtonEnabled() { return rileylinkStatsButtonEnabled; } + public boolean isUseRileyLinkBatteryLevel() { + return useRileyLinkBatteryLevel; + } + public boolean isTimeChangeEventEnabled() { return timeChangeEventEnabled; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/manager/OmnipodRileyLinkCommunicationManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/manager/OmnipodRileyLinkCommunicationManager.java index 44f2069c59..0171b60a9a 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/manager/OmnipodRileyLinkCommunicationManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/manager/OmnipodRileyLinkCommunicationManager.java @@ -8,6 +8,7 @@ import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; +import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager; @@ -15,6 +16,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLink import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkBLEError; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; +import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.OmnipodAction; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.MessageBlock; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.OmnipodMessage; @@ -50,6 +52,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateMa */ @Singleton public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunicationManager { + private Integer batteryLevel; + // This empty constructor must be kept, otherwise dagger injection might break! @Inject public OmnipodRileyLinkCommunicationManager() { @@ -81,6 +85,21 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication // We don't use PumpDeviceState in the Omnipod driver } + @Override protected OmnipodPacket sendAndListen(OmnipodPacket msg, int timeout_ms, int repeatCount, int retryCount, Integer extendPreamble_ms) throws RileyLinkCommunicationException { + OmnipodPacket response = super.sendAndListen(msg, timeout_ms, repeatCount, retryCount, extendPreamble_ms); + + PumpInterface activePump = activePluginProvider.getActivePump(); + if (activePump instanceof OmnipodPumpPlugin && ((OmnipodPumpPlugin) activePump).isUseRileyLinkBatteryLevel()) { + updateBatteryLevel(); + } + + return response; + } + + public Integer getBatteryLevel() { + return batteryLevel; + } + public T sendCommand(Class responseClass, PodStateManager podStateManager, MessageBlock command) { return sendCommand(responseClass, podStateManager, command, true); } @@ -384,4 +403,7 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication throw new RileyLinkUnreachableException(); } + private void updateBatteryLevel() { + batteryLevel = rfspy.getBatteryLevel(); + } } diff --git a/omnipod/src/main/res/drawable/ic_pod_128.xml b/omnipod/src/main/res/drawable/ic_pod_128.xml new file mode 100644 index 0000000000..e98ba3dc76 --- /dev/null +++ b/omnipod/src/main/res/drawable/ic_pod_128.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + diff --git a/omnipod/src/main/res/layout/omnipod_overview.xml b/omnipod/src/main/res/layout/omnipod_overview.xml index 25aa66c0f6..3b746579ff 100644 --- a/omnipod/src/main/res/layout/omnipod_overview.xml +++ b/omnipod/src/main/res/layout/omnipod_overview.xml @@ -747,21 +747,23 @@ - + + android:paddingTop="10dp" + android:rotationX="180" + android:rotationY="180" /> diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index 1dde9ce781..9a3fad5066 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -10,7 +10,8 @@ AAPS.Omnipod.tbr_beeps_enabled AAPS.Omnipod.suspend_delivery_button_enabled AAPS.Omnipod.pulse_log_button_enabled - AAPS.Omnipod.rileylink_stats_button_enabled + AAPS.Omnipod.rileylink_stats_button_enabled + AAPS.Omnipod.use_riley_link_battery_level AAPS.Omnipod.time_change_enabled AAPS.Omnipod.expiration_reminder_enabled AAPS.Omnipod.expiration_reminder_hours_before_shutdown @@ -43,6 +44,8 @@ Show Suspend Delivery button in Omnipod tab Show Pulse Log button in Pod Management menu Show RileyLink Stats button in Pod Management menu + Use battery level reported by OrangeLink/EmaLink + DOES NOT work with the original RileyLink. May not work with other RileyLink alternatives. DST/Time zone detection enabled Expiration reminder enabled Hours before shutdown @@ -55,19 +58,19 @@ RileyLink Other Alerts - Confirmation beeps + Confirmation Beeps Notifications - No active Pod + No Active Pod Setup in progress (waiting for Pod activation) Setup in progress (waiting for cannula insertion) Running Suspended - Pod fault + Pod Fault Activation time exceeded Inactive - Pod fault: %1$03d %2$s + Pod Fault: %1$03d %2$s Finish pairing reminder @@ -75,11 +78,11 @@ Pod will expire soon Pod will expire soon Shutdown is imminent - Low reservoir - Unknown alert + Low Reservoir + Unknown Alert - Pod history + Pod History Description Source Date @@ -88,6 +91,15 @@ %1$.2f U, CH=%2$.1f g Rate: %1$.2f U, duration: %2$d minutes + + No Active Pod + LastConn: %1$d min ago + LastBolus: %1$s @ %2$s + Temp: %1$s + Extended: %1$s + Reserv: %1$sU + RLBatt: %1$d + Warning RileyLink address invalid. @@ -115,7 +127,7 @@ Setting basal profile failed. Cancelling temp basal might have failed. Please manually refresh the Pod status from the Omnipod tab. Setting temp basal failed. If a temp basal was previously running, it might have been cancelled. Please manually refresh the Pod status from the Omnipod tab. - Setting temp might have basal failed. If a temp basal was previously running, it has been cancelled. Please manually refresh the Pod status from the Omnipod tab. + Setting temp basal might have basal failed. If a temp basal was previously running, it has been cancelled. Please manually refresh the Pod status from the Omnipod tab. TBR duration must be greater than zero and a multiple of %1$s minutes. Setting time might have failed. Delivery might be suspended! Please manually refresh the Pod status from the Omnipod tab and resume delivery if needed. Setting time failed. Delivery is suspended! Please manually resume delivery from the Omnipod tab. @@ -129,7 +141,7 @@ Failed to suspend delivery Failed to set time Failed to resume delivery - Failed to automatically change time on the Pod. You should manually synchronise the time on the Omnipod tab. + Failed to automatically change time on the Pod. You should manually synchronize the time on the Omnipod tab. Unable to verify whether the bolus succeeded. Please manually verify that your Pod is bolusing by listening to clicks. If you are sure that the bolus didn\'t succeed, you should manually delete the bolus entry from Treatments, even if you click \'Cancel bolus\' now! Unable to verify whether SMB bolus (%1$.2f U) succeeded. If you are sure that the Bolus didn\'t succeed, you should manually delete the SMB entry from Treatments. Bolus did not succeed. @@ -153,45 +165,45 @@ Deactivate Pod Discard Pod - Set bolus - Cancel bolus - Set temporary basal - Cancel temporary basal (internally by driver) - Cancel temporary basal - Set basal schedule - Get Pod status - Get Pod info - Set time - Configure alerts - Acknowledge alerts - Suspend delivery - Resume delivery - Unknown entry + Set Bolus + Cancel Bolus + Set Temporary Basal + Cancel Temporary Basal (internally by driver) + Cancel Temporary Basal + Set Basal Schedule + Get Pod Status + Get Pod Info + Set Time + Configure Alerts + Acknowledge Alerts + Suspend Delivery + Resume Delivery + Unknown Entry Initialize Pod - Insert cannula - Read pulse log + Insert Cannula + Read Pulse Log Set fake temporary basal because the Pod is suspended Cancel fake temporary basal that was created because the Pod was suspended Split temporary basal because of uncertain failure in cancellation - Beep config - Play test beep + Beep Config + Play Test Beep - Pod management + Pod Management Actions Tools Waiting for RileyLink connection… Activate Pod Deactivate Pod Discard Pod - Pod history - RileyLink stats + Pod History + RileyLink Stats Reset RileyLink Config - Read pulse log - Reading pulse log… + Read Pulse Log + Reading Pulse Log… If you discard the Pod, you will not be able to communicate with it anymore. You should only do this when all communication with the Pod persistently fails. If you can still communicate with the Pod, please use the Deactivate Pod option.\n\nIf you wish to proceed, please make sure to remove the Pod from your body! - Play test beep - Playing test beep… + Play Test Beep + Playing Test Beep… Cancel @@ -211,9 +223,9 @@ Attach Pod Prepare the infusion site. Remove the Pod\'s needle cap and adhesive backing and attach the Pod to the infusion site.\n\nIf the cannula sticks out, please press Cancel and discard your Pod.\n\nPress Next to insert the cannula and begin basal delivery. When you press OK, the cannula will be inserted. Make sure that you have attached the Pod to the infusion site. - Insert cannula + Insert Cannula Trying to set initial basal schedule and insert the cannula.\n\nWhen the cannula has successfully been inserted, you can press Next. - Pod activated + Pod Activated The new Pod is now active.\n\nYour basal schedule has been programmed and the cannula has been inserted.\n\nPlease verify that the cannula has been inserted correctly and change your Pod if you think it has not. @@ -221,9 +233,9 @@ Press Next to deactivate the Pod.\n\nNote: This will suspend all insulin delivery and deactivate the Pod. Deactivating Pod Deactivating the Pod.\n\nWhen deactivation has completed successfully, you can press Next. - Pod deactivated + Pod Deactivated Your Pod has been deactivated.\n\nPlease remove the Pod from your body and recycle it. - Pod discarded + Pod Discarded The Pod state has been discarded. Insulin delivery has not been suspended because the Pod has not been properly deactivated!\n\nPlease remove the Pod from your body and recycle it. If you discard the Pod, you will not be able to communicate with it anymore. You should only do this when all communication with the Pod persistently fails. Are you sure you want to discard the Pod? Discard Pod @@ -232,21 +244,21 @@ Set time Suspend Refresh - Resume delivery - Pod mgmt - Ack alerts - Pod status - Total delivered + Resume Delivery + Pod Mgmt + Ack Alerts + Pod Status + Total Delivered %1$.2f U - Pod address - Pod expires - Last connection - Last bolus - Temp basal rate - Base basal rate + Pod Address + Pod Expires + Last Connection + Last Bolus + Temp Basal Rate + Base Basal Rate Reservoir - Active Pod alerts - Firmware version + Active Pod Alerts + Firmware Version Time on Pod %1$.2fU/h @%2$s (%3$d/%4$d minutes) %1$.2f U left @@ -281,8 +293,8 @@ %1$d days - Pod alert: %1$s - Pod alerts: %1$s + Pod Alert: %1$s + Pod Alerts: %1$s \ No newline at end of file diff --git a/omnipod/src/main/res/xml/pref_omnipod.xml b/omnipod/src/main/res/xml/pref_omnipod.xml index d0135d82a1..79a772e94a 100644 --- a/omnipod/src/main/res/xml/pref_omnipod.xml +++ b/omnipod/src/main/res/xml/pref_omnipod.xml @@ -112,9 +112,15 @@ + + ()); diff --git a/rileylink/build.gradle b/rileylink/build.gradle index cdeb8d9bc3..308f4bdeb5 100644 --- a/rileylink/build.gradle +++ b/rileylink/build.gradle @@ -50,6 +50,9 @@ dependencies { kapt "com.google.dagger:dagger-compiler:$dagger_version" testImplementation "junit:junit:$junit_version" + testImplementation "org.mockito:mockito-core:${mockitoVersion}" + testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}" + testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}" androidTestImplementation "androidx.test.ext:junit:$androidx_junit" androidTestImplementation "androidx.test:rules:$androidx_rules" } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java index 5bec93fb4c..6e502e6c36 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java @@ -57,6 +57,8 @@ public class RFSpy { private final UUID radioServiceUUID = UUID.fromString(GattAttributes.SERVICE_RADIO); private final UUID radioDataUUID = UUID.fromString(GattAttributes.CHARA_RADIO_DATA); private final UUID radioVersionUUID = UUID.fromString(GattAttributes.CHARA_RADIO_VERSION); + private final UUID batteryServiceUUID = UUID.fromString(GattAttributes.SERVICE_BATTERY); + private final UUID batteryLevelUUID = UUID.fromString(GattAttributes.CHARA_BATTERY_UNK); //private UUID responseCountUUID = UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT); private RileyLinkFirmwareVersion firmwareVersion; private String bleVersion; // We don't use it so no need of sofisticated logic @@ -98,7 +100,9 @@ public class RFSpy { // firmware version public void initializeRileyLink() { bleVersion = getVersion(); - rileyLinkServiceData.firmwareVersion = getFirmwareVersion(); + String cc1110Version = getCC1110Version(); + rileyLinkServiceData.versionCC110 = cc1110Version; + rileyLinkServiceData.firmwareVersion = getFirmwareVersion(aapsLogger, bleVersion, cc1110Version); } @@ -109,6 +113,19 @@ public class RFSpy { } + public Integer getBatteryLevel() { + BLECommOperationResult result = rileyLinkBle.readCharacteristic_blocking(batteryServiceUUID, batteryLevelUUID); + if (result.resultCode == BLECommOperationResult.RESULT_SUCCESS) { + int value = result.value[0]; + aapsLogger.debug(LTag.PUMPBTCOMM, "BLE battery level: {}", value); + return value; + } else { + aapsLogger.error(LTag.PUMPBTCOMM, "getBatteryLevel failed with code: " + result.resultCode); + return null; + } + } + + // This gets the version from the BLE113, not from the CC1110. // I.e., this gets the version from the BLE interface, not from the radio. public String getVersion() { @@ -123,15 +140,7 @@ public class RFSpy { } } - public boolean isRileyLinkStillAvailable() { - RileyLinkFirmwareVersion firmwareVersion = getFirmwareVersion(); - - return (firmwareVersion != RileyLinkFirmwareVersion.UnknownVersion); - } - - - private RileyLinkFirmwareVersion getFirmwareVersion() { - + private String getCC1110Version() { aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version. Get Version - Start"); for (int i = 0; i < 5; i++) { @@ -146,19 +155,29 @@ public class RFSpy { if (response != null) { // && response[0] == (byte) 0xDD) { String versionString = StringUtil.fromBytes(response); - - RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(StringUtil - .fromBytes(response)); - - aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: {}, resolved to {}.", versionString, version); - - if (version != RileyLinkFirmwareVersion.UnknownVersion) - return version; - + if (versionString.length() > 3) { + if (versionString.indexOf('s') >= 0) { + versionString = versionString.substring(versionString.indexOf('s')); + } + return versionString; + } SystemClock.sleep(1000); } } + return null; + } + + static RileyLinkFirmwareVersion getFirmwareVersion(AAPSLogger aapsLogger, String bleVersion, String cc1110Version) { + if (cc1110Version != null) { + RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(cc1110Version); + aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: {}, resolved to {}.", cc1110Version, version); + + if (version != RileyLinkFirmwareVersion.UnknownVersion) { + return version; + } + } + aapsLogger.error(LTag.PUMPBTCOMM, "Firmware Version can't be determined. Checking with BLE Version [{}].", bleVersion); if (bleVersion.contains(" 2.")) { @@ -168,7 +187,6 @@ public class RFSpy { return RileyLinkFirmwareVersion.UnknownVersion; } - private byte[] writeToDataRaw(byte[] bytes, int responseTimeout_ms) { SystemClock.sleep(100); // FIXME drain read queue? @@ -373,7 +391,7 @@ public class RFSpy { private void setMedtronicEncoding() { RileyLinkEncodingType encoding = RileyLinkEncodingType.FourByteSixByteLocal; - if (RileyLinkFirmwareVersion.isSameVersion(rileyLinkServiceData.firmwareVersion, RileyLinkFirmwareVersion.Version2AndHigher)) { + if (rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) { if (sp.getString(RileyLinkConst.Prefs.Encoding, "None") .equals(resourceHelper.gs(R.string.key_medtronic_pump_encoding_4b6b_rileylink))) { encoding = RileyLinkEncodingType.FourByteSixByteRileyLink; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java index dccf3a5c15..92dd858185 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java @@ -74,8 +74,7 @@ public class RadioResponse { } byte[] encodedPayload; - if (RileyLinkFirmwareVersion.isSameVersion(rileyLinkServiceData.versionCC110, - RileyLinkFirmwareVersion.Version2AndHigher)) { + if (rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) { encodedPayload = ByteUtil.substring(rxData, 3, rxData.length - 3); rssi = rxData[1]; responseNumber = rxData[2]; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersion.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersion.java index 1a6b42c443..3239580512 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersion.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersion.java @@ -1,6 +1,9 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -10,19 +13,22 @@ public enum RileyLinkFirmwareVersion { Version_0_0(0, 0, "0.0"), // just for defaulting Version_0_9(0, 9, "0.9"), // Version_1_0(1, 0, "1.0"), // + Version_1_x(1, null, "1.x"), // Version_2_0(2, 0, "2.0"), // Version_2_2(2, 2, "2.2"), // - Version_3_x(3, 0, "3.x"), // - Version_4_x(4, 0, "4.x"), // - UnknownVersion(0, 0, "???"), // - Version1(Version_0_0, Version_0_9, Version_1_0), // - Version2(Version_2_0, Version_2_2), // - Version2AndHigher(Version_2_0, Version_2_2, Version_3_x, Version_4_x), // - ; + Version_2_x(2, null, "2.x"), // + Version_3_x(3, null, "3.x"), // + Version_4_x(4, null, "4.x"), // + UnknownVersion(null, null, "???"), // + Version1(Version_0_0, Version_0_9, Version_1_0, Version_1_x), // + Version2(Version_2_0, Version_2_2, Version_2_x), // + Version3(Version_3_x), // + Version4(Version_4_x), // + Version2AndHigher(Version2, Version3, Version4); private static final String FIRMWARE_IDENTIFICATION_PREFIX = "subg_rfspy "; private static final Pattern _version_pattern = Pattern.compile(FIRMWARE_IDENTIFICATION_PREFIX - + "([0-9]+)\\.([0-9]+)"); + + "([0-9]+)\\.([0-9]+)"); static Map mapByVersion; static { @@ -34,13 +40,12 @@ public enum RileyLinkFirmwareVersion { } } - protected RileyLinkFirmwareVersion[] familyMembers; - private int major; - private int minor; + private List familyMembers; + private Integer major; + private Integer minor; private String versionKey = ""; - - RileyLinkFirmwareVersion(int major, int minor, String versionKey) { + RileyLinkFirmwareVersion(Integer major, Integer minor, String versionKey) { this.major = major; this.minor = minor; this.versionKey = versionKey; @@ -48,23 +53,39 @@ public enum RileyLinkFirmwareVersion { RileyLinkFirmwareVersion(RileyLinkFirmwareVersion... familyMembers) { - this.familyMembers = familyMembers; + this.familyMembers = Arrays.asList(familyMembers); } + public boolean hasFamilyMembers() { + return familyMembers != null; + } - public static boolean isSameVersion(RileyLinkFirmwareVersion versionWeCheck, RileyLinkFirmwareVersion versionSources) { - if (versionSources.familyMembers != null) { - for (RileyLinkFirmwareVersion vrs : versionSources.familyMembers) { - if (vrs == versionWeCheck) - return true; + private List getFamilyMembersRecursive() { + List members = new ArrayList<>(); + if (hasFamilyMembers()) { + for (RileyLinkFirmwareVersion version : familyMembers) { + members.add(version); + if (version.hasFamilyMembers()) { + members.addAll(version.getFamilyMembersRecursive()); + } } - } else { - return (versionWeCheck == versionSources); } + + return members; + } + + static boolean isSameVersion(RileyLinkFirmwareVersion versionWeCheck, RileyLinkFirmwareVersion versionSources) { + if (versionWeCheck == versionSources) { + return true; + } + + if (versionSources.familyMembers != null) { + return versionSources.getFamilyMembersRecursive().contains(versionWeCheck); + } + return false; } - public static RileyLinkFirmwareVersion getByVersionString(String versionString) { if (versionString != null) { Matcher m = _version_pattern.matcher(versionString); @@ -76,7 +97,7 @@ public enum RileyLinkFirmwareVersion { return mapByVersion.get(versionKey); } else { return defaultToLowestMajorVersion(major); // just in case there is new release that we don't cover - // example: 2.3 etc + // example: 2.3 etc } } } @@ -86,8 +107,8 @@ public enum RileyLinkFirmwareVersion { private static RileyLinkFirmwareVersion defaultToLowestMajorVersion(int major) { - if (mapByVersion.containsKey(major + ".0")) { - return mapByVersion.get(major + ".0"); + if (mapByVersion.containsKey(major + ".x")) { + return mapByVersion.get(major + ".x"); } return UnknownVersion; } @@ -100,6 +121,9 @@ public enum RileyLinkFirmwareVersion { @Override public String toString() { + if (hasFamilyMembers()) { + return FIRMWARE_IDENTIFICATION_PREFIX + name(); + } return FIRMWARE_IDENTIFICATION_PREFIX + versionKey; } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java index 6f4462a470..576e04e436 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java @@ -17,7 +17,6 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.plugins.pump.common.R; import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpInfo; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; @@ -52,7 +51,6 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re boolean first = false; - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.rileylink_status_general, container, false); @@ -79,7 +77,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re if (!first) { - // 7-12 + // 7-14 int[] ids = {R.id.rls_t1_tv02, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, // R.id.rls_t1_tv08, R.id.rls_t1_tv09, R.id.rls_t1_tv10, R.id.rls_t1_tv11, R.id.rls_t1_tv12, R.id.rls_t1_tv13}; @@ -108,15 +106,12 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re "-" : resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice))); - RileyLinkFirmwareVersion firmwareVersion = rileyLinkServiceData.versionCC110; - if (firmwareVersion == null) { this.firmwareVersion.setText("BLE113: -\nCC110: -"); } else { - this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 + // - "\nCC110: " + firmwareVersion.toString()); + this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 + + "\nCC110: " + rileyLinkServiceData.versionCC110); } - } RileyLinkPumpDevice pumpPlugin = (RileyLinkPumpDevice) activePlugin.getActivePump(); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java index 337f8b5527..b240f8bc0b 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java @@ -159,7 +159,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver { // if (isLoggingEnabled()) aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy Radio version (CC110): " + rlVersion.name()); - this.rileyLinkServiceData.versionCC110 = rlVersion; + this.rileyLinkServiceData.firmwareVersion = rlVersion; ServiceTask task = new InitializePumpManagerTask(injector, context); serviceTaskExecutor.startTask(task); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java index 02b27846bc..6307c7ad87 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java @@ -32,7 +32,7 @@ public class RileyLinkServiceData { public RileyLinkError rileyLinkError; public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted; private long lastServiceStateChange = 0L; - public RileyLinkFirmwareVersion firmwareVersion; + public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version public RileyLinkTargetFrequency rileyLinkTargetFrequency; public String rileylinkAddress; long lastTuneUpTime = 0L; @@ -41,7 +41,7 @@ public class RileyLinkServiceData { // bt version public String versionBLE113; // radio version - public RileyLinkFirmwareVersion versionCC110; + public String versionCC110; public RileyLinkTargetDevice targetDevice; @@ -77,7 +77,6 @@ public class RileyLinkServiceData { private synchronized RileyLinkServiceState workWithServiceState(RileyLinkServiceState newState, RileyLinkError errorCode, boolean set) { if (set) { - rileyLinkServiceState = newState; lastServiceStateChange = System.currentTimeMillis(); this.rileyLinkError = errorCode; @@ -87,7 +86,6 @@ public class RileyLinkServiceData { rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(rileyLinkServiceState, errorCode, targetDevice)); rxBus.send(new EventRileyLinkDeviceStatusChange(targetDevice, newState, errorCode)); return null; - } else { return rileyLinkServiceState; } diff --git a/rileylink/src/main/res/layout/rileylink_status.xml b/rileylink/src/main/res/layout/rileylink_status.xml index 41425a96a6..c32fbd7ecb 100644 --- a/rileylink/src/main/res/layout/rileylink_status.xml +++ b/rileylink/src/main/res/layout/rileylink_status.xml @@ -26,7 +26,7 @@ diff --git a/rileylink/src/main/res/layout/rileylink_status_general.xml b/rileylink/src/main/res/layout/rileylink_status_general.xml index 42f5cd5abb..dfa5f94d82 100644 --- a/rileylink/src/main/res/layout/rileylink_status_general.xml +++ b/rileylink/src/main/res/layout/rileylink_status_general.xml @@ -30,7 +30,9 @@ @@ -49,14 +51,16 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> @@ -75,15 +79,17 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> @@ -102,15 +108,17 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> @@ -129,15 +137,16 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> - @@ -156,9 +165,9 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> @@ -178,7 +187,9 @@ @@ -197,15 +208,17 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> @@ -224,15 +237,17 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> @@ -251,15 +266,17 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> @@ -278,14 +295,16 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> @@ -304,15 +323,17 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> @@ -331,9 +352,9 @@ android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_weight="65" - android:textAlignment="center" android:gravity="center_vertical" - android:text=" " /> + android:text=" " + android:textAlignment="center" /> diff --git a/rileylink/src/main/res/values/strings.xml b/rileylink/src/main/res/values/strings.xml index 8f4d134211..7483d77152 100644 --- a/rileylink/src/main/res/values/strings.xml +++ b/rileylink/src/main/res/values/strings.xml @@ -29,7 +29,7 @@ Device Model Last used frequency Last device contact - RL Firmware + Firmware diff --git a/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpyTest.java b/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpyTest.java new file mode 100644 index 0000000000..8afff65fa4 --- /dev/null +++ b/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpyTest.java @@ -0,0 +1,47 @@ +package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.modules.junit4.PowerMockRunner; + +import info.nightscout.androidaps.logging.AAPSLogger; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion; + +import static org.junit.Assert.assertEquals; + +@RunWith(PowerMockRunner.class) +public class RFSpyTest { + @Mock + private AAPSLogger aapsLogger; + + @Test + public void testGetFirmwareVersion() { + assertEquals(RileyLinkFirmwareVersion.Version_1_0, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.0")); + assertEquals(RileyLinkFirmwareVersion.Version_1_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1")); + assertEquals(RileyLinkFirmwareVersion.Version_1_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1.13")); + + assertEquals(RileyLinkFirmwareVersion.Version_2_0, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0")); + assertEquals(RileyLinkFirmwareVersion.Version_2_0, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0.1")); + assertEquals(RileyLinkFirmwareVersion.Version_2_2, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2")); + assertEquals(RileyLinkFirmwareVersion.Version_2_2, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.16")); + assertEquals(RileyLinkFirmwareVersion.Version_2_2, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.17")); + assertEquals(RileyLinkFirmwareVersion.Version_2_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3")); + assertEquals(RileyLinkFirmwareVersion.Version_2_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.0")); + assertEquals(RileyLinkFirmwareVersion.Version_2_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.17")); + + assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0")); + assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0.1")); + assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1")); + assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1.13")); + + assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0")); + assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0.4")); + assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.3")); + assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.5.7")); + + assertEquals(RileyLinkFirmwareVersion.UnknownVersion, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0")); + assertEquals(RileyLinkFirmwareVersion.UnknownVersion, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0.0")); + assertEquals(RileyLinkFirmwareVersion.UnknownVersion, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.5.5")); + } +} \ No newline at end of file diff --git a/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersionTest.java b/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersionTest.java new file mode 100644 index 0000000000..90351e7d89 --- /dev/null +++ b/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersionTest.java @@ -0,0 +1,60 @@ +package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs; + +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class RileyLinkFirmwareVersionTest { + + @Test + public void testIsSameVersion() { + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version1, RileyLinkFirmwareVersion.Version1)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_0, RileyLinkFirmwareVersion.Version1)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_0, RileyLinkFirmwareVersion.Version1)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_9, RileyLinkFirmwareVersion.Version1)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_x, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version1, RileyLinkFirmwareVersion.Version_1_0)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_0, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_0, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_9, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_x, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version1, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_0, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_2, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_x, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version1)); + + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version2)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version2AndHigher)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_0, RileyLinkFirmwareVersion.Version2)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_0, RileyLinkFirmwareVersion.Version2AndHigher)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_2, RileyLinkFirmwareVersion.Version2)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_2, RileyLinkFirmwareVersion.Version2AndHigher)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_x, RileyLinkFirmwareVersion.Version2)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_x, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version_2_x)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version2)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version2)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version2)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version2)); + + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version3)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version2AndHigher)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version3)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version_3_x)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version3)); + + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version4)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version2AndHigher)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version4)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version_4_x)); + } +} \ No newline at end of file diff --git a/wear/build.gradle b/wear/build.gradle index a1cab4f14c..db4b0c5129 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -127,7 +127,7 @@ dependencies { testImplementation "junit:junit:$junit_version" testImplementation 'org.json:json:20200518' - testImplementation("org.mockito:mockito-core:2.8.47") { + testImplementation("org.mockito:mockito-core:${mockitoVersion}") { exclude group: 'net.bytebuddy', module: 'byte-buddy' exclude group: 'net.bytebuddy', module: 'byte-buddy-android' exclude group: 'net.bytebuddy', module: 'byte-buddy-agent'