Set defaults on profile selection and new day only
This commit is contained in:
parent
40e6ebc44a
commit
a33bdb6bff
|
@ -103,7 +103,7 @@ class AutotuneFragment : DaggerFragment() {
|
||||||
days.view?.setSelectedDays(days.getSelectedDays())
|
days.view?.setSelectedDays(days.getSelectedDays())
|
||||||
else {
|
else {
|
||||||
days.set(InputWeekDay.DayOfWeek.fromCalendarInt(i), selected)
|
days.set(InputWeekDay.DayOfWeek.fromCalendarInt(i), selected)
|
||||||
resetParam()
|
resetParam(false)
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class AutotuneFragment : DaggerFragment() {
|
||||||
profile = ATProfile(profileStore.getSpecificProfile(profileName)?.let { ProfileSealed.Pure(it) } ?: currentProfile, LocalInsulin(""), injector)
|
profile = ATProfile(profileStore.getSpecificProfile(profileName)?.let { ProfileSealed.Pure(it) } ?: currentProfile, LocalInsulin(""), injector)
|
||||||
}
|
}
|
||||||
autotunePlugin.selectedProfile = profileName
|
autotunePlugin.selectedProfile = profileName
|
||||||
resetParam()
|
resetParam(true)
|
||||||
}
|
}
|
||||||
updateGui()
|
updateGui()
|
||||||
}
|
}
|
||||||
|
@ -364,10 +364,8 @@ class AutotuneFragment : DaggerFragment() {
|
||||||
val runToday = autotunePlugin.lastRun > MidnightTime.calc(dateUtil.now() - autotunePlugin.autotuneStartHour * 3600 * 1000L) + autotunePlugin.autotuneStartHour * 3600 * 1000L
|
val runToday = autotunePlugin.lastRun > MidnightTime.calc(dateUtil.now() - autotunePlugin.autotuneStartHour * 3600 * 1000L) + autotunePlugin.autotuneStartHour * 3600 * 1000L
|
||||||
if (runToday && autotunePlugin.result != "") {
|
if (runToday && autotunePlugin.result != "") {
|
||||||
binding.tuneWarning.text = rh.gs(R.string.autotune_warning_after_run)
|
binding.tuneWarning.text = rh.gs(R.string.autotune_warning_after_run)
|
||||||
} else if (!runToday || autotunePlugin.result.isEmpty()) { //if new day re-init result, default days, warning and button's visibility
|
} else if (!runToday || autotunePlugin.result.isEmpty()) //if new day re-init result, default days, warning and button's visibility
|
||||||
resetParam(!runToday)
|
resetParam(!runToday)
|
||||||
days.setAll(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addWarnings(): String {
|
private fun addWarnings(): String {
|
||||||
|
@ -392,10 +390,12 @@ class AutotuneFragment : DaggerFragment() {
|
||||||
return warning
|
return warning
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resetParam(resetDay: Boolean = true) {
|
private fun resetParam(resetDay: Boolean) {
|
||||||
binding.tuneWarning.text = addWarnings()
|
binding.tuneWarning.text = addWarnings()
|
||||||
if (resetDay)
|
if (resetDay) {
|
||||||
autotunePlugin.lastNbDays = sp.getInt(R.string.key_autotune_default_tune_days, 5).toString()
|
autotunePlugin.lastNbDays = sp.getInt(R.string.key_autotune_default_tune_days, 5).toString()
|
||||||
|
days.setAll(true)
|
||||||
|
}
|
||||||
autotunePlugin.result = ""
|
autotunePlugin.result = ""
|
||||||
binding.autotuneResults.removeAllViews()
|
binding.autotuneResults.removeAllViews()
|
||||||
autotunePlugin.tunedProfile = null
|
autotunePlugin.tunedProfile = null
|
||||||
|
|
Loading…
Reference in a new issue