Merge pull request #1969 from Philoul/Fix/AutotuneKeyboad

Autotune Fix Keyboard input for TuneDays
This commit is contained in:
Milos Kozak 2022-07-30 23:10:01 +02:00 committed by GitHub
commit e635978c1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 7 deletions

View file

@ -115,6 +115,7 @@ class AutotuneFragment : DaggerFragment() {
} }
autotunePlugin.selectedProfile = profileName autotunePlugin.selectedProfile = profileName
resetParam() resetParam()
binding.tuneDays.value = autotunePlugin.lastNbDays.toDouble()
} }
updateGui() updateGui()
} }
@ -275,6 +276,7 @@ class AutotuneFragment : DaggerFragment() {
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ updateGui() }, fabricPrivacy::logException) .subscribe({ updateGui() }, fabricPrivacy::logException)
checkNewDay() checkNewDay()
binding.tuneDays.value = autotunePlugin.lastNbDays.toDouble()
updateGui() updateGui()
} }
@ -287,7 +289,6 @@ class AutotuneFragment : DaggerFragment() {
@Synchronized @Synchronized
private fun updateGui() { private fun updateGui() {
_binding ?: return _binding ?: return
binding.tuneDays.value = autotunePlugin.lastNbDays.toDouble()
profileStore = activePlugin.activeProfileSource.profile ?: ProfileStore(injector, JSONObject(), dateUtil) profileStore = activePlugin.activeProfileSource.profile ?: ProfileStore(injector, JSONObject(), dateUtil)
profileName = if (binding.profileList.text.toString() == rh.gs(R.string.active)) "" else binding.profileList.text.toString() profileName = if (binding.profileList.text.toString() == rh.gs(R.string.active)) "" else binding.profileList.text.toString()
profileFunction.getProfile()?.let { currentProfile -> profileFunction.getProfile()?.let { currentProfile ->
@ -387,7 +388,7 @@ class AutotuneFragment : DaggerFragment() {
try { try {
if (autotunePlugin.calculationRunning) if (autotunePlugin.calculationRunning)
binding.tuneDays.value = autotunePlugin.lastNbDays.toDouble() binding.tuneDays.value = autotunePlugin.lastNbDays.toDouble()
if (binding.tuneDays.value != autotunePlugin.lastNbDays.toDouble()) { if (binding.tuneDays.text != autotunePlugin.lastNbDays) {
autotunePlugin.lastNbDays = binding.tuneDays.text autotunePlugin.lastNbDays = binding.tuneDays.text
resetParam(false) resetParam(false)
} }

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory <PreferenceCategory
android:key="@string/key_autotune_plugin" android:key="@string/key_autotune_plugin"
android:title="@string/autotune_settings" android:title="@string/autotune_settings"
@ -24,12 +26,19 @@
android:summary="@string/autotune_tune_insulin_curve_summary" android:summary="@string/autotune_tune_insulin_curve_summary"
android:title="@string/autotune_tune_insulin_curve_title" /> android:title="@string/autotune_tune_insulin_curve_title" />
--> -->
<EditTextPreference
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="5" android:defaultValue="5"
android:inputType="number"
android:key="@string/key_autotune_default_tune_days" android:key="@string/key_autotune_default_tune_days"
android:summary="@string/autotune_default_tune_days_summary" android:title="@string/autotune_default_tune_days_title"
android:title="@string/autotune_default_tune_days_title" /> android:dialogMessage="@string/autotune_default_tune_days_summary"
android:digits="0123456789"
android:inputType="number"
android:selectAllOnFocus="true"
android:singleLine="true"
validate:maxNumber="30"
validate:minNumber="1"
validate:testType="numericRange" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"