Remove unsupported options (nano), saner defaults
This commit is contained in:
parent
d72444bfc5
commit
3b0ac0b1cb
3 changed files with 37 additions and 16 deletions
|
@ -7,6 +7,7 @@ import android.content.ServiceConnection
|
|||
import android.os.IBinder
|
||||
import android.text.format.DateFormat
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.core.ui.toast.ToastUtils
|
||||
|
@ -122,8 +123,29 @@ import kotlin.math.abs
|
|||
|
||||
override fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) {
|
||||
super.preprocessPreferences(preferenceFragment)
|
||||
val serialSetting = preferenceFragment.findPreference(rh.gs(R.string.key_sn_input)) as EditTextPreference?
|
||||
serialSetting?.isEnabled = !isInitialized()
|
||||
preferenceFragment.findPreference<EditTextPreference>(rh.gs(R.string.key_sn_input))?.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 {
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
<resources>
|
||||
<string-array name="alarmSettings">
|
||||
<!-- Nano doesnt have lights, other patches not yet supported -->
|
||||
<!-- <item>Light, vibrate and beep</item> -->
|
||||
<!-- <item>Light and vibrate</item> -->
|
||||
<!-- <item>Light and beep</item> -->
|
||||
<!-- <item>Light only</item> -->
|
||||
<item>Light, vibrate and beep</item>
|
||||
<item>Light and vibrate</item>
|
||||
<item>Light and beep</item>
|
||||
<item>Light only</item>
|
||||
<item>Vibrate and beep</item>
|
||||
<item>Vibrate only</item>
|
||||
<item>Beep only</item>
|
||||
<item>None</item>
|
||||
<item>Beep</item>
|
||||
<item>Silent</item>
|
||||
</string-array>
|
||||
<string-array name="alarmSettingsValues" translatable="false">
|
||||
<!-- <item>0</item> -->
|
||||
<!-- <item>1</item> -->
|
||||
<!-- <item>2</item> -->
|
||||
<!-- <item>3</item> -->
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
android:summary="@string/patch_expiration_summary" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="4"
|
||||
android:defaultValue="6"
|
||||
android:key="@string/key_alarm_setting"
|
||||
android:title="@string/alarm_setting_title"
|
||||
android:dialogTitle="@string/alarm_setting_summary"
|
||||
|
@ -28,7 +28,7 @@
|
|||
android:entryValues="@array/alarmSettingsValues" />
|
||||
|
||||
<info.nightscout.core.validators.ValidatingEditTextPreference
|
||||
android:defaultValue="30"
|
||||
android:defaultValue="25"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_hourly_max_insulin"
|
||||
android:title="@string/hourly_max_insulin_title"
|
||||
|
@ -38,7 +38,7 @@
|
|||
validate:testType="numericRange" />
|
||||
|
||||
<info.nightscout.core.validators.ValidatingEditTextPreference
|
||||
android:defaultValue="100"
|
||||
android:defaultValue="80"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_daily_max_insulin"
|
||||
android:title="@string/daily_max_insulin_title"
|
||||
|
|
Loading…
Reference in a new issue