virtual pump status upload optional
This commit is contained in:
parent
e00045155e
commit
8001796f4b
5 changed files with 30 additions and 1 deletions
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.plugins.DanaR.BluetoothDevicePreference;
|
|||
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpPlugin;
|
||||
import info.nightscout.utils.LocaleHelper;
|
||||
|
||||
public class PreferencesActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
@ -104,6 +105,10 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
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)
|
||||
addPreferencesFromResource(R.xml.pref_smscommunicator);
|
||||
addPreferencesFromResource(R.xml.pref_others);
|
||||
|
|
|
@ -969,7 +969,10 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
}
|
||||
if (activePump != null) {
|
||||
deviceStatus.device = "openaps://" + deviceID();
|
||||
deviceStatus.pump = getJSONStatus();
|
||||
JSONObject pumpstatus = getJSONStatus();
|
||||
if (pumpstatus != null) {
|
||||
deviceStatus.pump = getJSONStatus();
|
||||
}
|
||||
|
||||
deviceStatus.created_at = DateUtil.toISOString(new Date());
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package info.nightscout.androidaps.plugins.VirtualPump;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -401,6 +403,10 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
|
||||
@Override
|
||||
public JSONObject getJSONStatus() {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
if (!preferences.getBoolean("virtualpump_uploadstatus", false)) {
|
||||
return null;
|
||||
}
|
||||
JSONObject pump = new JSONObject();
|
||||
JSONObject battery = new JSONObject();
|
||||
JSONObject status = new JSONObject();
|
||||
|
|
|
@ -501,4 +501,6 @@
|
|||
<string name="updatingbasalrates">Updating basal rates</string>
|
||||
<string name="disconnecting">Disconnecting</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>
|
||||
|
|
13
app/src/main/res/xml/pref_virtualpump.xml
Normal file
13
app/src/main/res/xml/pref_virtualpump.xml
Normal 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>
|
Loading…
Reference in a new issue