detect ns versions
This commit is contained in:
parent
2f16c9b998
commit
a4bdebdedf
|
@ -37,7 +37,7 @@
|
|||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<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">
|
||||
<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">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -44,6 +44,10 @@
|
|||
<action android:name="info.nightscout.client.NEW_PROFILE" />
|
||||
<action android:name="info.nightscout.client.NEW_SGV" />
|
||||
<action android:name="info.nightscout.client.NEW_STATUS" />
|
||||
<action android:name="info.nightscout.client.NEW_MBG" />
|
||||
<action android:name="info.nightscout.client.NEW_DEVICESTATUS" />
|
||||
<action android:name="info.nightscout.client.NEW_CAL" />
|
||||
<action android:name="info.nightscout.client.NEW_STATUS" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ public class Config {
|
|||
public static final boolean LOWSUSPEDENABLED = APS && true;
|
||||
public static final boolean OPENAPSMAENABLED = APS && true;
|
||||
public static final boolean LOOPENABLED = APS && true;
|
||||
public static final boolean OBJECTIVESENABLED = APS && true;
|
||||
|
||||
public static final boolean detailedLog = true;
|
||||
public static final boolean logFunctionCalls = true;
|
||||
|
|
|
@ -59,18 +59,15 @@ public class MainActivity extends AppCompatActivity {
|
|||
// Register all tabs in app here
|
||||
pluginsList.add(OverviewFragment.newInstance());
|
||||
pluginsList.add(VirtualPumpFragment.newInstance());
|
||||
if (Config.LOOPENABLED)
|
||||
pluginsList.add(LoopFragment.newInstance());
|
||||
if (Config.LOWSUSPEDENABLED)
|
||||
pluginsList.add(LowSuspendFragment.newInstance());
|
||||
if (Config.OPENAPSMAENABLED)
|
||||
pluginsList.add(OpenAPSMAFragment.newInstance());
|
||||
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.newInstance());
|
||||
if (Config.LOWSUSPEDENABLED) pluginsList.add(LowSuspendFragment.newInstance());
|
||||
if (Config.OPENAPSMAENABLED) pluginsList.add(OpenAPSMAFragment.newInstance());
|
||||
pluginsList.add(NSProfileViewerFragment.newInstance());
|
||||
pluginsList.add(SimpleProfileFragment.newInstance());
|
||||
pluginsList.add(TreatmentsFragment.newInstance());
|
||||
pluginsList.add(TempBasalsFragment.newInstance());
|
||||
pluginsList.add(SafetyFragment.newInstance());
|
||||
pluginsList.add(ObjectivesFragment.newInstance());
|
||||
if (Config.OPENAPSMAENABLED) pluginsList.add(ObjectivesFragment.newInstance());
|
||||
pluginsList.add(SourceXdripFragment.newInstance());
|
||||
pluginsList.add(SourceNSClientFragment.newInstance());
|
||||
pluginsList.add(configBuilderFragment = ConfigBuilderFragment.newInstance());
|
||||
|
@ -162,4 +159,14 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
return newList;
|
||||
}
|
||||
|
||||
public static PluginBase getSpecificPlugin(Class pluginClass) {
|
||||
Iterator<PluginBase> it = pluginsList.iterator();
|
||||
while (it.hasNext()) {
|
||||
PluginBase p = it.next();
|
||||
if (p.getClass() == pluginClass)
|
||||
return p;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainActivity;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
|
@ -34,12 +35,14 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
|
|||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.Objectives.ObjectivesFragment;
|
||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientFragment;
|
||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripFragment;
|
||||
import info.nightscout.androidaps.receivers.NSClientDataReceiver;
|
||||
import info.nightscout.androidaps.receivers.xDripReceiver;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.client.data.NSSgv;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
|
||||
public class DataService extends IntentService {
|
||||
|
@ -78,7 +81,11 @@ public class DataService extends IntentService {
|
|||
Intents.ACTION_NEW_TREATMENT.equals(action) ||
|
||||
Intents.ACTION_CHANGED_TREATMENT.equals(action) ||
|
||||
Intents.ACTION_REMOVED_TREATMENT.equals(action) ||
|
||||
Intents.ACTION_NEW_SGV.equals(action)
|
||||
Intents.ACTION_NEW_SGV.equals(action) ||
|
||||
Intents.ACTION_NEW_STATUS.equals(action) ||
|
||||
Intents.ACTION_NEW_DEVICESTATUS.equals(action) ||
|
||||
Intents.ACTION_NEW_CAL.equals(action) ||
|
||||
Intents.ACTION_NEW_MBG.equals(action)
|
||||
) {
|
||||
handleNewDataFromNSClient(intent);
|
||||
NSClientDataReceiver.completeWakefulIntent(intent);
|
||||
|
@ -145,6 +152,22 @@ public class DataService extends IntentService {
|
|||
if (bundles == null) return;
|
||||
|
||||
|
||||
if (intent.getAction().equals(Intents.ACTION_NEW_STATUS)) {
|
||||
if (Config.logIncommingData)
|
||||
log.debug("Received status: " + bundles);
|
||||
if (bundles.containsKey("nsclientversioncode")) {
|
||||
ConfigBuilderFragment configBuilderFragment = MainApp.getConfigBuilder();
|
||||
configBuilderFragment.nightscoutVersionCode = bundles.getInt("nightscoutversioncode"); // for ver 1.2.3 contains 10203
|
||||
configBuilderFragment.nightscoutVersionName = bundles.getString("nightscoutversionname");
|
||||
configBuilderFragment.nsClientVersionCode = bundles.getInt("nsclientversioncode"); // for ver 1.17 contains 117
|
||||
configBuilderFragment.nsClientVersionName = bundles.getString("nsclientversionname");
|
||||
log.debug("Got versions: NSClient: " + configBuilderFragment.nsClientVersionName + " Nightscout: " + configBuilderFragment.nightscoutVersionName);
|
||||
if (configBuilderFragment.nsClientVersionCode < 117)
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.resources.getString(R.string.unsupportedclientver));
|
||||
} else {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.resources.getString(R.string.unsupportedclientver));
|
||||
}
|
||||
}
|
||||
// Handle profile
|
||||
if (intent.getAction().equals(Intents.ACTION_NEW_PROFILE)) {
|
||||
try {
|
||||
|
@ -354,6 +377,9 @@ public class DataService extends IntentService {
|
|||
}
|
||||
MainApp.bus().post(new EventNewBG());
|
||||
}
|
||||
// Objectives 0
|
||||
ObjectivesFragment objectivesFragment = (ObjectivesFragment) MainActivity.getSpecificPlugin(ObjectivesFragment.class);
|
||||
if (objectivesFragment != null) objectivesFragment.bgIsAvailableInNS = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ public interface Intents {
|
|||
String ACTION_REMOVED_TREATMENT = "info.nightscout.client.REMOVED_TREATMENT";
|
||||
String ACTION_NEW_PROFILE = "info.nightscout.client.NEW_PROFILE";
|
||||
String ACTION_NEW_SGV = "info.nightscout.client.NEW_SGV";
|
||||
String ACTION_NEW_DEVICESTATUS = "info.nightscout.client.NEW_DEVICESTATUS";
|
||||
String ACTION_NEW_MBG = "info.nightscout.client.NEW_MBG";
|
||||
String ACTION_NEW_CAL = "info.nightscout.client.NEW_CAL";
|
||||
String ACTION_NEW_STATUS = "info.nightscout.client.NEW_STATUS";
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
@ -66,6 +67,8 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
ListView apsListView;
|
||||
ListView constraintsListView;
|
||||
ListView generalListView;
|
||||
TextView nsclientVerView;
|
||||
TextView nightscoutVerView;
|
||||
|
||||
PluginCustomAdapter bgsourceDataAdapter = null;
|
||||
PluginCustomAdapter pumpDataAdapter = null;
|
||||
|
@ -85,6 +88,11 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
TempBasalsInterface activeTempBasals;
|
||||
LoopFragment activeLoop;
|
||||
|
||||
public String nightscoutVersionName = "";
|
||||
public Integer nightscoutVersionCode = 0;
|
||||
public String nsClientVersionName = "";
|
||||
public Integer nsClientVersionCode = 0;
|
||||
|
||||
ArrayList<PluginBase> pluginList;
|
||||
|
||||
public ConfigBuilderFragment() {
|
||||
|
@ -124,7 +132,13 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI
|
|||
apsListView = (ListView) view.findViewById(R.id.configbuilder_apslistview);
|
||||
constraintsListView = (ListView) view.findViewById(R.id.configbuilder_constraintslistview);
|
||||
generalListView = (ListView) view.findViewById(R.id.configbuilder_generallistview);
|
||||
nsclientVerView = (TextView) view.findViewById(R.id.configbuilder_nsclientversion);
|
||||
nightscoutVerView = (TextView) view.findViewById(R.id.configbuilder_nightscoutversion);
|
||||
|
||||
nsclientVerView.setText(nsClientVersionName);
|
||||
nightscoutVerView.setText(nightscoutVersionName);
|
||||
if (nsClientVersionCode < 117) nsclientVerView.setTextColor(Color.RED);
|
||||
if (nightscoutVersionCode < 900) nightscoutVerView.setTextColor(Color.RED);
|
||||
setViews();
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -99,6 +99,11 @@ public class ObjectivesFragment extends Fragment implements View.OnClickListener
|
|||
}
|
||||
}
|
||||
|
||||
// Objective 0
|
||||
public boolean bgIsAvailableInNS = false;
|
||||
public boolean pumpStatusIsAvailableInNS = false;
|
||||
|
||||
|
||||
private List<Objective> objectives;
|
||||
|
||||
private void initializeData() {
|
||||
|
|
|
@ -13,6 +13,45 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="NSClient version:" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:id="@+id/configbuilder_nsclientversion"
|
||||
android:layout_marginLeft="10dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Nightscout version:" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:id="@+id/configbuilder_nightscoutversion"
|
||||
android:layout_marginLeft="10dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -149,5 +149,6 @@
|
|||
<string name="closedloop">Closed Loop</string>
|
||||
<string name="openloop">Open Loop</string>
|
||||
<string name="openloop_newsuggestion">New suggestion available</string>
|
||||
<string name="unsupportedclientver">Unsupported version of NSClient</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue