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..fc3b910602 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -65,14 +65,14 @@ 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 + val reasonList: List = 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) + ) context?.let { context -> - val reasonList: List = 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 { @@ -101,8 +101,8 @@ class TempTargetDialog : DialogFragmentWithDate() { } else -> { - defaultDuration = overview_temptarget_duration.value - defaultTarget = overview_temptarget_temptarget.value + defaultDuration = savedInstanceState?.getDouble("overview_temptarget_duration") ?: 0.0 + defaultTarget = savedInstanceState?.getDouble("overview_temptarget_temptarget") ?: if (profileFunction.getUnits() == Constants.MMOL) Constants.MIN_TT_MMOL else Constants.MIN_TT_MGDL } } overview_temptarget_temptarget.value = defaultTarget @@ -112,6 +112,32 @@ class TempTargetDialog : DialogFragmentWithDate() { override fun onNothingSelected(parent: AdapterView<*>?) {} } } + + 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))); + } + overview_temptarget_cancel?.setOnClickListener { + overview_temptarget_temptarget.value = 0.0 + overview_temptarget_duration.value = 0.0 + overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.cancel))); + } + overview_temptarget_eating_soon?.setOnClickListener { + overview_temptarget_temptarget.value = defaultValueHelper.determineEatingSoonTT() + overview_temptarget_duration.value = defaultValueHelper.determineEatingSoonTTDuration().toDouble() + overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.eatingsoon))); + } + overview_temptarget_activity?.setOnClickListener { + overview_temptarget_temptarget.value = defaultValueHelper.determineActivityTT() + overview_temptarget_duration.value = defaultValueHelper.determineActivityTTDuration().toDouble() + overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.activity))); + } + overview_temptarget_hypo?.setOnClickListener { + overview_temptarget_temptarget.value = defaultValueHelper.determineHypoTT() + overview_temptarget_duration.value = defaultValueHelper.determineHypoTTDuration().toDouble() + overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.hypo))); + } } override fun submit(): Boolean { 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/layout/dialog_temptarget.xml b/app/src/main/res/layout/dialog_temptarget.xml index f770f8ba98..9db270caad 100644 --- a/app/src/main/res/layout/dialog_temptarget.xml +++ b/app/src/main/res/layout/dialog_temptarget.xml @@ -71,6 +71,48 @@ + + + + + + + + + + + + + + #77dd77 #77dd77 + #67DFE8 #779ECB 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 @@ + + + + + + + +