virtual pump status upload optional

This commit is contained in:
Milos Kozak 2017-02-14 15:41:30 +01:00
parent e00045155e
commit 8001796f4b
5 changed files with 30 additions and 1 deletions

View file

@ -19,6 +19,7 @@ import info.nightscout.androidaps.plugins.DanaR.BluetoothDevicePreference;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin; import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin;
import info.nightscout.utils.LocaleHelper; import info.nightscout.utils.LocaleHelper;
public class PreferencesActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener { public class PreferencesActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -104,6 +105,10 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_danarprofile); addPreferencesFromResource(R.xml.pref_danarprofile);
} }
} }
VirtualPumpPlugin virtualPumpPlugin = (VirtualPumpPlugin) MainApp.getSpecificPlugin(VirtualPumpPlugin.class);
if (virtualPumpPlugin != null && virtualPumpPlugin.isEnabled(PluginBase.PUMP)) {
addPreferencesFromResource(R.xml.pref_virtualpump);
}
if (Config.SMSCOMMUNICATORENABLED) if (Config.SMSCOMMUNICATORENABLED)
addPreferencesFromResource(R.xml.pref_smscommunicator); addPreferencesFromResource(R.xml.pref_smscommunicator);
addPreferencesFromResource(R.xml.pref_others); addPreferencesFromResource(R.xml.pref_others);

View file

@ -969,7 +969,10 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} }
if (activePump != null) { if (activePump != null) {
deviceStatus.device = "openaps://" + deviceID(); deviceStatus.device = "openaps://" + deviceID();
JSONObject pumpstatus = getJSONStatus();
if (pumpstatus != null) {
deviceStatus.pump = getJSONStatus(); deviceStatus.pump = getJSONStatus();
}
deviceStatus.created_at = DateUtil.toISOString(new Date()); deviceStatus.created_at = DateUtil.toISOString(new Date());

View file

@ -1,6 +1,8 @@
package info.nightscout.androidaps.plugins.VirtualPump; package info.nightscout.androidaps.plugins.VirtualPump;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -401,6 +403,10 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override @Override
public JSONObject getJSONStatus() { public JSONObject getJSONStatus() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
if (!preferences.getBoolean("virtualpump_uploadstatus", false)) {
return null;
}
JSONObject pump = new JSONObject(); JSONObject pump = new JSONObject();
JSONObject battery = new JSONObject(); JSONObject battery = new JSONObject();
JSONObject status = new JSONObject(); JSONObject status = new JSONObject();

View file

@ -501,4 +501,6 @@
<string name="updatingbasalrates">Updating basal rates</string> <string name="updatingbasalrates">Updating basal rates</string>
<string name="disconnecting">Disconnecting</string> <string name="disconnecting">Disconnecting</string>
<string name="executing">Executing</string> <string name="executing">Executing</string>
<string name="virtualpump_settings">Virtual pump settings</string>
<string name="virtualpump_uploadstatus_title">Upload status to NS</string>
</resources> </resources>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="virtualpump"
android:title="@string/virtualpump_settings">
<SwitchPreference
android:defaultValue="false"
android:key="virtualpump_uploadstatus"
android:title="@string/virtualpump_uploadstatus_title" />
</PreferenceCategory>
</PreferenceScreen>