Allow configuring pump type in NSClient

This commit is contained in:
Milos Kozak 2020-10-25 23:10:09 +01:00
parent 08b363b6a5
commit b4ff088974
6 changed files with 15 additions and 6 deletions

View file

@ -175,7 +175,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
addPreferencesFromResourceIfEnabled(localInsightPlugin, rootKey, config.PUMPDRIVERS) addPreferencesFromResourceIfEnabled(localInsightPlugin, rootKey, config.PUMPDRIVERS)
addPreferencesFromResourceIfEnabled(comboPlugin, rootKey, config.PUMPDRIVERS) addPreferencesFromResourceIfEnabled(comboPlugin, rootKey, config.PUMPDRIVERS)
addPreferencesFromResourceIfEnabled(medtronicPumpPlugin, rootKey, config.PUMPDRIVERS) addPreferencesFromResourceIfEnabled(medtronicPumpPlugin, rootKey, config.PUMPDRIVERS)
addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey, !config.NSCLIENT) addPreferencesFromResourceIfEnabled(virtualPumpPlugin, rootKey)
addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey) addPreferencesFromResourceIfEnabled(insulinOrefFreePeakPlugin, rootKey)
addPreferencesFromResourceIfEnabled(nsClientPlugin, rootKey) addPreferencesFromResourceIfEnabled(nsClientPlugin, rootKey)
addPreferencesFromResourceIfEnabled(tidepoolPlugin, rootKey) addPreferencesFromResourceIfEnabled(tidepoolPlugin, rootKey)

View file

@ -48,7 +48,7 @@ public class Objective0 extends Objective {
tasks.add(new Task(R.string.virtualpump_uploadstatus_title) { tasks.add(new Task(R.string.virtualpump_uploadstatus_title) {
@Override @Override
public boolean isCompleted() { public boolean isCompleted() {
return sp.getBoolean("virtualpump_uploadstatus", false); return sp.getBoolean(R.string.key_virtualpump_uploadstatus, false);
} }
@Override @Override

View file

@ -185,7 +185,7 @@ private val allowedKeys = """
tidepool_only_while_charging tidepool_only_while_charging
tidepool_only_while_unmetered tidepool_only_while_unmetered
virtualpump virtualpump
virtualpump_uploadstatus key_virtualpump_uploadstatus
virtualpump_type virtualpump_type
wearplugin wearplugin
wearcontrol wearcontrol

View file

@ -1,6 +1,8 @@
package info.nightscout.androidaps.plugins.pump.virtual package info.nightscout.androidaps.plugins.pump.virtual
import android.os.SystemClock import android.os.SystemClock
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
@ -59,7 +61,6 @@ class VirtualPumpPlugin @Inject constructor(
.pluginName(R.string.virtualpump) .pluginName(R.string.virtualpump)
.shortName(R.string.virtualpump_shortname) .shortName(R.string.virtualpump_shortname)
.preferencesId(R.xml.pref_virtualpump) .preferencesId(R.xml.pref_virtualpump)
.neverVisible(config.NSCLIENT)
.description(R.string.description_pump_virtual) .description(R.string.description_pump_virtual)
.setDefault(), .setDefault(),
injector, aapsLogger, resourceHelper, commandQueue injector, aapsLogger, resourceHelper, commandQueue
@ -120,6 +121,13 @@ class VirtualPumpPlugin @Inject constructor(
super.onStop() super.onStop()
} }
override fun preprocessPreferences(preferenceFragment: PreferenceFragmentCompat) {
super.preprocessPreferences(preferenceFragment)
val uploadStatus = preferenceFragment.findPreference(resourceHelper.gs(R.string.key_virtualpump_uploadstatus)) as SwitchPreference?
?: return
uploadStatus.isVisible = !config.NSCLIENT
}
override fun isFakingTempsByExtendedBoluses(): Boolean { override fun isFakingTempsByExtendedBoluses(): Boolean {
return config.NSCLIENT && getFakingStatus() return config.NSCLIENT && getFakingStatus()
} }
@ -332,7 +340,7 @@ class VirtualPumpPlugin @Inject constructor(
override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject { override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject {
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
if (!sp.getBoolean("virtualpump_uploadstatus", false)) { if (!sp.getBoolean(R.string.key_virtualpump_uploadstatus, false)) {
return JSONObject() return JSONObject()
} }
val pump = JSONObject() val pump = JSONObject()

View file

@ -921,6 +921,7 @@
<string name="openapsama_current_basal_safety_multiplier">Current basal safety multiplier</string> <string name="openapsama_current_basal_safety_multiplier">Current basal safety multiplier</string>
<string name="value_unavailable_short">n/a</string> <string name="value_unavailable_short">n/a</string>
<string name="key_virtualpump_type" translatable="false">virtualpump_type</string> <string name="key_virtualpump_type" translatable="false">virtualpump_type</string>
<string name="key_virtualpump_uploadstatus" translatable="false">virtualpump_uploadstatus</string>
<string name="virtualpump_type">Virtual Pump Type</string> <string name="virtualpump_type">Virtual Pump Type</string>
<string name="virtualpump_definition">Pump Definition</string> <string name="virtualpump_definition">Pump Definition</string>
<string name="virtualpump_pump_def">Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s</string> <string name="virtualpump_pump_def">Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s</string>

View file

@ -15,7 +15,7 @@
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="virtualpump_uploadstatus" android:key="@string/key_virtualpump_uploadstatus"
android:title="@string/virtualpump_uploadstatus_title" /> android:title="@string/virtualpump_uploadstatus_title" />
</PreferenceCategory> </PreferenceCategory>