Remove unsupported options (nano), saner defaults

This commit is contained in:
jbr7rr 2023-08-12 15:18:23 +02:00
parent d72444bfc5
commit 3b0ac0b1cb
3 changed files with 37 additions and 16 deletions

View file

@ -7,6 +7,7 @@ import android.content.ServiceConnection
import android.os.IBinder import android.os.IBinder
import android.text.format.DateFormat import android.text.format.DateFormat
import androidx.preference.EditTextPreference import androidx.preference.EditTextPreference
import androidx.preference.ListPreference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
@ -122,8 +123,29 @@ import kotlin.math.abs
override fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) { override fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) {
super.preprocessPreferences(preferenceFragment) super.preprocessPreferences(preferenceFragment)
val serialSetting = preferenceFragment.findPreference(rh.gs(R.string.key_sn_input)) as EditTextPreference? preferenceFragment.findPreference<EditTextPreference>(rh.gs(R.string.key_sn_input))?.isEnabled = !isInitialized()
serialSetting?.isEnabled = !isInitialized()
val alarmSetting = preferenceFragment.findPreference<ListPreference>(rh.gs(R.string.key_alarm_setting))
val allAlarmEntries = preferenceFragment.resources.getStringArray(R.array.alarmSettings)
val allAlarmValues = preferenceFragment.resources.getStringArray(R.array.alarmSettingsValues)
if (allAlarmEntries.size < 8 || allAlarmValues.size < 8) {
aapsLogger.error(LTag.PUMP, "Alarm settings array is not complete")
return
}
when (medtrumPump.pumpType()) {
PumpType.MEDTRUM_NANO -> {
alarmSetting?.entries = arrayOf(allAlarmEntries[6], allAlarmEntries[7]) // "Beep", "Silent"
alarmSetting?.entryValues = arrayOf(allAlarmValues[6], allAlarmValues[7]) // "6", "7"
}
else -> {
// Use Nano settings for unknown pumps
alarmSetting?.entries = arrayOf(allAlarmEntries[6], allAlarmEntries[7]) // "Beep", "Silent"
alarmSetting?.entryValues = arrayOf(allAlarmValues[6], allAlarmValues[7]) // "6", "7"
}
}
} }
override fun isInitialized(): Boolean { override fun isInitialized(): Boolean {

View file

@ -1,20 +1,19 @@
<resources> <resources>
<string-array name="alarmSettings"> <string-array name="alarmSettings">
<!-- Nano doesnt have lights, other patches not yet supported --> <item>Light, vibrate and beep</item>
<!-- <item>Light, vibrate and beep</item> --> <item>Light and vibrate</item>
<!-- <item>Light and vibrate</item> --> <item>Light and beep</item>
<!-- <item>Light and beep</item> --> <item>Light only</item>
<!-- <item>Light only</item> -->
<item>Vibrate and beep</item> <item>Vibrate and beep</item>
<item>Vibrate only</item> <item>Vibrate only</item>
<item>Beep only</item> <item>Beep</item>
<item>None</item> <item>Silent</item>
</string-array> </string-array>
<string-array name="alarmSettingsValues" translatable="false"> <string-array name="alarmSettingsValues" translatable="false">
<!-- <item>0</item> --> <item>0</item>
<!-- <item>1</item> --> <item>1</item>
<!-- <item>2</item> --> <item>2</item>
<!-- <item>3</item> --> <item>3</item>
<item>4</item> <item>4</item>
<item>5</item> <item>5</item>
<item>6</item> <item>6</item>

View file

@ -20,7 +20,7 @@
android:summary="@string/patch_expiration_summary" /> android:summary="@string/patch_expiration_summary" />
<ListPreference <ListPreference
android:defaultValue="4" android:defaultValue="6"
android:key="@string/key_alarm_setting" android:key="@string/key_alarm_setting"
android:title="@string/alarm_setting_title" android:title="@string/alarm_setting_title"
android:dialogTitle="@string/alarm_setting_summary" android:dialogTitle="@string/alarm_setting_summary"
@ -28,7 +28,7 @@
android:entryValues="@array/alarmSettingsValues" /> android:entryValues="@array/alarmSettingsValues" />
<info.nightscout.core.validators.ValidatingEditTextPreference <info.nightscout.core.validators.ValidatingEditTextPreference
android:defaultValue="30" android:defaultValue="25"
android:inputType="number" android:inputType="number"
android:key="@string/key_hourly_max_insulin" android:key="@string/key_hourly_max_insulin"
android:title="@string/hourly_max_insulin_title" android:title="@string/hourly_max_insulin_title"
@ -38,7 +38,7 @@
validate:testType="numericRange" /> validate:testType="numericRange" />
<info.nightscout.core.validators.ValidatingEditTextPreference <info.nightscout.core.validators.ValidatingEditTextPreference
android:defaultValue="100" android:defaultValue="80"
android:inputType="number" android:inputType="number"
android:key="@string/key_daily_max_insulin" android:key="@string/key_daily_max_insulin"
android:title="@string/daily_max_insulin_title" android:title="@string/daily_max_insulin_title"