Merge remote-tracking branch 'origin/dev' into rs

This commit is contained in:
Milos Kozak 2020-04-23 23:54:21 +02:00
commit 7b4cba14d1
24 changed files with 488 additions and 407 deletions

View file

@ -28,6 +28,7 @@ import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.androidaps.plugins.general.tidepool.TidepoolPlugin
import info.nightscout.androidaps.plugins.general.wear.WearPlugin
@ -49,8 +50,8 @@ import info.nightscout.androidaps.plugins.source.EversensePlugin
import info.nightscout.androidaps.plugins.source.GlimpPlugin
import info.nightscout.androidaps.plugins.source.PoctechPlugin
import info.nightscout.androidaps.plugins.source.TomatoPlugin
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.show
import info.nightscout.androidaps.utils.SafeParse
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.show
import info.nightscout.androidaps.utils.protection.PasswordCheck
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -97,6 +98,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
@Inject lateinit var maintenancePlugin: MaintenancePlugin
@Inject lateinit var passwordCheck: PasswordCheck
@Inject lateinit var nsSettingStatus: NSSettingsStatus
@Inject lateinit var androidInjector: DispatchingAndroidInjector<Any>
@ -339,6 +341,11 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
passwordCheck.setPassword(context, R.string.application_password, R.string.key_application_password)
return true
}
// NSClient copy settings
if (preference.key == resourceHelper.gs(R.string.key_statuslights_copy_ns)) {
nsSettingStatus.copyStatusLightsNsSettings(context)
return true
}
}
}
return super.onPreferenceTreeClick(preference)

View file

@ -33,6 +33,7 @@ import info.nightscout.androidaps.plugins.general.overview.graphExtensions.Point
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.utils.Translator;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
@DatabaseTable(tableName = DatabaseHelper.DATABASE_CAREPORTALEVENTS)
public class CareportalEvent implements DataPointWithLabelInterface, Interval {
@ -93,15 +94,15 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
return (System.currentTimeMillis() - date) / (60 * 60 * 1000.0);
}
public String age(boolean useShortText) {
public String age(boolean useShortText, ResourceHelper resourceHelper) {
Map<TimeUnit, Long> diff = computeDiff(date, System.currentTimeMillis());
String days = " " + MainApp.gs(R.string.days) + " ";
String hours = " " + MainApp.gs(R.string.hours) + " ";
String days = " " + resourceHelper.gs(R.string.days) + " ";
String hours = " " + resourceHelper.gs(R.string.hours) + " ";
if (useShortText) {
days = MainApp.gs(R.string.shortday);
hours = MainApp.gs(R.string.shorthour);
days = resourceHelper.gs(R.string.shortday);
hours = resourceHelper.gs(R.string.shorthour);
}
return diff.get(TimeUnit.DAYS) + days + diff.get(TimeUnit.HOURS) + hours;

View file

@ -240,7 +240,7 @@ class ActionsFragment : DaggerFragment() {
actions_temptarget?.visibility = Config.APS.toVisibility()
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
statusLightHandler.updateAge(careportal_sensorage, careportal_insulinage, careportal_canulaage, careportal_pbage)
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
checkPumpCustomActions()
}

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.events.EventCareportalEventChange
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -23,7 +22,6 @@ import javax.inject.Inject
class CareportalFragment : DaggerFragment(), View.OnClickListener {
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var nsSettingsStatus: NSSettingsStatus
@Inject lateinit var statusLightHandler: StatusLightHandler
@Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var activePlugin: ActivePluginProvider
@ -133,6 +131,6 @@ class CareportalFragment : DaggerFragment(), View.OnClickListener {
}
private fun updateGUI() {
statusLightHandler.updateAge(careportal_sensorage, careportal_insulinage, careportal_canulaage, careportal_pbage)
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
}
}

View file

@ -185,15 +185,7 @@ public class NSClientPlugin extends PluginBase {
super.preprocessPreferences(preferenceFragment);
if (Config.NSCLIENT) {
PreferenceScreen scrnAdvancedSettings = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_advancedsettings));
if (scrnAdvancedSettings != null) {
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_res_warning)));
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_res_critical)));
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_bat_warning)));
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_bat_critical)));
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_show_statuslights)));
scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(resourceHelper.gs(R.string.key_show_statuslights_extended)));
}
preferenceFragment.findPreference(resourceHelper.gs(R.string.key_statuslights_overview_advanced));
}
}

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.general.nsclient.data
import android.content.Context
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.logging.AAPSLogger
@ -10,7 +11,9 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.JsonHelper
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.json.JSONException
import org.json.JSONObject
import javax.inject.Inject
@ -111,10 +114,12 @@ class NSSettingsStatus @Inject constructor(
private val aapsLogger: AAPSLogger,
private val resourceHelper: ResourceHelper,
private val rxBus: RxBusWrapper,
private val defaultValueHelper: DefaultValueHelper
private val defaultValueHelper: DefaultValueHelper,
private val sp: SP
) {
var nightscoutVersionName = ""
// ***** PUMP STATUS ******
var data: JSONObject? = null
@ -133,6 +138,7 @@ class NSSettingsStatus @Inject constructor(
val targetlow = getSettingsThreshold("bgTargetBottom")
if (targetHigh != null) defaultValueHelper.bgTargetHigh = targetHigh
if (targetlow != null) defaultValueHelper.bgTargetLow = targetlow
copyStatusLightsNsSettings(null)
}
fun getName(): String? =
@ -152,10 +158,14 @@ class NSSettingsStatus @Inject constructor(
// valid property is "warn" or "urgent"
// plugings "iage" "sage" "cage" "pbage"
fun getExtendedWarnValue(plugin: String, property: String, defaultValue: Double): Double {
val extendedSettings = getExtendedSettings() ?: return defaultValue
val pluginJson = extendedSettings.optJSONObject(plugin) ?: return defaultValue
return pluginJson.optDouble(property, defaultValue)
fun getExtendedWarnValue(plugin: String, property: String): Double? {
val extendedSettings = getExtendedSettings() ?: return null
val pluginJson = extendedSettings.optJSONObject(plugin) ?: return null
try {
return pluginJson.getDouble(property)
} catch (e: Exception) {
return null
}
}
// "bgHigh": 252,
@ -211,4 +221,20 @@ class NSSettingsStatus @Inject constructor(
val openaps = JsonHelper.safeGetJSONObject(getExtendedSettings(), "openaps", null)
return JsonHelper.safeGetBoolean(openaps, "enableAlerts")
}
fun copyStatusLightsNsSettings(context: Context?) {
val action = Runnable {
getExtendedWarnValue("cage", "warn")?.let { sp.putDouble(R.string.key_statuslights_cage_warning, it) }
getExtendedWarnValue("cage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_cage_critical, it) }
getExtendedWarnValue("iage", "warn")?.let { sp.putDouble(R.string.key_statuslights_iage_warning, it) }
getExtendedWarnValue("iage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_iage_critical, it) }
getExtendedWarnValue("sage", "warn")?.let { sp.putDouble(R.string.key_statuslights_sage_warning, it) }
getExtendedWarnValue("sage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_sage_critical, it) }
getExtendedWarnValue("bage", "warn")?.let { sp.putDouble(R.string.key_statuslights_bage_warning, it) }
getExtendedWarnValue("bage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_bage_critical, it) }
}
if (context != null) OKDialog.showConfirmation(context, resourceHelper.gs(R.string.statuslights), resourceHelper.gs(R.string.copyexistingvalues), action)
else action.run()
}
}

View file

@ -68,8 +68,13 @@ import info.nightscout.androidaps.utils.wizard.QuickWizard
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.careportal_stats_fragment.*
import kotlinx.android.synthetic.main.overview_fragment.*
import kotlinx.android.synthetic.main.overview_fragment.careportal_canulaage
import kotlinx.android.synthetic.main.overview_fragment.careportal_insulinage
import kotlinx.android.synthetic.main.overview_fragment.careportal_reservoirlevel
import kotlinx.android.synthetic.main.overview_fragment.careportal_sensorage
import kotlinx.android.synthetic.main.overview_fragment.careportal_pbage
import kotlinx.android.synthetic.main.overview_fragment.careportal_batterylevel
import kotlinx.android.synthetic.main.overview_fragment.overview_activeprofile
import kotlinx.android.synthetic.main.overview_fragment.overview_apsmode
import kotlinx.android.synthetic.main.overview_fragment.overview_arrow
@ -714,15 +719,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}
}
// NSClient mode
statusLightHandler.updateAge(careportal_sensorage, careportal_insulinage, careportal_canulaage, careportal_pbage)
// Mode modes
if (sp.getBoolean(R.string.key_show_statuslights, false)) {
if (sp.getBoolean(R.string.key_show_statuslights_extended, false))
statusLightHandler.extendedStatusLight(overview_canulaage, overview_insulinage, overview_reservoirlevel, overview_sensorage, overview_batterylevel)
else
statusLightHandler.statusLight(overview_canulaage, overview_insulinage, overview_reservoirlevel, overview_sensorage, overview_batterylevel)
}
// Status lights
overview_statuslights?.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || Config.NSCLIENT).toVisibility()
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, careportal_pbage, careportal_batterylevel)
// cob
var cobText: String = resourceHelper.gs(R.string.value_unavailable_short)
@ -755,7 +754,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
// ****** GRAPH *******
GlobalScope.launch(Dispatchers.Main) {
overview_bggraph?: return@launch
overview_bggraph ?: return@launch
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin)
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()

View file

@ -1,17 +1,15 @@
package info.nightscout.androidaps.plugins.general.overview
import android.graphics.Color
import android.view.View
import android.widget.TextView
import androidx.arch.core.util.Function
import androidx.annotation.StringRes
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.db.CareportalEvent
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.SetWarnColor
import info.nightscout.androidaps.utils.WarnColors
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import javax.inject.Inject
@ -19,154 +17,44 @@ import javax.inject.Singleton
@Singleton
class StatusLightHandler @Inject constructor(
private val nsSettingsStatus: NSSettingsStatus,
private val resourceHelper: ResourceHelper,
private val sp: SP,
private val activePlugin: ActivePluginProvider
private val activePlugin: ActivePluginProvider,
private val warnColors: WarnColors
) {
/**
* applies the statusLight subview on the overview fragment
*/
fun statusLight(cageView: TextView?, iAgeView: TextView?, reservoirView: TextView?,
sageView: TextView?, batteryView: TextView?) {
val pump = activePlugin.activePump
applyStatusLight("cage", CareportalEvent.SITECHANGE, cageView, "CAN", 48, 72)
applyStatusLight("iage", CareportalEvent.INSULINCHANGE, iAgeView, "INS", 72, 96)
val reservoirLevel = if (pump.isInitialized) pump.reservoirLevel else (-1).toDouble()
applyStatusLightLevel(R.string.key_statuslights_res_critical, 10.0,
R.string.key_statuslights_res_warning, 80.0, reservoirView, "RES", reservoirLevel)
applyStatusLight("sage", CareportalEvent.SENSORCHANGE, sageView, "SEN", 164, 166)
if (pump.model() != PumpType.AccuChekCombo) {
val batteryLevel = if (pump.isInitialized) pump.batteryLevel.toDouble() else -1.0
applyStatusLightLevel(R.string.key_statuslights_bat_critical, 5.0,
R.string.key_statuslights_bat_warning, 22.0,
batteryView, "BAT", batteryLevel)
} else {
applyStatusLight("bage", CareportalEvent.PUMPBATTERYCHANGE, batteryView, "BAT", 224, 336)
}
}
private fun applyStatusLight(nsSettingPlugin: String?, eventName: String?, view: TextView?, text: String?,
defaultWarnThreshold: Int, defaultUrgentThreshold: Int) {
if (view != null) {
val urgent = nsSettingsStatus.getExtendedWarnValue(nsSettingPlugin!!, "urgent", defaultUrgentThreshold.toDouble())
val warn = nsSettingsStatus.getExtendedWarnValue(nsSettingPlugin, "warn", defaultWarnThreshold.toDouble())
val event = MainApp.getDbHelper().getLastCareportalEvent(eventName)
val age = event?.hoursFromStart ?: Double.MAX_VALUE
applyStatusLight(view, text, age, warn, urgent, Double.MAX_VALUE, true)
}
}
private fun applyStatusLightLevel(criticalSetting: Int, criticalDefaultValue: Double,
warnSetting: Int, warnDefaultValue: Double,
view: TextView?, text: String?, level: Double) {
if (view != null) {
val resUrgent = sp.getDouble(criticalSetting, criticalDefaultValue)
val resWarn = sp.getDouble(warnSetting, warnDefaultValue)
applyStatusLight(view, text, level, resWarn, resUrgent, -1.0, false)
}
}
private fun applyStatusLight(view: TextView, text: String?, value: Double, warnThreshold: Double,
urgentThreshold: Double, invalid: Double, checkAscending: Boolean) {
val check =
if (checkAscending) Function { threshold: Double -> value >= threshold }
else Function { threshold: Double -> value <= threshold }
if (value != invalid) {
view.text = text
when {
check.apply(urgentThreshold) -> view.setTextColor(resourceHelper.gc(R.color.ribbonCritical))
check.apply(warnThreshold) -> view.setTextColor(resourceHelper.gc(R.color.ribbonWarning))
else -> view.setTextColor(resourceHelper.gc(R.color.ribbonDefault))
}
view.visibility = View.VISIBLE
} else {
view.visibility = View.GONE
}
}
/**
* applies the extended statusLight subview on the overview fragment
*/
fun extendedStatusLight(cageView: TextView?, iAgeView: TextView?,
reservoirView: TextView?, sageView: TextView?,
batteryView: TextView?) {
fun updateStatusLights(careportal_canulaage: TextView?, careportal_insulinage: TextView?, careportal_reservoirlevel: TextView?, careportal_sensorage: TextView?, careportal_pbage: TextView?, careportal_batterylevel: TextView?) {
val pump = activePlugin.activePump
handleAge("cage", CareportalEvent.SITECHANGE, cageView, "CAN ",
48, 72)
handleAge("iage", CareportalEvent.INSULINCHANGE, iAgeView, "INS ",
72, 96)
handleLevel(R.string.key_statuslights_res_critical, 10.0,
R.string.key_statuslights_res_warning, 80.0,
reservoirView, "RES ", pump.reservoirLevel)
handleAge("sage", CareportalEvent.SENSORCHANGE, sageView, "SEN ",
164, 166)
if (pump.model() != PumpType.AccuChekCombo) {
handleLevel(R.string.key_statuslights_bat_critical, 26.0,
R.string.key_statuslights_bat_warning, 51.0,
batteryView, "BAT ", pump.batteryLevel.toDouble())
} else {
handleAge("bage", CareportalEvent.PUMPBATTERYCHANGE, batteryView, "BAT ",
224, 336)
}
handleAge(careportal_canulaage, "cage", CareportalEvent.SITECHANGE, R.string.key_statuslights_cage_warning, 48.0, R.string.key_statuslights_cage_critical, 72.0)
handleAge(careportal_insulinage, "iage", CareportalEvent.INSULINCHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0)
handleAge(careportal_sensorage, "sage", CareportalEvent.SENSORCHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
handleAge(careportal_pbage, "bage", 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)
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())
}
private fun handleAge(nsSettingPlugin: String, eventName: String, view: TextView?, text: String,
defaultWarnThreshold: Int, defaultUrgentThreshold: Int) {
val urgent = nsSettingsStatus.getExtendedWarnValue(nsSettingPlugin, "urgent", defaultUrgentThreshold.toDouble())
val warn = nsSettingsStatus.getExtendedWarnValue(nsSettingPlugin, "warn", defaultWarnThreshold.toDouble())
handleAge(view, text, eventName, warn, urgent)
}
private fun handleLevel(criticalSetting: Int, criticalDefaultValue: Double,
warnSetting: Int, warnDefaultValue: Double,
view: TextView?, text: String, level: Double) {
if (view != null) {
val resUrgent = sp.getDouble(criticalSetting, criticalDefaultValue)
val resWarn = sp.getDouble(warnSetting, warnDefaultValue)
@Suppress("SetTextI18n")
view.text = text + DecimalFormatter.to0Decimal(level)
SetWarnColor.setColorInverse(view, level, resWarn, resUrgent)
}
}
private fun handleAge(age: TextView?, eventType: String, warnThreshold: Double, urgentThreshold: Double) =
handleAge(age, "", eventType, warnThreshold, urgentThreshold)
fun handleAge(age: TextView?, prefix: String, eventType: String, warnThreshold: Double, urgentThreshold: Double) {
val notavailable = if (resourceHelper.shortTextMode()) "-" else resourceHelper.gs(R.string.notavailable)
val careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(eventType)
private fun handleAge(view: TextView?, nsSettingPlugin: String, eventName: String, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) {
val warn = sp.getDouble(warnSettings, defaultWarnThreshold)
val urgent = sp.getDouble(urgentSettings, defaultUrgentThreshold)
val careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(eventName)
if (careportalEvent != null) {
age?.setTextColor(determineTextColor(careportalEvent, warnThreshold, urgentThreshold))
age?.text = prefix + careportalEvent.age(resourceHelper.shortTextMode())
warnColors.setColorByAge(view, careportalEvent, warn, urgent)
view?.text = careportalEvent.age(resourceHelper.shortTextMode(), resourceHelper)
} else {
age?.text = notavailable
view?.text = if (resourceHelper.shortTextMode()) "-" else resourceHelper.gs(R.string.notavailable)
}
}
fun updateAge(sage: TextView?, iage: TextView?, cage: TextView?, pbage: TextView?) {
val iageUrgent = nsSettingsStatus.getExtendedWarnValue("iage", "urgent", 96.0)
val iageWarn = nsSettingsStatus.getExtendedWarnValue("iage", "warn", 72.0)
handleAge(iage, CareportalEvent.INSULINCHANGE, iageWarn, iageUrgent)
val cageUrgent = nsSettingsStatus.getExtendedWarnValue("cage", "urgent", 72.0)
val cageWarn = nsSettingsStatus.getExtendedWarnValue("cage", "warn", 48.0)
handleAge(cage, CareportalEvent.SITECHANGE, cageWarn, cageUrgent)
val sageUrgent = nsSettingsStatus.getExtendedWarnValue("sage", "urgent", 166.0)
val sageWarn = nsSettingsStatus.getExtendedWarnValue("sage", "warn", 164.0)
handleAge(sage, CareportalEvent.SENSORCHANGE, sageWarn, sageUrgent)
val pbageUrgent = nsSettingsStatus.getExtendedWarnValue("bage", "urgent", 360.0)
val pbageWarn = nsSettingsStatus.getExtendedWarnValue("bage", "warn", 240.0)
handleAge(pbage, CareportalEvent.PUMPBATTERYCHANGE, pbageWarn, pbageUrgent)
}
fun determineTextColor(careportalEvent: CareportalEvent, warnThreshold: Double, urgentThreshold: Double): Int {
return if (careportalEvent.isOlderThan(urgentThreshold)) {
resourceHelper.gc(R.color.low)
} else if (careportalEvent.isOlderThan(warnThreshold)) {
resourceHelper.gc(R.color.high)
} else {
Color.WHITE
}
private fun handleLevel(view: TextView?, criticalSetting: Int, criticalDefaultValue: Double, warnSetting: Int, warnDefaultValue: Double, level: Double) {
val resUrgent = sp.getDouble(criticalSetting, criticalDefaultValue)
val resWarn = sp.getDouble(warnSetting, warnDefaultValue)
@Suppress("SetTextI18n")
view?.text = " " + DecimalFormatter.to0Decimal(level)
warnColors.setColorInverse(view, level, resWarn, resUrgent)
}
}

View file

@ -6,7 +6,6 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
import info.nightscout.androidaps.plugins.general.nsclient.data.NSAlarm
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -21,7 +20,6 @@ class NotificationWithAction constructor(
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var sp: SP
@Inject lateinit var defaultValueHelper: DefaultValueHelper
@Inject lateinit var nsSettingsStatus: NSSettingsStatus
@Inject lateinit var nsClientPlugin: NSClientPlugin
private var nsAlarm: NSAlarm? = null

View file

@ -29,8 +29,8 @@ import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
import info.nightscout.androidaps.queue.events.EventQueueChanged
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.SetWarnColor
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.WarnColors
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.extensions.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -51,6 +51,7 @@ class DanaRFragment : DaggerFragment() {
@Inject lateinit var danaRPump: DanaRPump
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var sp: SP
@Inject lateinit var warnColors: WarnColors
private var disposable: CompositeDisposable = CompositeDisposable()
@ -179,7 +180,7 @@ class DanaRFragment : DaggerFragment() {
val agoMsec = System.currentTimeMillis() - pump.lastConnection
val agoMin = (agoMsec.toDouble() / 60.0 / 1000.0).toInt()
danar_lastconnection?.text = DateUtil.timeString(pump.lastConnection) + " (" + resourceHelper.gs(R.string.minago, agoMin) + ")"
SetWarnColor.setColor(danar_lastconnection, agoMin.toDouble(), 16.0, 31.0)
warnColors.setColor(danar_lastconnection, agoMin.toDouble(), 16.0, 31.0)
}
if (pump.lastBolusTime != 0L) {
val agoMsec = System.currentTimeMillis() - pump.lastBolusTime
@ -192,7 +193,7 @@ class DanaRFragment : DaggerFragment() {
}
danar_dailyunits?.text = resourceHelper.gs(R.string.reservoirvalue, pump.dailyTotalUnits, pump.maxDailyTotalUnits)
SetWarnColor.setColor(danar_dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
warnColors.setColor(danar_dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
danar_basabasalrate?.text = "( " + (pump.activeProfile + 1) + " ) " + resourceHelper.gs(R.string.pump_basebasalrate, plugin.baseBasalRate)
// DanaRPlugin, DanaRKoreanPlugin
if (activePlugin.activePump.isFakingTempsByExtendedBoluses == true) {
@ -206,9 +207,9 @@ class DanaRFragment : DaggerFragment() {
danar_extendedbolus?.text = activePlugin.activeTreatments.getExtendedBolusFromHistory(System.currentTimeMillis())?.toString()
?: ""
danar_reservoir?.text = resourceHelper.gs(R.string.reservoirvalue, pump.reservoirRemainingUnits, 300)
SetWarnColor.setColorInverse(danar_reservoir, pump.reservoirRemainingUnits, 50.0, 20.0)
warnColors.setColorInverse(danar_reservoir, pump.reservoirRemainingUnits, 50.0, 20.0)
danar_battery?.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}"
SetWarnColor.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0)
warnColors.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0)
danar_iob?.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob)
danar_firmware?.text = resourceHelper.gs(R.string.dana_model, pump.modelFriendlyName(), pump.hwModel, pump.protocol, pump.productCode)
danar_basalstep?.text = pump.basalStep.toString()

View file

@ -38,8 +38,8 @@ import info.nightscout.androidaps.queue.events.EventQueueChanged
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.SetWarnColor
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.WarnColors
import info.nightscout.androidaps.utils.extensions.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper
import io.reactivex.android.schedulers.AndroidSchedulers
@ -56,6 +56,7 @@ class MedtronicFragment : DaggerFragment() {
@Inject lateinit var commandQueue: CommandQueueProvider
@Inject lateinit var activePlugin: ActivePluginProvider
@Inject lateinit var medtronicPumpPlugin: MedtronicPumpPlugin
@Inject lateinit var warnColors: WarnColors
private var disposable: CompositeDisposable = CompositeDisposable()
@ -325,11 +326,11 @@ class MedtronicFragment : DaggerFragment() {
} else {
medtronic_pumpstate_battery.text = "{fa-battery-" + pumpStatus.batteryRemaining / 25 + "} " + pumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", pumpStatus.batteryVoltage)
}
SetWarnColor.setColorInverse(medtronic_pumpstate_battery, pumpStatus.batteryRemaining.toDouble(), 25.0, 10.0)
warnColors.setColorInverse(medtronic_pumpstate_battery, pumpStatus.batteryRemaining.toDouble(), 25.0, 10.0)
// reservoir
medtronic_reservoir.text = resourceHelper.gs(R.string.reservoirvalue, pumpStatus.reservoirRemainingUnits, pumpStatus.reservoirFullUnits)
SetWarnColor.setColorInverse(medtronic_reservoir, pumpStatus.reservoirRemainingUnits, 50.0, 20.0)
warnColors.setColorInverse(medtronic_reservoir, pumpStatus.reservoirRemainingUnits, 50.0, 20.0)
medtronic_errors.text = pumpStatus.errorInfo
}

View file

@ -1,25 +0,0 @@
package info.nightscout.androidaps.utils;
import android.graphics.Color;
import android.widget.TextView;
/**
* Created by mike on 08.07.2016.
*/
public class SetWarnColor {
static final int normalColor = Color.WHITE;
static final int warnColor = Color.YELLOW;
static final int urgentColor = Color.RED;
public static void setColor(TextView view, double value, double warnLevel, double urgentLevel) {
if (value >= urgentLevel) view.setTextColor(urgentColor);
else if (value >= warnLevel) view.setTextColor(warnColor);
else view.setTextColor(normalColor);
}
public static void setColorInverse(TextView view, double value, double warnLevel, double urgentLevel) {
if (value <= urgentLevel) view.setTextColor(urgentColor);
else if (value <= warnLevel) view.setTextColor(warnColor);
else view.setTextColor(normalColor);
}
}

View file

@ -0,0 +1,38 @@
package info.nightscout.androidaps.utils
import android.graphics.Color
import android.widget.TextView
import info.nightscout.androidaps.R
import info.nightscout.androidaps.db.CareportalEvent
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class WarnColors @Inject constructor(val resourceHelper: ResourceHelper) {
private val normalColor = Color.WHITE
private val warnColor = Color.YELLOW
private val urgentColor = Color.RED
fun setColor(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double) =
view?.setTextColor(when {
value >= urgentLevel -> urgentColor
value >= warnLevel -> warnColor
else -> normalColor
})
fun setColorInverse(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double) =
view?.setTextColor(when {
value <= urgentLevel -> urgentColor
value <= warnLevel -> warnColor
else -> normalColor
})
fun setColorByAge(view: TextView?, careportalEvent: CareportalEvent, warnThreshold: Double, urgentThreshold: Double) =
view?.setTextColor(when {
careportalEvent.isOlderThan(urgentThreshold) -> resourceHelper.gc(R.color.low)
careportalEvent.isOlderThan(warnThreshold) -> resourceHelper.gc(R.color.high)
else -> Color.WHITE
})
}

View file

@ -42,21 +42,19 @@ class ResourceHelperImplementation @Inject constructor(private val context: Cont
override fun openRawResourceFd(id: Int): AssetFileDescriptor =
context.resources.openRawResourceFd(id)
override fun getIcon(): Int {
return when {
override fun getIcon(): Int =
when {
Config.NSCLIENT -> R.mipmap.ic_yellowowl
Config.PUMPCONTROL -> R.mipmap.ic_pumpcontrol
else -> R.mipmap.ic_launcher
}
}
override fun getNotificationIcon(): Int {
return when {
override fun getNotificationIcon(): Int =
when {
Config.NSCLIENT -> R.drawable.ic_notif_nsclient
Config.PUMPCONTROL -> R.drawable.ic_notif_pumpcontrol
else -> R.drawable.ic_notif_aaps
}
}
override fun decodeResource(id: Int): Bitmap =
BitmapFactory.decodeResource(context.resources, id)
@ -69,5 +67,5 @@ class ResourceHelperImplementation @Inject constructor(private val context: Cont
return (dp * scale + 0.5f).toInt()
}
override fun shortTextMode() : Boolean = !gb(R.bool.isTablet) && Config.NSCLIENT
override fun shortTextMode() : Boolean = !gb(R.bool.isTablet)
}

View file

@ -29,6 +29,7 @@ interface SP {
fun putBoolean(key: String, value: Boolean)
fun putBoolean(@StringRes resourceID: Int, value: Boolean)
fun putDouble(key: String, value: Double)
fun putDouble(@StringRes resourceID: Int, value: Double)
fun putLong(key: String, value: Long)
fun putLong(@StringRes resourceID: Int, value: Long)
fun putInt(key: String, value: Int)

View file

@ -102,6 +102,10 @@ class SPImplementation @Inject constructor(
override fun putDouble(key: String, value: Double) =
sharedPreferences.edit().putString(key, value.toString()).apply()
override fun putDouble(resourceID: Int, value: Double) {
sharedPreferences.edit().putString(resourceHelper.gs(resourceID), value.toString()).apply()
}
override fun putLong(key: String, value: Long) =
sharedPreferences.edit().putLong(key, value).apply()

View file

@ -0,0 +1 @@
# danars-support-lib

View file

@ -363,58 +363,101 @@
<LinearLayout
android:id="@+id/overview_statuslights"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:background="?android:attr/colorControlHighlight"
android:orientation="horizontal"
android:paddingTop="4dp"
android:paddingBottom="4dp"
app:layout_constraintBottom_toTopOf="@+id/overview_bggraph"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/bg_tbr_layout">
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_canula" />
<TextView
android:id="@+id/overview_canulaage"
android:id="@+id/careportal_canulaage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_insulin" />
<TextView
android:id="@+id/careportal_insulinage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_insulinage"
android:id="@+id/careportal_reservoirlevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="14sp" />
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_sensor" />
<TextView
android:id="@+id/careportal_sensorage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_battery" />
<TextView
android:id="@+id/careportal_pbage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_reservoirlevel"
android:id="@+id/careportal_batterylevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:textSize="14sp" />
<TextView
android:id="@+id/overview_sensorage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:textSize="14sp" />
<TextView
android:id="@+id/overview_batterylevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
</LinearLayout>

View file

@ -363,58 +363,101 @@
<LinearLayout
android:id="@+id/overview_statuslights"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:background="?android:attr/colorControlHighlight"
android:orientation="horizontal"
android:paddingTop="4dp"
android:paddingBottom="4dp"
app:layout_constraintBottom_toTopOf="@+id/overview_bggraph"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/bg_tbr_layout">
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_canula" />
<TextView
android:id="@+id/overview_canulaage"
android:id="@+id/careportal_canulaage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_insulin" />
<TextView
android:id="@+id/careportal_insulinage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_insulinage"
android:id="@+id/careportal_reservoirlevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="14sp" />
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_sensor" />
<TextView
android:id="@+id/careportal_sensorage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_battery" />
<TextView
android:id="@+id/careportal_pbage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_reservoirlevel"
android:id="@+id/careportal_batterylevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:textSize="14sp" />
<TextView
android:id="@+id/overview_sensorage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:textSize="14sp" />
<TextView
android:id="@+id/overview_batterylevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
</LinearLayout>

View file

@ -117,7 +117,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/overview_statuslights_nscl"
app:layout_constraintBottom_toTopOf="@+id/overview_statuslights"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/overview_pumpstatuslayout">
@ -362,98 +362,104 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/overview_statuslights_nscl"
android:id="@+id/overview_statuslights"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:background="?android:attr/colorControlHighlight"
android:orientation="horizontal"
android:paddingTop="4dp"
android:paddingBottom="4dp"
app:layout_constraintBottom_toTopOf="@+id/overview_pump"
app:layout_constraintBottom_toTopOf="@+id/overview_bggraph"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/bg_tbr_layout">
<ImageView
android:layout_width="30dp"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="0"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:paddingEnd="1dp"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_canula" />
<TextView
android:id="@+id/careportal_canulaage"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
<ImageView
android:layout_width="30dp"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="0"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:paddingEnd="1dp"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_insulin" />
<TextView
android:id="@+id/careportal_insulinage"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
<ImageView
android:layout_width="30dp"
android:layout_height="match_parent"
<TextView
android:id="@+id/careportal_reservoirlevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="14sp" />
<ImageView
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:paddingEnd="1dp"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_sensor" />
<TextView
android:id="@+id/careportal_sensorage"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
<ImageView
android:layout_width="30dp"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="0"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:paddingEnd="1dp"
android:scaleType="centerInside"
android:src="@drawable/icon_cp_age_battery" />
<TextView
android:id="@+id/careportal_pbage"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:textSize="14sp" />
<TextView
android:id="@+id/careportal_batterylevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="1dp"
android:paddingEnd="2dp"
android:textSize="14sp" />
</LinearLayout>
<TextView
@ -468,7 +474,7 @@
app:layout_constraintBottom_toTopOf="@+id/overview_openaps"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/overview_statuslights_nscl" />
app:layout_constraintTop_toBottomOf="@+id/overview_statuslights" />
<TextView
android:id="@+id/overview_openaps"

View file

@ -131,7 +131,6 @@
<string name="configbuilder">Config Builder</string>
<string name="objectives">Objectives</string>
<string name="openapsma">OpenAPS MA</string>
<string name="overview">Overview</string>
<string name="nsprofile">NS Profile</string>
<string name="simpleprofile">Simple profile</string>
@ -653,18 +652,31 @@
<string name="key_usesuperbolus" translatable="false">key_usersuperbolus</string>
<string name="enablesuperbolus">Enable superbolus in wizard</string>
<string name="enablesuperbolus_summary">Enable superbolus functionality in wizard. Do not enable until you learn what it really does. IT MAY CAUSE INSULIN OVERDOSE IF USED BLINDLY!</string>
<string name="key_show_statuslights" translatable="false">key_show_statuslights</string>
<string name="key_show_statuslights_extended" translatable="false">key_show_statuslights_extended</string>
<string name="key_show_statuslights" translatable="false">show_statuslights</string>
<string name="show_statuslights">Show status lights on home screen</string>
<string name="show_statuslights_extended">Show extended status lights on home screen</string>
<string name="show_statuslights_extended_summary">Enable extended status lights for cage, iage, sage, reservoir and battery level on home screen.</string>
<string name="key_statuslights_res_warning" translatable="false">key_statuslights_res_warning</string>
<string name="key_statuslights_cage_warning" translatable="false">statuslights_cage_warning</string>
<string name="statuslights_cage_warning">Threshold warning canula age [h]</string>
<string name="key_statuslights_cage_critical" translatable="false">statuslights_cage_critical</string>
<string name="statuslights_cage_critical">Threshold critical canula age [h]</string>
<string name="key_statuslights_iage_warning" translatable="false">statuslights_iage_warning</string>
<string name="statuslights_iage_warning">Threshold warning insulin age [h]</string>
<string name="key_statuslights_iage_critical" translatable="false">statuslights_iage_critical</string>
<string name="statuslights_iage_critical">Threshold critical insulin age [h]</string>
<string name="key_statuslights_sage_warning" translatable="false">statuslights_sage_warning</string>
<string name="statuslights_sage_warning">Threshold warning sensor age [h]</string>
<string name="key_statuslights_sage_critical" translatable="false">statuslights_sage_critical</string>
<string name="statuslights_sage_critical">Threshold critical sensor age [h]</string>
<string name="key_statuslights_bage_warning" translatable="false">statuslights_bage_warning</string>
<string name="statuslights_bage_warning">Threshold warning battery age [h]</string>
<string name="key_statuslights_bage_critical" translatable="false">statuslights_bage_critical</string>
<string name="statuslights_bage_critical">Threshold critical battery age [h]</string>
<string name="key_statuslights_res_warning" translatable="false">statuslights_res_warning</string>
<string name="statuslights_res_warning">Threshold warning reservoir level [U]</string>
<string name="key_statuslights_res_critical" translatable="false">key_statuslights_res_critical</string>
<string name="key_statuslights_res_critical" translatable="false">statuslights_res_critical</string>
<string name="statuslights_res_critical">Threshold critical reservoir level [U]</string>
<string name="key_statuslights_bat_warning" translatable="false">key_statuslights_bat_warning</string>
<string name="key_statuslights_bat_warning" translatable="false">statuslights_bat_warning</string>
<string name="statuslights_bat_warning">Threshold warning battery level [%]</string>
<string name="key_statuslights_bat_critical" translatable="false">key_statuslights_bat_critical</string>
<string name="key_statuslights_bat_critical" translatable="false">statuslights_bat_critical</string>
<string name="statuslights_bat_critical">Threshold critical battery level [%]</string>
<string name="iob">IOB</string>
<string name="cob">COB</string>
@ -1826,4 +1838,9 @@
<string name="master_password_summary">Master password is used for backup encryption and to override security in application. Remember it or store on a safe place.</string>
<string name="passwords_dont_match">Passwords don\'t match</string>
<string name="current_master_password">Current master password</string>
<string name="statuslights">Status lights</string>
<string name="statuslights_copy_ns">Copy settings from NS</string>
<string name="key_statuslights_copy_ns">statuslights_copy_ns</string>
<string name="copyexistingvalues">Copy NS settins (if exists)?</string>
<string name="key_statuslights_overview_advanced" translatable="false">statuslights_overview_advanced</string>
</resources>

View file

@ -1,63 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:title="@string/openapsma"
app:initialExpandedChildrenCount="0">
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="1"
android:dialogMessage="@string/openapsma_maxbasal_summary"
android:inputType="numberDecimal"
android:key="@string/key_openapsma_max_basal"
android:title="@string/openapsma_maxbasal_title"
validate:floatmaxNumber="12.0"
validate:floatminNumber="0.1"
validate:testType="floatNumericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="1.5"
android:dialogMessage="@string/openapsma_maxiob_summary"
android:inputType="numberDecimal"
android:key="@string/key_openapsma_max_iob"
android:title="@string/openapsma_maxiob_title"
validate:floatmaxNumber="12.0"
validate:floatminNumber="0"
validate:testType="floatNumericRange" />
<androidx.preference.PreferenceScreen
android:key="absorption_ma_advanced"
android:title="@string/advancedsettings_title">
<Preference android:summary="@string/openapsama_link_to_preferncejson_doc_txt">
<intent
android:action="android.intent.action.VIEW"
android:data="@string/openapsama_link_to_preferncejson_doc" />
</Preference>
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_always_use_shortavg"
android:summary="@string/always_use_shortavg_summary"
android:title="@string/always_use_shortavg" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="2"
android:dialogMessage="@string/openapsama_bolussnooze_dia_divisor_summary"
android:digits="0123456789.,"
android:inputType="numberDecimal"
android:key="@string/key_openapsama_bolussnooze_dia_divisor"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/openapsama_bolussnooze_dia_divisor"
validate:maxNumber="10"
validate:minNumber="1"
validate:testType="floatNumericRange" />
</androidx.preference.PreferenceScreen>
</PreferenceCategory>
</androidx.preference.PreferenceScreen>

View file

@ -274,39 +274,117 @@
android:title="@string/overview_show_notes_field_in_dialogs_title" />
<androidx.preference.PreferenceScreen
android:key="absorption_overview_advanced"
android:title="@string/advancedsettings_title">
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="100"
android:dialogMessage="@string/deliverpartofboluswizard"
android:inputType="number"
android:key="@string/key_boluswizard_percentage"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/partialboluswizard"
validate:maxNumber="100"
validate:minNumber="10"
validate:testType="numericRange" />
android:key="@string/key_statuslights_overview_advanced"
android:title="@string/statuslights">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_usesuperbolus"
android:summary="@string/enablesuperbolus_summary"
android:title="@string/enablesuperbolus" />
<SwitchPreference
android:defaultValue="false"
android:defaultValue="true"
android:key="@string/key_show_statuslights"
android:title="@string/show_statuslights" />
<SwitchPreference
android:defaultValue="false"
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="48"
android:dependency="@string/key_show_statuslights"
android:key="@string/key_show_statuslights_extended"
android:summary="@string/show_statuslights_extended_summary"
android:title="@string/show_statuslights_extended" />
android:inputType="numberSigned"
android:key="@string/key_statuslights_cage_warning"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/statuslights_cage_warning"
validate:maxNumber="120"
validate:minNumber="24"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="72"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
android:key="@string/key_statuslights_cage_critical"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/statuslights_cage_critical"
validate:maxNumber="120"
validate:minNumber="24"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="72"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
android:key="@string/key_statuslights_iage_warning"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/statuslights_iage_warning"
validate:maxNumber="240"
validate:minNumber="24"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="144"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
android:key="@string/key_statuslights_iage_critical"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/statuslights_iage_critical"
validate:maxNumber="240"
validate:minNumber="24"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="216"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
android:key="@string/key_statuslights_sage_warning"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/statuslights_sage_warning"
validate:maxNumber="720"
validate:minNumber="24"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="240"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
android:key="@string/key_statuslights_sage_critical"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/statuslights_sage_critical"
validate:maxNumber="720"
validate:minNumber="24"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="216"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
android:key="@string/key_statuslights_bage_warning"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/statuslights_bage_warning"
validate:maxNumber="1000"
validate:minNumber="24"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="240"
android:dependency="@string/key_show_statuslights"
android:inputType="numberSigned"
android:key="@string/key_statuslights_bage_critical"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/statuslights_bage_critical"
validate:maxNumber="1000"
validate:minNumber="24"
validate:testType="numericRange" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="80"
@ -360,6 +438,37 @@
validate:minNumber="0"
validate:testType="numericRange" />
<Preference
android:key="@string/key_statuslights_copy_ns"
android:dependency="@string/key_show_statuslights"
android:title="@string/statuslights_copy_ns">
</Preference>
</androidx.preference.PreferenceScreen>
<androidx.preference.PreferenceScreen
android:key="overview_advanced"
android:title="@string/advancedsettings_title">
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="100"
android:dialogMessage="@string/deliverpartofboluswizard"
android:inputType="number"
android:key="@string/key_boluswizard_percentage"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/partialboluswizard"
validate:maxNumber="100"
validate:minNumber="10"
validate:testType="numericRange" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_usesuperbolus"
android:summary="@string/enablesuperbolus_summary"
android:title="@string/enablesuperbolus" />
</androidx.preference.PreferenceScreen>
</PreferenceCategory>

View file

@ -149,12 +149,10 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
objectivesPlugin.objectives[ObjectivesPlugin.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0
var c: Constraint<Boolean> = constraintChecker.isClosedLoopAllowed()
Assert.assertEquals(true, c.reasonList.size == 2) // Safety & Objectives
Assert.assertEquals(true, c.mostLimitedReasonList.size == 2) // Safety & Objectives
Assert.assertEquals(false, c.value())
`when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("open")
c = constraintChecker.isClosedLoopAllowed()
Assert.assertEquals(true, c.reasonList.size == 3) // 2x Safety & Objectives
Assert.assertEquals(true, c.mostLimitedReasonList.size == 3) // 2x Safety & Objectives
Assert.assertEquals(false, c.value())
}