commit
38d1386ad4
14 changed files with 271 additions and 39 deletions
|
@ -37,7 +37,7 @@
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
<!-- Receiver from NSClient -->
|
<!-- Receiver from NSClient -->
|
||||||
<receiver
|
<receiver
|
||||||
android:name="info.nightscout.client.receivers.NSClientDataReceiver"
|
android:name=".receivers.NSClientDataReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
|
@ -27,6 +27,8 @@ import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||||
import info.nightscout.androidaps.plugins.SafetyFragment.SafetyFragment;
|
import info.nightscout.androidaps.plugins.SafetyFragment.SafetyFragment;
|
||||||
import info.nightscout.androidaps.plugins.SimpleProfile.SimpleProfileFragment;
|
import info.nightscout.androidaps.plugins.SimpleProfile.SimpleProfileFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
|
||||||
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsFragment;
|
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsFragment;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||||
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpFragment;
|
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpFragment;
|
||||||
|
@ -73,6 +75,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
pluginsList.add(TempBasalsFragment.newInstance());
|
pluginsList.add(TempBasalsFragment.newInstance());
|
||||||
pluginsList.add(SafetyFragment.newInstance());
|
pluginsList.add(SafetyFragment.newInstance());
|
||||||
pluginsList.add(ObjectivesFragment.newInstance());
|
pluginsList.add(ObjectivesFragment.newInstance());
|
||||||
|
pluginsList.add(SourceXdripFragment.newInstance());
|
||||||
|
pluginsList.add(SourceNSClientFragment.newInstance());
|
||||||
pluginsList.add(configBuilderFragment = ConfigBuilderFragment.newInstance());
|
pluginsList.add(configBuilderFragment = ConfigBuilderFragment.newInstance());
|
||||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
import info.nightscout.client.data.NSSgv;
|
import info.nightscout.client.data.NSSgv;
|
||||||
|
|
||||||
|
@ -297,6 +298,7 @@ public class DataService extends IntentService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intent.getAction().equals(Intents.ACTION_NEW_SGV)) {
|
if (intent.getAction().equals(Intents.ACTION_NEW_SGV)) {
|
||||||
|
if (MainActivity.getConfigBuilder().getActiveBgSource().getClass().equals(SourceNSClientFragment.class)) {
|
||||||
try {
|
try {
|
||||||
if (bundles.containsKey("sgv")) {
|
if (bundles.containsKey("sgv")) {
|
||||||
String sgvstring = bundles.getString("sgv");
|
String sgvstring = bundles.getString("sgv");
|
||||||
|
@ -330,6 +332,7 @@ public class DataService extends IntentService {
|
||||||
MainApp.bus().post(new EventNewBG());
|
MainApp.bus().post(new EventNewBG());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Treatment findById(String _id) {
|
public static Treatment findById(String _id) {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 20.06.2016.
|
||||||
|
*/
|
||||||
|
public interface BgSourceInterface {
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ public interface PluginBase {
|
||||||
int PUMP = 6;
|
int PUMP = 6;
|
||||||
int CONSTRAINTS = 7;
|
int CONSTRAINTS = 7;
|
||||||
int LOOP = 8;
|
int LOOP = 8;
|
||||||
|
int BGSOURCE = 9;
|
||||||
|
|
||||||
public int getType();
|
public int getType();
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
|
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
|
@ -54,6 +55,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
|
|
||||||
private static final String PREFS_NAME = "Settings";
|
private static final String PREFS_NAME = "Settings";
|
||||||
|
|
||||||
|
ListView bgsourceListView;
|
||||||
ListView pumpListView;
|
ListView pumpListView;
|
||||||
ListView loopListView;
|
ListView loopListView;
|
||||||
ListView treatmentsListView;
|
ListView treatmentsListView;
|
||||||
|
@ -63,6 +65,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
ListView constraintsListView;
|
ListView constraintsListView;
|
||||||
ListView generalListView;
|
ListView generalListView;
|
||||||
|
|
||||||
|
PluginCustomAdapter bgsourceDataAdapter = null;
|
||||||
PluginCustomAdapter pumpDataAdapter = null;
|
PluginCustomAdapter pumpDataAdapter = null;
|
||||||
PluginCustomAdapter loopDataAdapter = null;
|
PluginCustomAdapter loopDataAdapter = null;
|
||||||
PluginCustomAdapter treatmentsDataAdapter = null;
|
PluginCustomAdapter treatmentsDataAdapter = null;
|
||||||
|
@ -73,6 +76,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
PluginCustomAdapter generalDataAdapter = null;
|
PluginCustomAdapter generalDataAdapter = null;
|
||||||
|
|
||||||
|
|
||||||
|
BgSourceInterface activeBgSource;
|
||||||
PumpInterface activePump;
|
PumpInterface activePump;
|
||||||
ProfileInterface activeProfile;
|
ProfileInterface activeProfile;
|
||||||
TreatmentsInterface activeTreatments;
|
TreatmentsInterface activeTreatments;
|
||||||
|
@ -108,6 +112,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
|
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
|
||||||
|
bgsourceListView = (ListView) view.findViewById(R.id.configbuilder_bgsourcelistview);
|
||||||
pumpListView = (ListView) view.findViewById(R.id.configbuilder_pumplistview);
|
pumpListView = (ListView) view.findViewById(R.id.configbuilder_pumplistview);
|
||||||
loopListView = (ListView) view.findViewById(R.id.configbuilder_looplistview);
|
loopListView = (ListView) view.findViewById(R.id.configbuilder_looplistview);
|
||||||
treatmentsListView = (ListView) view.findViewById(R.id.configbuilder_treatmentslistview);
|
treatmentsListView = (ListView) view.findViewById(R.id.configbuilder_treatmentslistview);
|
||||||
|
@ -122,6 +127,9 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViews() {
|
void setViews() {
|
||||||
|
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.BGSOURCE));
|
||||||
|
bgsourceListView.setAdapter(bgsourceDataAdapter);
|
||||||
|
setListViewHeightBasedOnChildren(bgsourceListView);
|
||||||
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PUMP));
|
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainActivity.getSpecificPluginsList(PluginBase.PUMP));
|
||||||
pumpListView.setAdapter(pumpDataAdapter);
|
pumpListView.setAdapter(pumpDataAdapter);
|
||||||
setListViewHeightBasedOnChildren(pumpListView);
|
setListViewHeightBasedOnChildren(pumpListView);
|
||||||
|
@ -198,11 +206,6 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
*
|
*
|
||||||
* Config builder return itself as a pump and check constraints before it passes command to pump driver
|
* Config builder return itself as a pump and check constraints before it passes command to pump driver
|
||||||
*/
|
*/
|
||||||
@Nullable
|
|
||||||
public PumpInterface getActivePump() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTempBasalInProgress() {
|
public boolean isTempBasalInProgress() {
|
||||||
return activePump.isTempBasalInProgress();
|
return activePump.isTempBasalInProgress();
|
||||||
|
@ -310,8 +313,13 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
public Result setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||||
// TODO: constraints here
|
Double rateAfterConstraints = applyBasalConstraints(insulin);
|
||||||
return activePump.setExtendedBolus(insulin, durationInMinutes);
|
Result result = activePump.setExtendedBolus(rateAfterConstraints, durationInMinutes);
|
||||||
|
if (result.enacted) {
|
||||||
|
uploadExtendedBolus(result.bolusDelivered, result.duration);
|
||||||
|
MainApp.bus().post(new EventTreatmentChange());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -460,6 +468,16 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public BgSourceInterface getActiveBgSource() {
|
||||||
|
return activeBgSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public PumpInterface getActivePump() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ProfileInterface getActiveProfile() {
|
public ProfileInterface getActiveProfile() {
|
||||||
return activeProfile;
|
return activeProfile;
|
||||||
|
@ -487,6 +505,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
// Single selection allowed
|
// Single selection allowed
|
||||||
case PluginBase.PROFILE:
|
case PluginBase.PROFILE:
|
||||||
case PluginBase.PUMP:
|
case PluginBase.PUMP:
|
||||||
|
case PluginBase.BGSOURCE:
|
||||||
case PluginBase.LOOP:
|
case PluginBase.LOOP:
|
||||||
case PluginBase.TEMPBASAL:
|
case PluginBase.TEMPBASAL:
|
||||||
case PluginBase.TREATMENT:
|
case PluginBase.TREATMENT:
|
||||||
|
@ -508,7 +527,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifySelectionInCategories() {
|
private void verifySelectionInCategories() {
|
||||||
for (int category : new int[]{PluginBase.GENERAL, PluginBase.APS, PluginBase.PROFILE, PluginBase.PUMP, PluginBase.LOOP, PluginBase.TEMPBASAL, PluginBase.TREATMENT}) {
|
for (int category : new int[]{PluginBase.GENERAL, PluginBase.APS, PluginBase.PROFILE, PluginBase.PUMP, PluginBase.LOOP, PluginBase.TEMPBASAL, PluginBase.TREATMENT, PluginBase.BGSOURCE}) {
|
||||||
ArrayList<PluginBase> pluginsInCategory = MainActivity.getSpecificPluginsList(category);
|
ArrayList<PluginBase> pluginsInCategory = MainActivity.getSpecificPluginsList(category);
|
||||||
switch (category) {
|
switch (category) {
|
||||||
// Multiple selection allowed
|
// Multiple selection allowed
|
||||||
|
@ -517,6 +536,17 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
case PluginBase.CONSTRAINTS:
|
case PluginBase.CONSTRAINTS:
|
||||||
break;
|
break;
|
||||||
// Single selection allowed
|
// Single selection allowed
|
||||||
|
case PluginBase.BGSOURCE:
|
||||||
|
activeBgSource = (BgSourceInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||||
|
if (Config.logConfigBuilder)
|
||||||
|
log.debug("Selected bgSource interface: " + ((PluginBase) activeBgSource).getName());
|
||||||
|
for (PluginBase p : pluginsInCategory) {
|
||||||
|
if (!p.getName().equals(((PluginBase) activeBgSource).getName())) {
|
||||||
|
p.setFragmentVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// Single selection allowed
|
||||||
case PluginBase.PROFILE:
|
case PluginBase.PROFILE:
|
||||||
activeProfile = (ProfileInterface) getTheOneEnabledInArray(pluginsInCategory);
|
activeProfile = (ProfileInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||||
if (Config.logConfigBuilder)
|
if (Config.logConfigBuilder)
|
||||||
|
@ -803,4 +833,32 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void uploadExtendedBolus(Double insulin, double durationInMinutes) {
|
||||||
|
try {
|
||||||
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
data.put("eventType", "Combo Bolus");
|
||||||
|
data.put("duration", durationInMinutes);
|
||||||
|
data.put("splitNow", 0);
|
||||||
|
data.put("splitExt", 100);
|
||||||
|
data.put("enteredinsulin", insulin);
|
||||||
|
data.put("relative", insulin);
|
||||||
|
data.put("created_at", DateUtil.toISOString(new Date()));
|
||||||
|
data.put("enteredBy", MainApp.instance().getString(R.string.app_name));
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("action", "dbAdd");
|
||||||
|
bundle.putString("collection", "treatments");
|
||||||
|
bundle.putString("data", data.toString());
|
||||||
|
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
List<ResolveInfo> q = context.getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||||
|
if (q.size() < 1) {
|
||||||
|
log.error("DBADD No receivers");
|
||||||
|
} else log.debug("DBADD dbAdd " + q.size() + " receivers " + data.toString());
|
||||||
|
} catch (JSONException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package info.nightscout.androidaps.plugins.SourceNSClient;
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
|
public class SourceNSClientFragment extends Fragment implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
|
boolean fragmentEnabled = true;
|
||||||
|
|
||||||
|
public SourceNSClientFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return PluginBase.BGSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MainApp.instance().getString(R.string.nsclient);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return fragmentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisibleInTabs() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeHidden() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||||
|
this.fragmentEnabled = fragmentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFragmentVisible(boolean fragmentVisible) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SourceNSClientFragment newInstance() {
|
||||||
|
SourceNSClientFragment fragment = new SourceNSClientFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package info.nightscout.androidaps.plugins.SourceXdrip;
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
|
||||||
|
public class SourceXdripFragment extends Fragment implements PluginBase, BgSourceInterface {
|
||||||
|
|
||||||
|
boolean fragmentEnabled = true;
|
||||||
|
|
||||||
|
public SourceXdripFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return PluginBase.BGSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return MainApp.instance().getString(R.string.xdrip);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return fragmentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisibleInTabs() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeHidden() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFragmentEnabled(boolean fragmentEnabled) {
|
||||||
|
this.fragmentEnabled = fragmentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFragmentVisible(boolean fragmentVisible) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SourceXdripFragment newInstance() {
|
||||||
|
SourceXdripFragment fragment = new SourceXdripFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
}
|
|
@ -309,12 +309,15 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInt
|
||||||
extendedBolus.isAbsolute = true;
|
extendedBolus.isAbsolute = true;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
result.bolusDelivered = insulin;
|
||||||
|
result.duration = durationInMinutes;
|
||||||
result.comment = getString(R.string.virtualpump_resultok);
|
result.comment = getString(R.string.virtualpump_resultok);
|
||||||
try {
|
try {
|
||||||
MainApp.instance().getDbHelper().getDaoTempBasals().create(extendedBolus);
|
MainApp.instance().getDbHelper().getDaoTempBasals().create(extendedBolus);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
result.success = false;
|
result.success = false;
|
||||||
|
result.enacted = false;
|
||||||
result.comment = getString(R.string.virtualpump_sqlerror);
|
result.comment = getString(R.string.virtualpump_sqlerror);
|
||||||
}
|
}
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.client.receivers;
|
package info.nightscout.androidaps.receivers;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -7,8 +7,11 @@ import android.support.v4.content.WakefulBroadcastReceiver;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.Services.DataService;
|
import info.nightscout.androidaps.Services.DataService;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
|
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
||||||
|
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
|
||||||
|
|
||||||
public class NSClientDataReceiver extends WakefulBroadcastReceiver {
|
public class NSClientDataReceiver extends WakefulBroadcastReceiver {
|
||||||
private static Logger log = LoggerFactory.getLogger(NSClientDataReceiver.class);
|
private static Logger log = LoggerFactory.getLogger(NSClientDataReceiver.class);
|
|
@ -7,8 +7,10 @@ import android.support.v4.content.WakefulBroadcastReceiver;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.Services.DataService;
|
import info.nightscout.androidaps.Services.DataService;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
|
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
|
||||||
|
|
||||||
|
|
||||||
public class xDripReceiver extends WakefulBroadcastReceiver {
|
public class xDripReceiver extends WakefulBroadcastReceiver {
|
||||||
|
@ -16,6 +18,11 @@ public class xDripReceiver extends WakefulBroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (MainActivity.getConfigBuilder().getActiveBgSource() == null) {
|
||||||
|
log.debug("getActiveBgSource is still null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MainActivity.getConfigBuilder().getActiveBgSource().getClass().equals(SourceXdripFragment.class)) {
|
||||||
if (Config.logFunctionCalls)
|
if (Config.logFunctionCalls)
|
||||||
log.debug("onReceive " + intent);
|
log.debug("onReceive " + intent);
|
||||||
startWakefulService(context, new Intent(context, DataService.class)
|
startWakefulService(context, new Intent(context, DataService.class)
|
||||||
|
@ -23,3 +30,4 @@ public class xDripReceiver extends WakefulBroadcastReceiver {
|
||||||
.putExtras(intent));
|
.putExtras(intent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,23 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:text="@string/configbuilder_bgsource"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/configbuilder_bgsourcelistview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:background="@color/cardColorBackground" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -142,5 +142,8 @@
|
||||||
<string name="carbs">Carbs</string>
|
<string name="carbs">Carbs</string>
|
||||||
<string name="changeyourinput">Change your input!</string>
|
<string name="changeyourinput">Change your input!</string>
|
||||||
<string name="setextendedbolusquestion">Set new extended bolus:</string>
|
<string name="setextendedbolusquestion">Set new extended bolus:</string>
|
||||||
|
<string name="configbuilder_bgsource">BG Source</string>
|
||||||
|
<string name="xdrip">xDrip</string>
|
||||||
|
<string name="nsclient">NSClient</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue