From 9cec7282341e3f676ef6402e0dcfaa0f3810b405 Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 5 May 2022 23:27:07 +0200 Subject: [PATCH] Automation Day selection (duration) and Active profile selection for Autotune --- .../plugins/general/automation/elements/InputDuration.kt | 5 ++++- .../plugins/general/automation/elements/InputProfileName.kt | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt index 6e275190e9..05dc3ef41b 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt @@ -13,7 +13,7 @@ class InputDuration( ) : Element() { enum class TimeUnit { - MINUTES, HOURS + MINUTES, HOURS, DAYS } override fun addToLayout(root: LinearLayout) { @@ -21,6 +21,9 @@ class InputDuration( if (unit == TimeUnit.MINUTES) { numberPicker = MinutesNumberPicker(root.context, null) numberPicker.setParams(value.toDouble(), 5.0, 24 * 60.0, 10.0, DecimalFormat("0"), false, root.findViewById(R.id.ok)) + } else if (unit == TimeUnit.DAYS) { + numberPicker = MinutesNumberPicker(root.context, null) + numberPicker.setParams(value.toDouble(), 1.0, 30.0, 1.0, DecimalFormat("0"), false, root.findViewById(R.id.ok)) } else { numberPicker = NumberPicker(root.context, null) numberPicker.setParams(value.toDouble(), 1.0, 24.0, 1.0, DecimalFormat("0"), false, root.findViewById(R.id.ok)) diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt index 14f6bf46c7..9cdac1b01e 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt @@ -10,14 +10,15 @@ import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ResourceHelper -class InputProfileName(private val rh: ResourceHelper, private val activePlugin: ActivePlugin, val name: String = "") : Element() { +class InputProfileName(private val rh: ResourceHelper, private val activePlugin: ActivePlugin, val name: String = "", val addActive: Boolean = false) : Element() { var value: String = name override fun addToLayout(root: LinearLayout) { val profileStore = activePlugin.activeProfileSource.profile ?: return val profileList = profileStore.getProfileList() - + if (addActive) + profileList.add(0, rh.gs(R.string.active)) root.addView( Spinner(root.context).apply { adapter = ArrayAdapter(root.context, R.layout.spinner_centered, profileList).apply {