make SMB prefs more clear
This commit is contained in:
parent
1edef7fb4e
commit
007df3aab3
|
@ -185,9 +185,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
addPreferencesFromResourceIfEnabled(maintenancePlugin, rootKey)
|
addPreferencesFromResourceIfEnabled(maintenancePlugin, rootKey)
|
||||||
}
|
}
|
||||||
initSummary(preferenceScreen, pluginId != -1)
|
initSummary(preferenceScreen, pluginId != -1)
|
||||||
for (plugin in pluginStore.plugins) {
|
preprocessPreferences()
|
||||||
plugin.preprocessPreferences(this)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||||
|
@ -212,6 +210,13 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
|
||||||
checkForBiometricFallback(key)
|
checkForBiometricFallback(key)
|
||||||
|
|
||||||
updatePrefSummary(findPreference(key))
|
updatePrefSummary(findPreference(key))
|
||||||
|
preprocessPreferences()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun preprocessPreferences() {
|
||||||
|
for (plugin in pluginStore.plugins) {
|
||||||
|
plugin.preprocessPreferences(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForBiometricFallback(key: String) {
|
private fun checkForBiometricFallback(key: String) {
|
||||||
|
|
|
@ -2,6 +2,9 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMB;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
|
@ -42,6 +45,7 @@ import info.nightscout.androidaps.utils.HardLimits;
|
||||||
import info.nightscout.androidaps.utils.Profiler;
|
import info.nightscout.androidaps.utils.Profiler;
|
||||||
import info.nightscout.androidaps.utils.Round;
|
import info.nightscout.androidaps.utils.Round;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, ConstraintsInterface {
|
public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, ConstraintsInterface {
|
||||||
|
@ -56,6 +60,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
private final HardLimits hardLimits;
|
private final HardLimits hardLimits;
|
||||||
private final Profiler profiler;
|
private final Profiler profiler;
|
||||||
private final FabricPrivacy fabricPrivacy;
|
private final FabricPrivacy fabricPrivacy;
|
||||||
|
private final SP sp;
|
||||||
|
|
||||||
// last values
|
// last values
|
||||||
DetermineBasalAdapterSMBJS lastDetermineBasalAdapterSMBJS = null;
|
DetermineBasalAdapterSMBJS lastDetermineBasalAdapterSMBJS = null;
|
||||||
|
@ -77,7 +82,8 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
IobCobCalculatorPlugin iobCobCalculatorPlugin,
|
IobCobCalculatorPlugin iobCobCalculatorPlugin,
|
||||||
HardLimits hardLimits,
|
HardLimits hardLimits,
|
||||||
Profiler profiler,
|
Profiler profiler,
|
||||||
FabricPrivacy fabricPrivacy
|
FabricPrivacy fabricPrivacy,
|
||||||
|
SP sp
|
||||||
) {
|
) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.APS)
|
.mainType(PluginType.APS)
|
||||||
|
@ -100,6 +106,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
this.hardLimits = hardLimits;
|
this.hardLimits = hardLimits;
|
||||||
this.profiler = profiler;
|
this.profiler = profiler;
|
||||||
this.fabricPrivacy = fabricPrivacy;
|
this.fabricPrivacy = fabricPrivacy;
|
||||||
|
this.sp = sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,6 +126,25 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
return pump.getPumpDescription().isTempBasalCapable;
|
return pump.getPumpDescription().isTempBasalCapable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preprocessPreferences(PreferenceFragmentCompat preferenceFragment) {
|
||||||
|
super.preprocessPreferences(preferenceFragment);
|
||||||
|
boolean smbAlwaysEnabled = sp.getBoolean(R.string.key_enableSMB_always, false);
|
||||||
|
|
||||||
|
SwitchPreference withCOB = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_enableSMB_with_COB));
|
||||||
|
if (withCOB != null) {
|
||||||
|
withCOB.setVisible(!smbAlwaysEnabled);
|
||||||
|
}
|
||||||
|
SwitchPreference withTempTarget = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_enableSMB_with_temptarget));
|
||||||
|
if (withTempTarget != null) {
|
||||||
|
withTempTarget.setVisible(!smbAlwaysEnabled);
|
||||||
|
}
|
||||||
|
SwitchPreference afterCarbs = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_enableSMB_after_carbs));
|
||||||
|
if (afterCarbs != null) {
|
||||||
|
afterCarbs.setVisible(!smbAlwaysEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public APSResult getLastAPSResult() {
|
public APSResult getLastAPSResult() {
|
||||||
return lastAPSResult;
|
return lastAPSResult;
|
||||||
|
|
|
@ -761,7 +761,7 @@
|
||||||
<string name="enablesmbwithtemptarget">Enable SMB with temp targets</string>
|
<string name="enablesmbwithtemptarget">Enable SMB with temp targets</string>
|
||||||
<string name="enablesmbwithtemptarget_summary">Enable SMB when there is temp target active (eating soon, exercise)</string>
|
<string name="enablesmbwithtemptarget_summary">Enable SMB when there is temp target active (eating soon, exercise)</string>
|
||||||
<string name="enablesmbwithhightemptarget">Enable SMB with high temp targets</string>
|
<string name="enablesmbwithhightemptarget">Enable SMB with high temp targets</string>
|
||||||
<string name="enablesmbwithhightemptarget_summary">Enable SMB when there is high temp target active (exercise)</string>
|
<string name="enablesmbwithhightemptarget_summary">Enable SMB when there is high temp target active (exercise, above 100 mg/dl or 5.5 mmol/l)</string>
|
||||||
<string name="overview_insulin_label">Insulin</string>
|
<string name="overview_insulin_label">Insulin</string>
|
||||||
<string name="overview_carbs_label">Carbs</string>
|
<string name="overview_carbs_label">Carbs</string>
|
||||||
<string name="overview_buttons_selection">Buttons</string>
|
<string name="overview_buttons_selection">Buttons</string>
|
||||||
|
|
|
@ -38,20 +38,6 @@
|
||||||
android:summary="@string/enablesmb_summary"
|
android:summary="@string/enablesmb_summary"
|
||||||
android:title="@string/enablesmb" />
|
android:title="@string/enablesmb" />
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:dependency="@string/key_use_smb"
|
|
||||||
android:key="@string/key_enableSMB_with_COB"
|
|
||||||
android:summary="@string/enablesmbwithcob_summary"
|
|
||||||
android:title="@string/enablesmbwithcob" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:defaultValue="false"
|
|
||||||
android:dependency="@string/key_use_smb"
|
|
||||||
android:key="@string/key_enableSMB_with_temptarget"
|
|
||||||
android:summary="@string/enablesmbwithtemptarget_summary"
|
|
||||||
android:title="@string/enablesmbwithtemptarget" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:dependency="@string/key_use_smb"
|
android:dependency="@string/key_use_smb"
|
||||||
|
@ -66,6 +52,20 @@
|
||||||
android:summary="@string/enablesmbalways_summary"
|
android:summary="@string/enablesmbalways_summary"
|
||||||
android:title="@string/enablesmbalways" />
|
android:title="@string/enablesmbalways" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:dependency="@string/key_use_smb"
|
||||||
|
android:key="@string/key_enableSMB_with_COB"
|
||||||
|
android:summary="@string/enablesmbwithcob_summary"
|
||||||
|
android:title="@string/enablesmbwithcob" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:dependency="@string/key_use_smb"
|
||||||
|
android:key="@string/key_enableSMB_with_temptarget"
|
||||||
|
android:summary="@string/enablesmbwithtemptarget_summary"
|
||||||
|
android:title="@string/enablesmbwithtemptarget" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:dependency="@string/key_use_smb"
|
android:dependency="@string/key_use_smb"
|
||||||
|
|
Loading…
Reference in a new issue