add source selection xdrip/nsclient
This commit is contained in:
parent
ea43a033d7
commit
edddfed004
|
@ -37,7 +37,7 @@
|
|||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</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" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
<!-- Receiver from NSClient -->
|
||||
<receiver
|
||||
android:name="info.nightscout.client.receivers.NSClientDataReceiver"
|
||||
android:name=".receivers.NSClientDataReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<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.SafetyFragment.SafetyFragment;
|
||||
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.Treatments.TreatmentsFragment;
|
||||
import info.nightscout.androidaps.plugins.VirtualPump.VirtualPumpFragment;
|
||||
|
@ -73,6 +75,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
pluginsList.add(TempBasalsFragment.newInstance());
|
||||
pluginsList.add(SafetyFragment.newInstance());
|
||||
pluginsList.add(ObjectivesFragment.newInstance());
|
||||
pluginsList.add(SourceXdripFragment.newInstance());
|
||||
pluginsList.add(SourceNSClientFragment.newInstance());
|
||||
pluginsList.add(configBuilderFragment = ConfigBuilderFragment.newInstance());
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
|
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.events.EventNewBasalProfile;
|
|||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.client.data.NSSgv;
|
||||
|
||||
|
@ -297,6 +298,7 @@ public class DataService extends IntentService {
|
|||
}
|
||||
|
||||
if (intent.getAction().equals(Intents.ACTION_NEW_SGV)) {
|
||||
if (MainActivity.getConfigBuilder().getActiveBgSource().getClass().equals(SourceNSClientFragment.class)) {
|
||||
try {
|
||||
if (bundles.containsKey("sgv")) {
|
||||
String sgvstring = bundles.getString("sgv");
|
||||
|
@ -330,6 +332,7 @@ public class DataService extends IntentService {
|
|||
MainApp.bus().post(new EventNewBG());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
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 CONSTRAINTS = 7;
|
||||
int LOOP = 8;
|
||||
int BGSOURCE = 9;
|
||||
|
||||
public int getType();
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import info.nightscout.androidaps.db.Treatment;
|
|||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
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";
|
||||
|
||||
ListView bgsourceListView;
|
||||
ListView pumpListView;
|
||||
ListView loopListView;
|
||||
ListView treatmentsListView;
|
||||
|
@ -63,6 +65,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ListView constraintsListView;
|
||||
ListView generalListView;
|
||||
|
||||
PluginCustomAdapter bgsourceDataAdapter = null;
|
||||
PluginCustomAdapter pumpDataAdapter = null;
|
||||
PluginCustomAdapter loopDataAdapter = null;
|
||||
PluginCustomAdapter treatmentsDataAdapter = null;
|
||||
|
@ -73,6 +76,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
PluginCustomAdapter generalDataAdapter = null;
|
||||
|
||||
|
||||
BgSourceInterface activeBgSource;
|
||||
PumpInterface activePump;
|
||||
ProfileInterface activeProfile;
|
||||
TreatmentsInterface activeTreatments;
|
||||
|
@ -108,6 +112,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
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);
|
||||
loopListView = (ListView) view.findViewById(R.id.configbuilder_looplistview);
|
||||
treatmentsListView = (ListView) view.findViewById(R.id.configbuilder_treatmentslistview);
|
||||
|
@ -122,6 +127,9 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
}
|
||||
|
||||
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));
|
||||
pumpListView.setAdapter(pumpDataAdapter);
|
||||
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
|
||||
*/
|
||||
@Nullable
|
||||
public PumpInterface getActivePump() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTempBasalInProgress() {
|
||||
return activePump.isTempBasalInProgress();
|
||||
|
@ -465,6 +468,16 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BgSourceInterface getActiveBgSource() {
|
||||
return activeBgSource;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PumpInterface getActivePump() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ProfileInterface getActiveProfile() {
|
||||
return activeProfile;
|
||||
|
@ -492,6 +505,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
// Single selection allowed
|
||||
case PluginBase.PROFILE:
|
||||
case PluginBase.PUMP:
|
||||
case PluginBase.BGSOURCE:
|
||||
case PluginBase.LOOP:
|
||||
case PluginBase.TEMPBASAL:
|
||||
case PluginBase.TREATMENT:
|
||||
|
@ -513,7 +527,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
}
|
||||
|
||||
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);
|
||||
switch (category) {
|
||||
// Multiple selection allowed
|
||||
|
@ -522,6 +536,17 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
case PluginBase.CONSTRAINTS:
|
||||
break;
|
||||
// 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:
|
||||
activeProfile = (ProfileInterface) getTheOneEnabledInArray(pluginsInCategory);
|
||||
if (Config.logConfigBuilder)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.client.receivers;
|
||||
package info.nightscout.androidaps.receivers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -7,8 +7,11 @@ import android.support.v4.content.WakefulBroadcastReceiver;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainActivity;
|
||||
import info.nightscout.androidaps.Services.DataService;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
|
||||
|
||||
public class NSClientDataReceiver extends WakefulBroadcastReceiver {
|
||||
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.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainActivity;
|
||||
import info.nightscout.androidaps.Services.DataService;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
|
||||
|
||||
|
||||
public class xDripReceiver extends WakefulBroadcastReceiver {
|
||||
|
@ -16,6 +18,11 @@ public class xDripReceiver extends WakefulBroadcastReceiver {
|
|||
|
||||
@Override
|
||||
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)
|
||||
log.debug("onReceive " + intent);
|
||||
startWakefulService(context, new Intent(context, DataService.class)
|
||||
|
@ -23,3 +30,4 @@ public class xDripReceiver extends WakefulBroadcastReceiver {
|
|||
.putExtras(intent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,23 @@
|
|||
android:layout_height="match_parent"
|
||||
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
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -142,5 +142,8 @@
|
|||
<string name="carbs">Carbs</string>
|
||||
<string name="changeyourinput">Change your input!</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>
|
||||
|
|
Loading…
Reference in a new issue