Manual button hidden, Cancel only if TT running, Spinner added
Long Click removed for Cancel and Spinner don't update values
This commit is contained in:
parent
ef1fa6b7d1
commit
c6e8f277c0
2 changed files with 74 additions and 30 deletions
|
@ -13,6 +13,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.db.Source
|
import info.nightscout.androidaps.db.Source
|
||||||
import info.nightscout.androidaps.db.TempTarget
|
import info.nightscout.androidaps.db.TempTarget
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
@ -32,8 +33,9 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
var reason = ""
|
lateinit var reasonList: List<String>
|
||||||
|
|
||||||
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
override fun onSaveInstanceState(savedInstanceState: Bundle) {
|
||||||
super.onSaveInstanceState(savedInstanceState)
|
super.onSaveInstanceState(savedInstanceState)
|
||||||
|
@ -67,34 +69,51 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
val units = profileFunction.getUnits()
|
val units = profileFunction.getUnits()
|
||||||
overview_temptarget_units.text = if (units == Constants.MMOL) resourceHelper.gs(R.string.mmol) else resourceHelper.gs(R.string.mgdl)
|
overview_temptarget_units.text = if (units == Constants.MMOL) resourceHelper.gs(R.string.mmol) else resourceHelper.gs(R.string.mgdl)
|
||||||
|
|
||||||
reason = resourceHelper.gs(R.string.manual)
|
// temp target
|
||||||
|
context?.let { context ->
|
||||||
|
if (activePlugin.activeTreatments.tempTargetFromHistory != null)
|
||||||
|
overview_temptarget_cancel?.visibility = View.VISIBLE
|
||||||
|
else
|
||||||
|
overview_temptarget_cancel?.visibility = View.GONE
|
||||||
|
|
||||||
overview_temptarget_custom?.setOnClickListener {
|
reasonList = Lists.newArrayList(
|
||||||
overview_temptarget_temptarget.value = savedInstanceState?.getDouble("overview_temptarget_temptarget") ?: if (profileFunction.getUnits() == Constants.MMOL) Constants.MIN_TT_MMOL else Constants.MIN_TT_MGDL
|
resourceHelper.gs(R.string.manual),
|
||||||
overview_temptarget_duration.value = savedInstanceState?.getDouble("overview_temptarget_duration") ?: 0.0
|
resourceHelper.gs(R.string.eatingsoon),
|
||||||
reason = resourceHelper.gs(R.string.manual)
|
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_cancel?.setOnClickListener { shortClick(it) }
|
overview_temptarget_custom?.setOnClickListener {
|
||||||
overview_temptarget_eating_soon?.setOnClickListener { shortClick(it) }
|
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_activity?.setOnClickListener { shortClick(it) }
|
overview_temptarget_duration.value = savedInstanceState?.getDouble("overview_temptarget_duration") ?: 0.0
|
||||||
overview_temptarget_hypo?.setOnClickListener { shortClick(it) }
|
overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.manual)));
|
||||||
|
}
|
||||||
|
|
||||||
overview_temptarget_cancel?.setOnLongClickListener {
|
overview_temptarget_cancel?.setOnClickListener { shortClick(it) }
|
||||||
longClick(it)
|
overview_temptarget_eating_soon?.setOnClickListener { shortClick(it) }
|
||||||
return@setOnLongClickListener true
|
overview_temptarget_activity?.setOnClickListener { shortClick(it) }
|
||||||
}
|
overview_temptarget_hypo?.setOnClickListener { shortClick(it) }
|
||||||
overview_temptarget_eating_soon?.setOnLongClickListener {
|
/*
|
||||||
longClick(it)
|
overview_temptarget_cancel?.setOnLongClickListener {
|
||||||
return@setOnLongClickListener true
|
longClick(it)
|
||||||
}
|
return@setOnLongClickListener true
|
||||||
overview_temptarget_activity?.setOnLongClickListener {
|
}
|
||||||
longClick(it)
|
|
||||||
return@setOnLongClickListener true
|
*/
|
||||||
}
|
overview_temptarget_eating_soon?.setOnLongClickListener {
|
||||||
overview_temptarget_hypo?.setOnLongClickListener {
|
longClick(it)
|
||||||
longClick(it)
|
return@setOnLongClickListener true
|
||||||
return@setOnLongClickListener true
|
}
|
||||||
|
overview_temptarget_activity?.setOnLongClickListener {
|
||||||
|
longClick(it)
|
||||||
|
return@setOnLongClickListener true
|
||||||
|
}
|
||||||
|
overview_temptarget_hypo?.setOnLongClickListener {
|
||||||
|
longClick(it)
|
||||||
|
return@setOnLongClickListener true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,28 +127,29 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
R.id.overview_temptarget_cancel -> {
|
R.id.overview_temptarget_cancel -> {
|
||||||
overview_temptarget_temptarget.value = 0.0
|
overview_temptarget_temptarget.value = 0.0
|
||||||
overview_temptarget_duration.value = 0.0
|
overview_temptarget_duration.value = 0.0
|
||||||
reason = resourceHelper.gs(R.string.cancel)
|
overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.cancel)))
|
||||||
}
|
}
|
||||||
R.id.overview_temptarget_eating_soon -> {
|
R.id.overview_temptarget_eating_soon -> {
|
||||||
overview_temptarget_temptarget.value = defaultValueHelper.determineEatingSoonTT()
|
overview_temptarget_temptarget.value = defaultValueHelper.determineEatingSoonTT()
|
||||||
overview_temptarget_duration.value = defaultValueHelper.determineEatingSoonTTDuration().toDouble()
|
overview_temptarget_duration.value = defaultValueHelper.determineEatingSoonTTDuration().toDouble()
|
||||||
reason = resourceHelper.gs(R.string.eatingsoon)
|
overview_temptarget_reason.setSelection(reasonList.indexOf( resourceHelper.gs(R.string.eatingsoon)))
|
||||||
}
|
}
|
||||||
R.id.overview_temptarget_activity -> {
|
R.id.overview_temptarget_activity -> {
|
||||||
overview_temptarget_temptarget.value = defaultValueHelper.determineActivityTT()
|
overview_temptarget_temptarget.value = defaultValueHelper.determineActivityTT()
|
||||||
overview_temptarget_duration.value = defaultValueHelper.determineActivityTTDuration().toDouble()
|
overview_temptarget_duration.value = defaultValueHelper.determineActivityTTDuration().toDouble()
|
||||||
reason = resourceHelper.gs(R.string.activity)
|
overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.activity)))
|
||||||
}
|
}
|
||||||
R.id.overview_temptarget_hypo -> {
|
R.id.overview_temptarget_hypo -> {
|
||||||
overview_temptarget_temptarget.value = defaultValueHelper.determineHypoTT()
|
overview_temptarget_temptarget.value = defaultValueHelper.determineHypoTT()
|
||||||
overview_temptarget_duration.value = defaultValueHelper.determineHypoTTDuration().toDouble()
|
overview_temptarget_duration.value = defaultValueHelper.determineHypoTTDuration().toDouble()
|
||||||
reason = resourceHelper.gs(R.string.hypo)
|
overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.hypo)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun submit(): Boolean {
|
override fun submit(): Boolean {
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
|
val reason = overview_temptarget_reason?.selectedItem?.toString() ?: return false
|
||||||
val unitResId = if (profileFunction.getUnits() == Constants.MGDL) R.string.mgdl else R.string.mmol
|
val unitResId = if (profileFunction.getUnits() == Constants.MGDL) R.string.mgdl else R.string.mmol
|
||||||
val target = overview_temptarget_temptarget.value
|
val target = overview_temptarget_temptarget.value
|
||||||
val duration = overview_temptarget_duration.value.toInt()
|
val duration = overview_temptarget_duration.value.toInt()
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
android:text="@string/manual"
|
android:text="@string/manual"
|
||||||
android:textColor="@color/tempTargetConfirmation"
|
android:textColor="@color/tempTargetConfirmation"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||||
|
android:visibility="gone"
|
||||||
android:textSize="11sp" />
|
android:textSize="11sp" />
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.ui.SingleClickButton
|
<info.nightscout.androidaps.utils.ui.SingleClickButton
|
||||||
|
@ -197,6 +198,29 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:width="120dp"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="@string/reason"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/overview_temptarget_reason"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<include layout="@layout/datetime" />
|
<include layout="@layout/datetime" />
|
||||||
|
|
||||||
<include layout="@layout/okcancel" />
|
<include layout="@layout/okcancel" />
|
||||||
|
|
Loading…
Reference in a new issue